--- parser3/src/main/pa_dir.C 2013/07/21 14:45:32 1.22 +++ parser3/src/main/pa_dir.C 2015/06/29 17:59:13 1.25 @@ -8,9 +8,9 @@ #include "pa_common.h" #include "pa_dir.h" -volatile const char * IDENT_PA_DIR_C="$Id: pa_dir.C,v 1.22 2013/07/21 14:45:32 moko Exp $" IDENT_PA_DIR_H; +volatile const char * IDENT_PA_DIR_C="$Id: pa_dir.C,v 1.25 2015/06/29 17:59:13 moko Exp $" IDENT_PA_DIR_H; -#ifdef WIN32 +#ifdef _MSC_VER #define TICKS_PER_SECOND 10000000ULL #define EPOCH_DIFFERENCE 11644473600ULL @@ -39,7 +39,7 @@ void findclose(struct ffblk *_ffblk) { FindClose(_ffblk->handle); } -bool ffblk::is_dir() { +bool ffblk::is_dir(bool) { return (ff_attrib & FILE_ATTRIBUTE_DIRECTORY) != 0; } @@ -65,8 +65,7 @@ time_t ffblk::a_timestamp() { #else bool findfirst(const char* _pathname, struct ffblk *_ffblk, int /*_attrib*/) { - strncpy(_ffblk->filePath, _pathname, MAXPATH-1); - _ffblk->filePath[MAXPATH-1]=0; + _ffblk->filePath=_pathname; if(!(_ffblk->dir=opendir(_ffblk->filePath))) return true; @@ -79,9 +78,8 @@ bool findnext(struct ffblk *_ffblk) { if(!entry) return true; - int maxsize=sizeof(_ffblk->ff_name)-1; - strncpy(_ffblk->ff_name, entry->d_name, maxsize-1); - _ffblk->ff_name[maxsize]=0; + strncpy(_ffblk->ff_name, entry->d_name, sizeof(_ffblk->ff_name)-1); + _ffblk->ff_name[sizeof(_ffblk->ff_name)-1]=0; #ifdef HAVE_STRUCT_DIRENT_D_TYPE // http://www.gnu.org/software/libc/manual/html_node/Directory-Entries.html @@ -95,11 +93,7 @@ void findclose(struct ffblk *_ffblk) { closedir(_ffblk->dir); } -#ifdef HAVE_STRUCT_DIRENT_D_TYPE void ffblk::stat_file() { -#else -void ffblk::real_stat_file() { -#endif char fileSpec[MAXPATH]; snprintf(fileSpec, MAXPATH, "%s/%s", filePath, ff_name); @@ -108,13 +102,13 @@ void ffblk::real_stat_file() { } } -bool ffblk::is_dir() { +bool ffblk::is_dir(bool stat) { #ifdef HAVE_STRUCT_DIRENT_D_TYPE - return (_d_type & DT_DIR) != 0; -#else - real_stat_file(); - return S_ISDIR(_st.st_mode) != 0; + if(!stat && _d_type != DT_UNKNOWN) + return _d_type == DT_DIR; #endif + stat_file(); + return S_ISDIR(_st.st_mode) != 0; } double ffblk::size() {