Annotation of parser3/src/include/pa_dir.h, revision 1.27
1.1 paf 1: /** @file
2: Parser: directory scanning for different OS-es decls.
3:
1.27 ! moko 4: Copyright (c) 2000-2015 Art. Lebedev Studio (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.27 ! moko 11: #define IDENT_PA_DIR_H "$Id: pa_dir.h,v 1.26 2015/06/29 17:59:13 moko Exp $"
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.25 moko 20: #ifdef _MSC_VER
1.1 paf 21:
1.24 moko 22: #include <windows.h>
23:
1.1 paf 24: #define MAXPATH MAX_PATH
25:
26: struct ffblk {
1.23 moko 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 ];
1.1 paf 37: /*helper*/
38: HANDLE handle;
39:
1.26 moko 40: bool is_dir(bool);
1.22 moko 41: double size();
42: time_t c_timestamp();
43: time_t m_timestamp();
44: time_t a_timestamp();
1.1 paf 45: };
46:
47: #else
48:
49: #define MAXPATH 1000 /*NAME_MAX*/
50:
51: struct ffblk {
52: /*as if in windows :)*/
53: char ff_name[ MAXPATH ];
54: /*helpers*/
55: DIR *dir;
1.23 moko 56: const char *filePath;
1.22 moko 57: struct stat _st;
58:
59: #ifdef HAVE_STRUCT_DIRENT_D_TYPE
60: unsigned char _d_type;
1.26 moko 61: #endif
62: bool is_dir(bool);
1.22 moko 63: void stat_file();
64: double size();
65: time_t c_timestamp();
66: time_t m_timestamp();
67: time_t a_timestamp();
1.1 paf 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.18 paf 76: /// main dir workhorse: calles win32/unix unified functions findfirst/next/close [skip . and ..]
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 \
1.18 paf 81: if(*ffblk.ff_name && !(ffblk.ff_name[0]=='.' && (ffblk.ff_name[1]==0 || ffblk.ff_name[1]=='.' && ffblk.ff_name[2]==0) )) {\
1.6 paf 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: