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

1.1       paf         1: /** @file
                      2:        Parser: directory scanning for different OS-es decls.
                      3: 
1.2       paf         4:        Copyright (c) 2000,2001 ArtLebedev Group (http://www.artlebedev.com)
1.1       paf         5: 
                      6:        Author: Alexander Petrosyan <paf@design.ru> (http://design.ru/paf)
                      7: 
1.4     ! parser      8:        $Id: pa_dir.h,v 1.3 2001/04/26 14:55:25 paf Exp $
1.1       paf         9: */
                     10: 
                     11: #ifndef PA_DIR_H
                     12: #define PA_DIR_H
1.4     ! parser     13: 
        !            14: #include "pa_config_includes.h"
1.1       paf        15: 
1.3       paf        16: /** @struct ffblk 
                     17:        win32/unix unified directory entry structure name
                     18:        for findfirst/next/close interface
                     19: */
                     20: 
1.1       paf        21: #ifdef WIN32
                     22: 
                     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: 
                     73: bool findfirst(const char *_pathname, struct ffblk *_ffblk, int _attrib);
                     74: bool findnext(struct ffblk *_ffblk);
                     75: void findclose(struct ffblk *_ffblk);
                     76: 
1.3       paf        77: /// main dir workhorse: calles win32/unix unified functions findfirst/next/close
1.1       paf        78: #define LOAD_DIR(dir,action) {\
                     79:     ffblk ffblk; \
                     80:     bool done=findfirst(dir, &ffblk, 0); \
                     81:        while(!done) { \
                     82:                if(*ffblk.ff_name && ffblk.ff_name[0]!='.') {\
                     83:                        action; \
                     84:                } \
                     85:                done=findnext(&ffblk); \
                     86:     } \
                     87:        findclose(&ffblk); \
                     88: } 
                     89: 
                     90: #endif

E-mail: