tinydir.h (98cd9557da96230d06c9149ea591e10cc3829288) | tinydir.h (ec8ca29f14e3b738f9bc53e3f9b016e8a472ef04) |
---|---|
1/* | 1/* |
2Copyright (c) 2013-2017, tinydir authors: | 2Copyright (c) 2013-2018, tinydir authors: |
3- Cong Xu 4- Lautis Sun 5- Baudouin Feildel 6- Andargor <[email protected]> 7All rights reserved. 8 9Redistribution and use in source and binary forms, with or without 10modification, are permitted provided that the following conditions are met: --- 73 unchanged lines hidden (view full) --- 84# define _tinydir_strncmp strncmp 85#endif 86 87#if (defined _MSC_VER || defined __MINGW32__) 88# include <windows.h> 89# define _TINYDIR_PATH_MAX MAX_PATH 90#elif defined __linux__ 91# include <limits.h> | 3- Cong Xu 4- Lautis Sun 5- Baudouin Feildel 6- Andargor <[email protected]> 7All rights reserved. 8 9Redistribution and use in source and binary forms, with or without 10modification, are permitted provided that the following conditions are met: --- 73 unchanged lines hidden (view full) --- 84# define _tinydir_strncmp strncmp 85#endif 86 87#if (defined _MSC_VER || defined __MINGW32__) 88# include <windows.h> 89# define _TINYDIR_PATH_MAX MAX_PATH 90#elif defined __linux__ 91# include <limits.h> |
92# define _TINYDIR_PATH_MAX PATH_MAX | 92/* BK - only use PATH_MAX if defined */ 93# if defined(PATH_MAX) 94# define _TINYDIR_PATH_MAX PATH_MAX 95# endif |
93#elif defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) 94# include <sys/param.h> 95# if defined(BSD) 96# include <limits.h> 97# define _TINYDIR_PATH_MAX PATH_MAX 98# endif 99#endif 100 --- 259 unchanged lines hidden (view full) --- 360 n_files++; 361 if (tinydir_next(dir) == -1) 362 { 363 goto bail; 364 } 365 } 366 tinydir_close(dir); 367 | 96#elif defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) 97# include <sys/param.h> 98# if defined(BSD) 99# include <limits.h> 100# define _TINYDIR_PATH_MAX PATH_MAX 101# endif 102#endif 103 --- 259 unchanged lines hidden (view full) --- 363 n_files++; 364 if (tinydir_next(dir) == -1) 365 { 366 goto bail; 367 } 368 } 369 tinydir_close(dir); 370 |
368 if (tinydir_open(dir, path) == -1) | 371 if (n_files == 0 || tinydir_open(dir, path) == -1) |
369 { 370 return -1; 371 } 372 373 dir->n_files = 0; 374 dir->_files = (tinydir_file *)_TINYDIR_MALLOC(sizeof *dir->_files * n_files); 375 if (dir->_files == NULL) 376 { --- 276 unchanged lines hidden (view full) --- 653 { 654 errno = ENAMETOOLONG; 655 return -1; 656 } 657 658 /* Get the parent path */ 659#if (defined _MSC_VER || defined __MINGW32__) 660#if ((defined _MSC_VER) && (_MSC_VER >= 1400)) | 372 { 373 return -1; 374 } 375 376 dir->n_files = 0; 377 dir->_files = (tinydir_file *)_TINYDIR_MALLOC(sizeof *dir->_files * n_files); 378 if (dir->_files == NULL) 379 { --- 276 unchanged lines hidden (view full) --- 656 { 657 errno = ENAMETOOLONG; 658 return -1; 659 } 660 661 /* Get the parent path */ 662#if (defined _MSC_VER || defined __MINGW32__) 663#if ((defined _MSC_VER) && (_MSC_VER >= 1400)) |
661 _tsplitpath_s( | 664 errno = _tsplitpath_s( |
662 path, 663 drive_buf, _TINYDIR_DRIVE_MAX, 664 dir_name_buf, _TINYDIR_FILENAME_MAX, 665 file_name_buf, _TINYDIR_FILENAME_MAX, 666 ext_buf, _TINYDIR_FILENAME_MAX); 667#else 668 _tsplitpath( 669 path, 670 drive_buf, 671 dir_name_buf, 672 file_name_buf, 673 ext_buf); 674#endif 675 | 665 path, 666 drive_buf, _TINYDIR_DRIVE_MAX, 667 dir_name_buf, _TINYDIR_FILENAME_MAX, 668 file_name_buf, _TINYDIR_FILENAME_MAX, 669 ext_buf, _TINYDIR_FILENAME_MAX); 670#else 671 _tsplitpath( 672 path, 673 drive_buf, 674 dir_name_buf, 675 file_name_buf, 676 ext_buf); 677#endif 678 |
679if (errno) 680{ 681 return -1; 682} 683 |
|
676/* _splitpath_s not work fine with only filename and widechar support */ 677#ifdef _UNICODE 678 if (drive_buf[0] == L'\xFEFE') 679 drive_buf[0] = '\0'; 680 if (dir_name_buf[0] == L'\xFEFE') 681 dir_name_buf[0] = '\0'; 682#endif 683 | 684/* _splitpath_s not work fine with only filename and widechar support */ 685#ifdef _UNICODE 686 if (drive_buf[0] == L'\xFEFE') 687 drive_buf[0] = '\0'; 688 if (dir_name_buf[0] == L'\xFEFE') 689 dir_name_buf[0] = '\0'; 690#endif 691 |
684 if (errno) 685 { 686 errno = EINVAL; 687 return -1; 688 } | |
689 /* Emulate the behavior of dirname by returning "." for dir name if it's 690 empty */ 691 if (drive_buf[0] == '\0' && dir_name_buf[0] == '\0') 692 { 693 _tinydir_strcpy(dir_name_buf, TINYDIR_STRING(".")); 694 } 695 /* Concatenate the drive letter and dir name to form full dir name */ 696 _tinydir_strcat(drive_buf, dir_name_buf); --- 120 unchanged lines hidden --- | 692 /* Emulate the behavior of dirname by returning "." for dir name if it's 693 empty */ 694 if (drive_buf[0] == '\0' && dir_name_buf[0] == '\0') 695 { 696 _tinydir_strcpy(dir_name_buf, TINYDIR_STRING(".")); 697 } 698 /* Concatenate the drive letter and dir name to form full dir name */ 699 _tinydir_strcat(drive_buf, dir_name_buf); --- 120 unchanged lines hidden --- |