Annotation of parser3/src/include/pa_dir.h, revision 1.16.14.1
1.1 paf 1: /** @file
2: Parser: directory scanning for different OS-es decls.
3:
1.16.14.1! paf 4: Copyright (c) 2000,2001-2005 ArtLebedev Group (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.16.14.1! paf 11: static const char * const IDENT_DIR_H="$Date: 2004/02/11 15:33:13 $";
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:
1.14 paf 72: bool findfirst(const char* _pathname, struct ffblk *_ffblk, int _attrib);
1.1 paf 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: