Annotation of parser3/src/include/pa_dir.h, revision 1.31
1.1 paf 1: /** @file
2: Parser: directory scanning for different OS-es decls.
3:
1.31 ! moko 4: Copyright (c) 2000-2023 Art. Lebedev Studio (http://www.artlebedev.com)
! 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.31 ! moko 11: #define IDENT_PA_DIR_H "$Id: pa_dir.h,v 1.30 2020/12/15 17:10:31 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.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.22 moko 32: double size();
33: time_t c_timestamp();
34: time_t m_timestamp();
35: time_t a_timestamp();
1.1 paf 36: };
37:
38: #else
39:
40: #define MAXPATH 1000 /*NAME_MAX*/
41:
42: struct ffblk {
43: /*as if in windows :)*/
1.28 moko 44: char ff_name[ MAXPATH ];
1.1 paf 45: /*helpers*/
46: DIR *dir;
1.23 moko 47: const char *filePath;
1.22 moko 48: struct stat _st;
49:
50: #ifdef HAVE_STRUCT_DIRENT_D_TYPE
51: unsigned char _d_type;
1.26 moko 52: #endif
1.28 moko 53:
54: const char *name(){ return ff_name; }
1.26 moko 55: bool is_dir(bool);
1.22 moko 56: void stat_file();
57: double size();
58: time_t c_timestamp();
59: time_t m_timestamp();
60: time_t a_timestamp();
1.1 paf 61: };
62:
63: #endif
64:
1.14 paf 65: bool findfirst(const char* _pathname, struct ffblk *_ffblk, int _attrib);
1.1 paf 66: bool findnext(struct ffblk *_ffblk);
67: void findclose(struct ffblk *_ffblk);
68:
1.18 paf 69: /// main dir workhorse: calles win32/unix unified functions findfirst/next/close [skip . and ..]
1.28 moko 70: #define LOAD_DIR(dir,action) { \
71: ffblk ffblk; \
72: if(!findfirst(dir, &ffblk, 0)) { \
73: do { \
74: const char *file_name=ffblk.name(); \
75: if(*file_name && !(file_name[0]=='.' && (file_name[1]==0 || file_name[1]=='.' && file_name[2]==0) )) { \
1.6 paf 76: action; \
77: } \
1.28 moko 78: } while(!findnext(&ffblk)); \
1.6 paf 79: findclose(&ffblk); \
80: } \
1.28 moko 81: }
1.1 paf 82:
83: #endif
E-mail: