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

1.1       paf         1: /** @file
                      2:        Parser: directory scanning for different OS-es decls.
                      3: 
1.9     ! paf         4:        Copyright (c) 2000,2001, 2002 ArtLebedev Group (http://www.artlebedev.com)
1.8       paf         5:        Author: Alexander Petrosyan <paf@design.ru> (http://paf.design.ru)
1.1       paf         6: 
1.9     ! paf         7:        $Id: pa_dir.h,v 1.8 2001/11/05 11:46:24 paf Exp $
1.1       paf         8: */
                      9: 
                     10: #ifndef PA_DIR_H
                     11: #define PA_DIR_H
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: #include <windows.h>
                     23: 
                     24: #define MAXPATH MAX_PATH
                     25: #define FA_DIREC FILE_ATTRIBUTE_DIRECTORY
                     26: 
                     27: struct ffblk {
                     28:     DWORD ff_attrib;/*dwFileAttributes;*/
                     29:     FILETIME ftCreationTime;
                     30:     FILETIME ftLastAccessTime;
                     31:     FILETIME ftLastWriteTime;
                     32:     DWORD nFileSizeHigh;
                     33:     DWORD nFileSizeLow;
                     34:     DWORD dwReserved0;
                     35:     DWORD dwReserved1;
                     36:     CHAR   ff_name[ MAX_PATH ];/*cFileName[ MAX_PATH ];*/
                     37:     CHAR   cAlternateFileName[ 14 ];
                     38:        /*helper*/
                     39:        HANDLE handle;
                     40: 
                     41: /*     
                     42:        
                     43:        unsigned char  ff_attrib __attribute__((packed));
                     44:   unsigned short ff_ftime __attribute__((packed));
                     45:   unsigned short ff_fdate __attribute__((packed));
                     46:   unsigned long  ff_fsize __attribute__((packed));
                     47:   char ff_name[260] __attribute__((packed));
                     48:  */
                     49: };
                     50: 
                     51: #else
                     52: 
                     53: #include <strings.h>   
                     54: #include <sys/types.h>
                     55: #include <dirent.h>
                     56: #include <sys/stat.h>
                     57: 
                     58: #define MAXPATH 1000 /*NAME_MAX*/
                     59: #define FA_DIREC S_IFDIR
                     60: 
                     61: struct ffblk {
                     62:        /*as if in windows :)*/
                     63:     unsigned char ff_attrib;
                     64:     char ff_name[ MAXPATH ];
                     65:        /*helpers*/
                     66:        DIR *dir;
                     67:        char filePath[MAXPATH];
                     68: };
                     69: 
                     70: #endif
                     71: 
                     72: bool findfirst(const char *_pathname, struct ffblk *_ffblk, int _attrib);
                     73: bool findnext(struct ffblk *_ffblk);
                     74: void findclose(struct ffblk *_ffblk);
                     75: 
1.3       paf        76: /// main dir workhorse: calles win32/unix unified functions findfirst/next/close
1.1       paf        77: #define LOAD_DIR(dir,action) {\
                     78:     ffblk ffblk; \
1.7       paf        79:     if(!findfirst(dir, &ffblk, 0)) { \
1.6       paf        80:                do \
                     81:                        if(*ffblk.ff_name && ffblk.ff_name[0]!='.') {\
                     82:                                action; \
                     83:                        } \
1.7       paf        84:                while(!findnext(&ffblk)); \
1.6       paf        85:                findclose(&ffblk); \
                     86:        } \
1.1       paf        87: } 
                     88: 
                     89: #endif

E-mail: