--- parser3/src/include/pa_dir.h 2001/08/31 15:35:34 1.4 +++ parser3/src/include/pa_dir.h 2013/07/21 14:45:32 1.22 @@ -1,16 +1,15 @@ /** @file Parser: directory scanning for different OS-es decls. - Copyright (c) 2000,2001 ArtLebedev Group (http://www.artlebedev.com) - - Author: Alexander Petrosyan (http://design.ru/paf) - - $Id: pa_dir.h,v 1.4 2001/08/31 15:35:34 parser Exp $ + Copyright (c) 2000-2012 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.22 2013/07/21 14:45:32 moko Exp $" + #include "pa_config_includes.h" /** @struct ffblk @@ -40,13 +39,18 @@ struct ffblk { HANDLE handle; /* - unsigned char ff_attrib __attribute__((packed)); unsigned short ff_ftime __attribute__((packed)); unsigned short ff_fdate __attribute__((packed)); unsigned long ff_fsize __attribute__((packed)); char ff_name[260] __attribute__((packed)); */ + void stat_file(); + bool is_dir(); + double size(); + time_t c_timestamp(); + time_t m_timestamp(); + time_t a_timestamp(); }; #else @@ -61,30 +65,43 @@ struct ffblk { struct ffblk { /*as if in windows :)*/ - unsigned char ff_attrib; char ff_name[ MAXPATH ]; /*helpers*/ DIR *dir; char filePath[MAXPATH]; + struct stat _st; + +#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(); + double size(); + time_t c_timestamp(); + time_t m_timestamp(); + time_t a_timestamp(); }; #endif -bool findfirst(const char *_pathname, struct ffblk *_ffblk, int _attrib); +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 +/// main dir workhorse: calles win32/unix unified functions findfirst/next/close [skip . and ..] #define LOAD_DIR(dir,action) {\ ffblk ffblk; \ - bool done=findfirst(dir, &ffblk, 0); \ - while(!done) { \ - if(*ffblk.ff_name && ffblk.ff_name[0]!='.') {\ - action; \ - } \ - done=findnext(&ffblk); \ - } \ - findclose(&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) )) {\ + action; \ + } \ + while(!findnext(&ffblk)); \ + findclose(&ffblk); \ + } \ } #endif