00001
00040 #ifndef __DIR_WALKER_H__
00041 #define __DIR_WALKER_H__
00042
00043 #ifdef WIN32
00044
00045 #include <windows.h>
00046
00047 #else
00048
00049 #include <sys/types.h>
00050 #include <dirent.h>
00051
00052 #define INVALID_HANDLE_VALUE 0
00053 #define MAX_PATH 500
00054 typedef DIR* HANDLE;
00055
00056 #endif //WIN32
00057
00058 class DirWalker
00059 {
00060 HANDLE hFile;
00061 char szDirPath[MAX_PATH];
00062 size_t nDirPathLen;
00063
00064 #ifdef WIN32
00065 WIN32_FIND_DATA findData;
00066 #endif
00067
00068 public:
00069 DirWalker();
00070 ~DirWalker() { CloseDir(); }
00071
00072 const char* GetDirPath() { return szDirPath; }
00073 int GetDirPathLen() { return nDirPathLen; }
00074
00075 bool OpenDir(const char* szDirName);
00076 void CloseDir();
00077 bool GetNextFileOrDir(char* szFileName, size_t buffSize);
00078 bool GetNextFile(char* szFileName, size_t buffSize, char* szFileExt = NULL);
00079 bool GetNextDir(char* szFileName, size_t buffSize);
00080
00081 static bool IsDirectory(const char* szFileName);
00082 static const char* FindFileExtention(const char* szFileName);
00083 static bool CompFileExt(const char* szFileName, const char* szFileExt);
00084 static void ChangeFileExt(const char* szFileName, const char* szExt, char* szNewName);
00085 static int CreateFileName(const char* szDirName, const char* szPrefix,
00086 const char* szFileExt, char szFileName[]);
00087 static int CompareLastModifDate(const char* szFileName1, const char* szFileName2);
00088 };
00089
00090 #endif //__DIR_WALKER_H__