00001
00002
00003 #ifndef BASE_DIR_H
00004 #define BASE_DIR_H
00005
00006 #ifdef _WIN32
00007 #define WIN32_LEAN_AND_MEAN
00008 #include <windows.h>
00009 #else
00010 #include <dirent.h>
00011 #endif
00012 #include "String.h"
00013 #include "IOException.h"
00014 #include "Stat.h"
00015
00016 namespace base {
00018
00022 class PPBASE_EXPORT Dir {
00023 public:
00025 Dir();
00026
00028 ~Dir();
00029
00031 void close();
00032
00034
00040 static void copy(const String &srcpath, const String &dstpath, bool move = false);
00041
00043
00048 static bool exists(const String &path);
00049
00051
00055 static String getCWD();
00056
00058
00064 static bool isDirectory(const String &path);
00065
00067
00072 Stat lstat(const String &name);
00073
00075
00083 static void mkdir(const String &path, bool parent = false, unsigned mode = 0777,
00084 unsigned uid = (unsigned)-1, unsigned gid = (unsigned)-1);
00085
00087
00091 void open(const String &path);
00092
00094
00100 bool read(String &rstr, bool special = true);
00101
00103
00109 static void rmdir(const String &path, bool force = false, bool recursive = false);
00110
00112
00117 Stat stat(const String &name);
00118
00119 private:
00120 #ifdef _WIN32
00121 HANDLE _dir;
00122 WIN32_FIND_DATAW _file;
00123 bool _fileok;
00124 #else
00125 DIR *_dir;
00126 #endif
00127 String _path;
00128
00129 DISALLOW_COPY_CONSTRUCTOR_AND_ASSIGNMENT(Dir);
00130 };
00131 }
00132
00133 #endif