Annotation of parser3/src/include/pa_dir.h, revision 1.3
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.3 ! paf 8: $Id: pa_dir.h,v 1.2 2001/04/09 08:55:28 paf Exp $
1.1 paf 9: */
10:
11: #ifndef PA_DIR_H
12: #define PA_DIR_H
13:
1.3 ! paf 14: /** @struct ffblk
! 15: win32/unix unified directory entry structure name
! 16: for findfirst/next/close interface
! 17: */
! 18:
1.1 paf 19: #ifdef WIN32
20:
21: #include <windows.h>
22:
23: #define MAXPATH MAX_PATH
24: #define FA_DIREC FILE_ATTRIBUTE_DIRECTORY
25:
26: struct ffblk {
27: DWORD ff_attrib;/*dwFileAttributes;*/
28: FILETIME ftCreationTime;
29: FILETIME ftLastAccessTime;
30: FILETIME ftLastWriteTime;
31: DWORD nFileSizeHigh;
32: DWORD nFileSizeLow;
33: DWORD dwReserved0;
34: DWORD dwReserved1;
35: CHAR ff_name[ MAX_PATH ];/*cFileName[ MAX_PATH ];*/
36: CHAR cAlternateFileName[ 14 ];
37: /*helper*/
38: HANDLE handle;
39:
40: /*
41:
42: unsigned char ff_attrib __attribute__((packed));
43: unsigned short ff_ftime __attribute__((packed));
44: unsigned short ff_fdate __attribute__((packed));
45: unsigned long ff_fsize __attribute__((packed));
46: char ff_name[260] __attribute__((packed));
47: */
48: };
49:
50: #else
51:
52: #include <strings.h>
53: #include <sys/types.h>
54: #include <dirent.h>
55: #include <sys/stat.h>
56:
57: #define MAXPATH 1000 /*NAME_MAX*/
58: #define FA_DIREC S_IFDIR
59:
60: struct ffblk {
61: /*as if in windows :)*/
62: unsigned char ff_attrib;
63: char ff_name[ MAXPATH ];
64: /*helpers*/
65: DIR *dir;
66: char filePath[MAXPATH];
67: };
68:
69: #endif
70:
71: bool findfirst(const char *_pathname, struct ffblk *_ffblk, int _attrib);
72: bool findnext(struct ffblk *_ffblk);
73: void findclose(struct ffblk *_ffblk);
74:
1.3 ! paf 75: /// main dir workhorse: calles win32/unix unified functions findfirst/next/close
1.1 paf 76: #define LOAD_DIR(dir,action) {\
77: ffblk ffblk; \
78: bool done=findfirst(dir, &ffblk, 0); \
79: while(!done) { \
80: if(*ffblk.ff_name && ffblk.ff_name[0]!='.') {\
81: action; \
82: } \
83: done=findnext(&ffblk); \
84: } \
85: findclose(&ffblk); \
86: }
87:
88: #endif
E-mail: