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

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.20    ! moko       11: #define IDENT_PA_DIR_H "$Id: 2006-04-09 13:38:47 $"
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.19      paf        22: #define  WINVER  0x0400
1.1       paf        23: #include <windows.h>
                     24: 
                     25: #define MAXPATH MAX_PATH
                     26: #define FA_DIREC FILE_ATTRIBUTE_DIRECTORY
                     27: 
                     28: struct ffblk {
                     29:     DWORD ff_attrib;/*dwFileAttributes;*/
                     30:     FILETIME ftCreationTime;
                     31:     FILETIME ftLastAccessTime;
                     32:     FILETIME ftLastWriteTime;
                     33:     DWORD nFileSizeHigh;
                     34:     DWORD nFileSizeLow;
                     35:     DWORD dwReserved0;
                     36:     DWORD dwReserved1;
                     37:     CHAR   ff_name[ MAX_PATH ];/*cFileName[ MAX_PATH ];*/
                     38:     CHAR   cAlternateFileName[ 14 ];
                     39:        /*helper*/
                     40:        HANDLE handle;
                     41: 
                     42: /*     
                     43:        
                     44:        unsigned char  ff_attrib __attribute__((packed));
                     45:   unsigned short ff_ftime __attribute__((packed));
                     46:   unsigned short ff_fdate __attribute__((packed));
                     47:   unsigned long  ff_fsize __attribute__((packed));
                     48:   char ff_name[260] __attribute__((packed));
                     49:  */
                     50: };
                     51: 
                     52: #else
                     53: 
                     54: #include <strings.h>   
                     55: #include <sys/types.h>
                     56: #include <dirent.h>
                     57: #include <sys/stat.h>
                     58: 
                     59: #define MAXPATH 1000 /*NAME_MAX*/
                     60: #define FA_DIREC S_IFDIR
                     61: 
                     62: struct ffblk {
                     63:        /*as if in windows :)*/
                     64:     unsigned char ff_attrib;
                     65:     char ff_name[ MAXPATH ];
                     66:        /*helpers*/
                     67:        DIR *dir;
                     68:        char filePath[MAXPATH];
                     69: };
                     70: 
                     71: #endif
                     72: 
1.14      paf        73: bool findfirst(const char* _pathname, struct ffblk *_ffblk, int _attrib);
1.1       paf        74: bool findnext(struct ffblk *_ffblk);
                     75: void findclose(struct ffblk *_ffblk);
                     76: 
1.18      paf        77: /// main dir workhorse: calles win32/unix unified functions findfirst/next/close [skip . and ..]
1.1       paf        78: #define LOAD_DIR(dir,action) {\
                     79:     ffblk ffblk; \
1.7       paf        80:     if(!findfirst(dir, &ffblk, 0)) { \
1.6       paf        81:                do \
1.18      paf        82:                        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        83:                                action; \
                     84:                        } \
1.7       paf        85:                while(!findnext(&ffblk)); \
1.6       paf        86:                findclose(&ffblk); \
                     87:        } \
1.1       paf        88: } 
                     89: 
                     90: #endif

E-mail: