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

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.23    ! moko       11: #define IDENT_PA_DIR_H "$Id: pa_dir.h,v 1.22 2013/07/21 14:45:32 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: 
                     22: #define MAXPATH MAX_PATH
                     23: 
                     24: struct ffblk {
1.23    ! moko       25:        DWORD ff_attrib;/*dwFileAttributes;*/
        !            26:        FILETIME ftCreationTime;
        !            27:        FILETIME ftLastAccessTime;
        !            28:        FILETIME ftLastWriteTime;
        !            29:        DWORD nFileSizeHigh;
        !            30:        DWORD nFileSizeLow;
        !            31:        DWORD dwReserved0;
        !            32:        DWORD dwReserved1;
        !            33:        CHAR   ff_name[ MAX_PATH ];/*cFileName[ MAX_PATH ];*/
        !            34:        CHAR   cAlternateFileName[ 14 ];
1.1       paf        35:        /*helper*/
                     36:        HANDLE handle;
                     37: 
1.23    ! moko       38:        void stat_file(){}
1.22      moko       39:        bool is_dir();
                     40:        double size();
                     41:        time_t c_timestamp();
                     42:        time_t m_timestamp();
                     43:        time_t a_timestamp();
1.1       paf        44: };
                     45: 
                     46: #else
                     47: 
                     48: #define MAXPATH 1000 /*NAME_MAX*/
                     49: 
                     50: struct ffblk {
                     51:        /*as if in windows :)*/
                     52:     char ff_name[ MAXPATH ];
                     53:        /*helpers*/
                     54:        DIR *dir;
1.23    ! moko       55:        const char *filePath;
1.22      moko       56:        struct stat _st;
                     57: 
                     58: #ifdef HAVE_STRUCT_DIRENT_D_TYPE
                     59:        unsigned char _d_type;
                     60:        void stat_file();
                     61: #else
                     62:        void stat_file(){}
                     63:        void real_stat_file();
                     64: #endif
                     65:        bool is_dir();
                     66:        double size();
                     67:        time_t c_timestamp();
                     68:        time_t m_timestamp();
                     69:        time_t a_timestamp();
1.1       paf        70: };
                     71: 
                     72: #endif
                     73: 
1.14      paf        74: bool findfirst(const char* _pathname, struct ffblk *_ffblk, int _attrib);
1.1       paf        75: bool findnext(struct ffblk *_ffblk);
                     76: void findclose(struct ffblk *_ffblk);
                     77: 
1.18      paf        78: /// main dir workhorse: calles win32/unix unified functions findfirst/next/close [skip . and ..]
1.1       paf        79: #define LOAD_DIR(dir,action) {\
                     80:     ffblk ffblk; \
1.7       paf        81:     if(!findfirst(dir, &ffblk, 0)) { \
1.6       paf        82:                do \
1.18      paf        83:                        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        84:                                action; \
                     85:                        } \
1.7       paf        86:                while(!findnext(&ffblk)); \
1.6       paf        87:                findclose(&ffblk); \
                     88:        } \
1.1       paf        89: } 
                     90: 
                     91: #endif

E-mail: