00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef _SWORD_BASE_FILESYSTEM_
00020 #define _SWORD_BASE_FILESYSTEM_
00021
00022 #include "sword/streams.File.h"
00023 #include <vector>
00024
00025 namespace sword {
00026
00027 class SWORDDECL FileSystem {
00028 public:
00029 FileSystem(const std::string& path);
00030 FileSystem(const File& file);
00031 FileSystem();
00032
00033 void chdir(const std::string& path);
00034 void chdir(const File& file);
00035
00036 void mkdir(const std::string& path) const;
00037 void mkdir(const File& path) const;
00038 static void remove(const std::string& path);
00039 static void remove(const File& path);
00040 static void removeFile(const std::string& path);
00041 static void removeFile(const File& path);
00042 static void removeDirectory(const std::string& path);
00043 static void removeDirectory(const File& path);
00044
00045
00046
00047 enum Mode
00048 {
00049
00050 open = 1,
00051 openOrCreate = 2,
00052
00053
00054 create = 3,
00055 createAlways = 4,
00056 append = 5,
00057 appendOrCreate = 6,
00058
00059
00060 inherit = 0x0100,
00061 random = 0x0200,
00062 sequential = 0x0400
00063 };
00064
00065
00066 class RemoveException : public Exception {};
00067 class MkdirException : public Exception {};
00068
00069 class const_iterator
00070 {
00071 public :
00072 const_iterator(const FileSystem *fileSystem, int index = 0);
00073 const_iterator(const const_iterator &it);
00074
00075 ~const_iterator();
00076
00077 const File &operator *() const;
00078 const File *operator ->() const;
00079 bool operator ==(const const_iterator &it) const;
00080 bool operator !=(const const_iterator &it) const;
00081 const_iterator &operator ++();
00082 const_iterator &operator --();
00083
00084 private :
00085 const FileSystem *fileSystem_;
00086 int index_;
00087 };
00088 friend class const_iterator;
00089
00090 const_iterator begin() const;
00091 const_iterator end() const;
00092
00093 private:
00094 File current_;
00095 mutable word nbLiveIterator_;
00096 mutable std::vector<File> cache_;
00097
00098 static void mkdir_ (const std::string &path);
00099 void cacheFiles_() const;
00100 };
00101
00102 }
00103
00104 #include "sword.private/base.FileSystem.inl"
00105
00106 #endif // _SWORD_BASE_FILESYSTEM_
00107