Annotation of parser3/src/include/pa_dir.h, revision 1.5
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: Author: Alexander Petrosyan <paf@design.ru> (http://design.ru/paf)
6:
1.5 ! parser 7: $Id: pa_dir.h,v 1.4 2001/08/31 15:35:34 parser 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; \
79: bool done=findfirst(dir, &ffblk, 0); \
80: while(!done) { \
81: if(*ffblk.ff_name && ffblk.ff_name[0]!='.') {\
82: action; \
83: } \
84: done=findnext(&ffblk); \
85: } \
86: findclose(&ffblk); \
87: }
88:
89: #endif
E-mail: