|
|
| version 1.24, 2013/07/21 21:01:03 | version 1.34, 2026/04/25 13:38:46 |
|---|---|
| Line 1 | Line 1 |
| /** @file | /** @file |
| Parser: directory scanning for different OS-es decls. | Parser: directory scanning for different OS-es decls. |
| Copyright (c) 2000-2012 Art. Lebedev Studio (http://www.artlebedev.com) | Copyright (c) 2000-2026 Art. Lebedev Studio (https://www.artlebedev.com) |
| Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru) | Authors: Konstantin Morshnev <moko@design.ru>, Alexandr Petrosian <paf@design.ru> |
| */ | */ |
| #ifndef PA_DIR_H | #ifndef PA_DIR_H |
| Line 17 | Line 17 |
| for findfirst/next/close interface | for findfirst/next/close interface |
| */ | */ |
| #ifdef WIN32 | #ifdef _MSC_VER |
| #include <windows.h> | #include <windows.h> |
| #define MAXPATH MAX_PATH | #define MAXPATH ((MAX_PATH)*2) /*UTF-16*/ |
| struct ffblk { | struct ffblk { |
| DWORD ff_attrib;/*dwFileAttributes;*/ | struct _WIN32_FIND_DATAW stat; |
| FILETIME ftCreationTime; | |
| FILETIME ftLastAccessTime; | |
| FILETIME ftLastWriteTime; | |
| DWORD nFileSizeHigh; | |
| DWORD nFileSizeLow; | |
| DWORD dwReserved0; | |
| DWORD dwReserved1; | |
| CHAR ff_name[ MAX_PATH ];/*cFileName[ MAX_PATH ];*/ | |
| CHAR cAlternateFileName[ 14 ]; | |
| /*helper*/ | |
| HANDLE handle; | HANDLE handle; |
| void stat_file(){} | const char *name(); |
| bool is_dir(); | bool is_dir(bool); |
| double size(); | double size(); |
| time_t c_timestamp(); | time_t c_timestamp(); |
| time_t m_timestamp(); | time_t m_timestamp(); |
| Line 51 struct ffblk { | Line 41 struct ffblk { |
| struct ffblk { | struct ffblk { |
| /*as if in windows :)*/ | /*as if in windows :)*/ |
| char ff_name[ MAXPATH ]; | char ff_name[ MAXPATH ]; |
| /*helpers*/ | /*helpers*/ |
| DIR *dir; | DIR *dir; |
| const char *filePath; | const char *filePath; |
| Line 59 struct ffblk { | Line 49 struct ffblk { |
| #ifdef HAVE_STRUCT_DIRENT_D_TYPE | #ifdef HAVE_STRUCT_DIRENT_D_TYPE |
| unsigned char _d_type; | unsigned char _d_type; |
| void stat_file(); | |
| #else | |
| void stat_file(){} | |
| void real_stat_file(); | |
| #endif | #endif |
| bool is_dir(); | |
| const char *name(){ return ff_name; } | |
| bool is_dir(bool); | |
| void stat_file(); | |
| double size(); | double size(); |
| time_t c_timestamp(); | time_t c_timestamp(); |
| time_t m_timestamp(); | time_t m_timestamp(); |
| Line 78 bool findnext(struct ffblk *_ffblk); | Line 67 bool findnext(struct ffblk *_ffblk); |
| void findclose(struct ffblk *_ffblk); | void findclose(struct ffblk *_ffblk); |
| /// main dir workhorse: calles win32/unix unified functions findfirst/next/close [skip . and ..] | /// main dir workhorse: calles win32/unix unified functions findfirst/next/close [skip . and ..] |
| #define LOAD_DIR(dir,action) {\ | #define LOAD_DIR(dir,action) { \ |
| ffblk ffblk; \ | ffblk ffblk; \ |
| if(!findfirst(dir, &ffblk, 0)) { \ | if(!findfirst(dir, &ffblk, 0)) { \ |
| do \ | do { \ |
| if(*ffblk.ff_name && !(ffblk.ff_name[0]=='.' && (ffblk.ff_name[1]==0 || ffblk.ff_name[1]=='.' && ffblk.ff_name[2]==0) )) {\ | const char *file_name=ffblk.name(); \ |
| if(*file_name && !(file_name[0]=='.' && (file_name[1]==0 || file_name[1]=='.' && file_name[2]==0) )) { \ | |
| action; \ | action; \ |
| } \ | } \ |
| while(!findnext(&ffblk)); \ | } while(!findnext(&ffblk)); \ |
| findclose(&ffblk); \ | findclose(&ffblk); \ |
| } \ | } \ |
| } | } |
| #endif | #endif |