Annotation of parser3/src/include/pa_dir.h, revision 1.38
1.1 paf 1: /** @file
2: Parser: directory scanning for different OS-es decls.
3:
1.34 moko 4: Copyright (c) 2000-2026 Art. Lebedev Studio (https://www.artlebedev.com)
1.31 moko 5: Authors: Konstantin Morshnev <moko@design.ru>, Alexandr Petrosian <paf@design.ru>
1.1 paf 6: */
7:
8: #ifndef PA_DIR_H
9: #define PA_DIR_H
1.11 paf 10:
1.38 ! moko 11: #define IDENT_PA_DIR_H "$Id: pa_dir.h,v 1.37 2026/10/02 19:58:41 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.32 moko 24: #define MAXPATH ((MAX_PATH)*2) /*UTF-16*/
1.1 paf 25:
26: struct ffblk {
1.28 moko 27: struct _WIN32_FIND_DATAW stat;
1.1 paf 28: HANDLE handle;
29:
1.28 moko 30: const char *name();
1.26 moko 31: bool is_dir(bool);
1.38 ! moko 32: bool is_symlink();
1.22 moko 33: double size();
34: time_t c_timestamp();
35: time_t m_timestamp();
36: time_t a_timestamp();
1.1 paf 37: };
38:
1.36 moko 39: #else // _MSC_VER
1.1 paf 40:
41: #define MAXPATH 1000 /*NAME_MAX*/
42:
43: struct ffblk {
44: /*as if in windows :)*/
1.28 moko 45: char ff_name[ MAXPATH ];
1.1 paf 46: /*helpers*/
47: DIR *dir;
1.23 moko 48: const char *filePath;
1.22 moko 49: struct stat _st;
50:
51: #ifdef HAVE_STRUCT_DIRENT_D_TYPE
52: unsigned char _d_type;
1.26 moko 53: #endif
1.28 moko 54:
55: const char *name(){ return ff_name; }
1.26 moko 56: bool is_dir(bool);
1.38 ! moko 57: bool is_symlink();
1.22 moko 58: void stat_file();
59: double size();
60: time_t c_timestamp();
61: time_t m_timestamp();
62: time_t a_timestamp();
1.1 paf 63: };
64:
1.36 moko 65: #endif // _MSC_VER
1.1 paf 66:
1.14 paf 67: bool findfirst(const char* _pathname, struct ffblk *_ffblk, int _attrib);
1.1 paf 68: bool findnext(struct ffblk *_ffblk);
69: void findclose(struct ffblk *_ffblk);
70:
1.37 moko 71: /// main dir workhorse: calls win32/unix unified functions findfirst/next/close [skip . and ..]
72: #define LOAD_DIR(dir,action,failure) { \
1.28 moko 73: ffblk ffblk; \
74: if(!findfirst(dir, &ffblk, 0)) { \
75: do { \
76: const char *file_name=ffblk.name(); \
77: if(*file_name && !(file_name[0]=='.' && (file_name[1]==0 || file_name[1]=='.' && file_name[2]==0) )) { \
1.6 paf 78: action; \
79: } \
1.28 moko 80: } while(!findnext(&ffblk)); \
1.6 paf 81: findclose(&ffblk); \
1.37 moko 82: } else { \
83: failure; \
1.6 paf 84: } \
1.28 moko 85: }
1.1 paf 86:
1.35 moko 87:
1.1 paf 88: #endif
E-mail: