--- parser3/src/include/pa_dir.h 2015/06/29 17:59:13 1.26 +++ parser3/src/include/pa_dir.h 2026/09/27 17:13:40 1.36 @@ -1,14 +1,14 @@ /** @file Parser: directory scanning for different OS-es decls. - Copyright (c) 2000-2012 Art. Lebedev Studio (http://www.artlebedev.com) - Author: Alexandr Petrosian (http://paf.design.ru) + Copyright (c) 2000-2026 Art. Lebedev Studio (https://www.artlebedev.com) + Authors: Konstantin Morshnev , Alexandr Petrosian */ #ifndef PA_DIR_H #define PA_DIR_H -#define IDENT_PA_DIR_H "$Id: pa_dir.h,v 1.26 2015/06/29 17:59:13 moko Exp $" +#define IDENT_PA_DIR_H "$Id: pa_dir.h,v 1.36 2026/09/27 17:13:40 moko Exp $" #include "pa_config_includes.h" @@ -21,22 +21,13 @@ #include -#define MAXPATH MAX_PATH +#define MAXPATH ((MAX_PATH)*2) /*UTF-16*/ struct ffblk { - DWORD ff_attrib;/*dwFileAttributes;*/ - FILETIME ftCreationTime; - FILETIME ftLastAccessTime; - FILETIME ftLastWriteTime; - DWORD nFileSizeHigh; - DWORD nFileSizeLow; - DWORD dwReserved0; - DWORD dwReserved1; - CHAR ff_name[ MAX_PATH ];/*cFileName[ MAX_PATH ];*/ - CHAR cAlternateFileName[ 14 ]; - /*helper*/ + struct _WIN32_FIND_DATAW stat; HANDLE handle; + const char *name(); bool is_dir(bool); double size(); time_t c_timestamp(); @@ -44,13 +35,13 @@ struct ffblk { time_t a_timestamp(); }; -#else +#else // _MSC_VER #define MAXPATH 1000 /*NAME_MAX*/ struct ffblk { /*as if in windows :)*/ - char ff_name[ MAXPATH ]; + char ff_name[ MAXPATH ]; /*helpers*/ DIR *dir; const char *filePath; @@ -59,6 +50,8 @@ struct ffblk { #ifdef HAVE_STRUCT_DIRENT_D_TYPE unsigned char _d_type; #endif + + const char *name(){ return ff_name; } bool is_dir(bool); void stat_file(); double size(); @@ -67,23 +60,25 @@ struct ffblk { time_t a_timestamp(); }; -#endif +#endif // _MSC_VER bool findfirst(const char* _pathname, struct ffblk *_ffblk, int _attrib); bool findnext(struct ffblk *_ffblk); void findclose(struct ffblk *_ffblk); /// main dir workhorse: calles win32/unix unified functions findfirst/next/close [skip . and ..] -#define LOAD_DIR(dir,action) {\ - ffblk ffblk; \ - if(!findfirst(dir, &ffblk, 0)) { \ - do \ - if(*ffblk.ff_name && !(ffblk.ff_name[0]=='.' && (ffblk.ff_name[1]==0 || ffblk.ff_name[1]=='.' && ffblk.ff_name[2]==0) )) {\ +#define LOAD_DIR(dir,action) { \ + ffblk ffblk; \ + if(!findfirst(dir, &ffblk, 0)) { \ + do { \ + const char *file_name=ffblk.name(); \ + if(*file_name && !(file_name[0]=='.' && (file_name[1]==0 || file_name[1]=='.' && file_name[2]==0) )) { \ action; \ } \ - while(!findnext(&ffblk)); \ + } while(!findnext(&ffblk)); \ findclose(&ffblk); \ } \ -} +} + #endif