00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef __DSL_DIRECTORY_H__
00012 #define __DSL_DIRECTORY_H__
00013
00014 #ifdef __GLIBC__
00015 #if __GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 24)
00016 #warning "Old glibc, using readdir_r"
00017 #define __DSL_USE_READDIR_R__ 1
00018 #endif
00019 #endif
00020
00029 class DSL_API_CLASS Directory {
00030 private:
00031 union {
00032 char * mDir;
00033 wchar_t * wDir;
00034 };
00035 #if defined(WIN32)
00036 HANDLE hFind;
00037 union {
00038 WIN32_FIND_DATAA wfdA;
00039 WIN32_FIND_DATAW wfdW;
00040 };
00041 #else
00042 DIR * hFind;
00043 #if defined(__DSL_USE_READDIR_R__)
00044 dirent * last_res;
00045 #endif
00046 #endif
00047
00048 public:
00049 Directory();
00050 Directory(const char * dir);
00051 Directory(const wchar_t * dir);
00052 ~Directory();
00053
00054 bool Open(const char * dir);
00055 bool Open(const wchar_t * dir);
00056
00063 bool Read(char * buf, unsigned long bufSize, bool * is_dir=NULL, int64 * size=NULL);
00070 bool Read(wchar_t * buf, unsigned long bufSize, bool * is_dir = NULL, int64 * size = NULL);
00071
00072 void Close();
00073 };
00074
00077 #endif // __DSL_DIRECTORY_H__