--- parser3/src/include/pa_dir.h 2013/07/21 21:01:03 1.24 +++ parser3/src/include/pa_dir.h 2017/02/06 16:17:12 1.28 @@ -1,14 +1,14 @@ /** @file Parser: directory scanning for different OS-es decls. - Copyright (c) 2000-2012 Art. Lebedev Studio (http://www.artlebedev.com) + Copyright (c) 2000-2015 Art. Lebedev Studio (http://www.artlebedev.com) Author: Alexandr Petrosian (http://paf.design.ru) */ #ifndef PA_DIR_H #define PA_DIR_H -#define IDENT_PA_DIR_H "$Id: pa_dir.h,v 1.24 2013/07/21 21:01:03 moko Exp $" +#define IDENT_PA_DIR_H "$Id: pa_dir.h,v 1.28 2017/02/06 16:17:12 moko Exp $" #include "pa_config_includes.h" @@ -17,28 +17,18 @@ for findfirst/next/close interface */ -#ifdef WIN32 +#ifdef _MSC_VER #include #define MAXPATH MAX_PATH 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; - void stat_file(){} - bool is_dir(); + const char *name(); + bool is_dir(bool); double size(); time_t c_timestamp(); time_t m_timestamp(); @@ -51,7 +41,7 @@ struct ffblk { struct ffblk { /*as if in windows :)*/ - char ff_name[ MAXPATH ]; + char ff_name[ MAXPATH ]; /*helpers*/ DIR *dir; const char *filePath; @@ -59,12 +49,11 @@ struct ffblk { #ifdef HAVE_STRUCT_DIRENT_D_TYPE unsigned char _d_type; - void stat_file(); -#else - void stat_file(){} - void real_stat_file(); #endif - bool is_dir(); + + const char *name(){ return ff_name; } + bool is_dir(bool); + void stat_file(); double size(); time_t c_timestamp(); time_t m_timestamp(); @@ -78,16 +67,17 @@ 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