Annotation of parser3/src/include/pa_dir.h, revision 1.24

1.1       paf         1: /** @file
                      2:        Parser: directory scanning for different OS-es decls.
                      3: 
1.20      moko        4:        Copyright (c) 2000-2012 Art. Lebedev Studio (http://www.artlebedev.com)
1.10      paf         5:        Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru)
1.1       paf         6: */
                      7: 
                      8: #ifndef PA_DIR_H
                      9: #define PA_DIR_H
1.11      paf        10: 
1.24    ! moko       11: #define IDENT_PA_DIR_H "$Id: pa_dir.h,v 1.23 2013/07/21 20:33:44 moko Exp $"
1.4       parser     12: 
                     13: #include "pa_config_includes.h"
1.1       paf        14: 
1.3       paf        15: /** @struct ffblk 
                     16:        win32/unix unified directory entry structure name
                     17:        for findfirst/next/close interface
                     18: */
                     19: 
1.1       paf        20: #ifdef WIN32
                     21: 
1.24    ! moko       22: #include <windows.h>
        !            23: 
1.1       paf        24: #define MAXPATH MAX_PATH
                     25: 
                     26: struct ffblk {
1.23      moko       27:        DWORD ff_attrib;/*dwFileAttributes;*/
                     28:        FILETIME ftCreationTime;
                     29:        FILETIME ftLastAccessTime;
                     30:        FILETIME ftLastWriteTime;
                     31:        DWORD nFileSizeHigh;
                     32:        DWORD nFileSizeLow;
                     33:        DWORD dwReserved0;
                     34:        DWORD dwReserved1;
                     35:        CHAR   ff_name[ MAX_PATH ];/*cFileName[ MAX_PATH ];*/
                     36:        CHAR   cAlternateFileName[ 14 ];
1.1       paf        37:        /*helper*/
                     38:        HANDLE handle;
                     39: 
1.23      moko       40:        void stat_file(){}
1.22      moko       41:        bool is_dir();
                     42:        double size();
                     43:        time_t c_timestamp();
                     44:        time_t m_timestamp();
                     45:        time_t a_timestamp();
1.1       paf        46: };
                     47: 
                     48: #else
                     49: 
                     50: #define MAXPATH 1000 /*NAME_MAX*/
                     51: 
                     52: struct ffblk {
                     53:        /*as if in windows :)*/
                     54:     char ff_name[ MAXPATH ];
                     55:        /*helpers*/
                     56:        DIR *dir;
1.23      moko       57:        const char *filePath;
1.22      moko       58:        struct stat _st;
                     59: 
                     60: #ifdef HAVE_STRUCT_DIRENT_D_TYPE
                     61:        unsigned char _d_type;
                     62:        void stat_file();
                     63: #else
                     64:        void stat_file(){}
                     65:        void real_stat_file();
                     66: #endif
                     67:        bool is_dir();
                     68:        double size();
                     69:        time_t c_timestamp();
                     70:        time_t m_timestamp();
                     71:        time_t a_timestamp();
1.1       paf        72: };
                     73: 
                     74: #endif
                     75: 
1.14      paf        76: bool findfirst(const char* _pathname, struct ffblk *_ffblk, int _attrib);
1.1       paf        77: bool findnext(struct ffblk *_ffblk);
                     78: void findclose(struct ffblk *_ffblk);
                     79: 
1.18      paf        80: /// main dir workhorse: calles win32/unix unified functions findfirst/next/close [skip . and ..]
1.1       paf        81: #define LOAD_DIR(dir,action) {\
                     82:     ffblk ffblk; \
1.7       paf        83:     if(!findfirst(dir, &ffblk, 0)) { \
1.6       paf        84:                do \
1.18      paf        85:                        if(*ffblk.ff_name && !(ffblk.ff_name[0]=='.' && (ffblk.ff_name[1]==0 || ffblk.ff_name[1]=='.' && ffblk.ff_name[2]==0)  )) {\
1.6       paf        86:                                action; \
                     87:                        } \
1.7       paf        88:                while(!findnext(&ffblk)); \
1.6       paf        89:                findclose(&ffblk); \
                     90:        } \
1.1       paf        91: } 
                     92: 
                     93: #endif

E-mail: