00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef FIFE_VFS_VFS_H
00023 #define FIFE_VFS_VFS_H
00024
00025
00026 #include <set>
00027 #include <string>
00028 #include <vector>
00029
00030
00031 #include <boost/shared_ptr.hpp>
00032
00033
00034
00035
00036
00037 #include "util/base/singleton.h"
00038
00039
00040 namespace FIFE {
00041
00042 class RawData;
00043
00044 class VFSSourceProvider;
00045 class VFSSource;
00046
00058 class VFS : public DynamicSingleton<VFS>{
00059 public:
00063 VFS();
00064
00067 virtual ~VFS();
00068
00069 void cleanup();
00070
00077 void addProvider(VFSSourceProvider* provider);
00078
00085 VFSSource* createSource(const std::string& path) const;
00086
00090 void addNewSource(const std::string& path);
00091
00092
00094 void addSource(VFSSource* source);
00095
00097 void removeSource(VFSSource* source);
00098
00104 bool exists(const std::string& file) const;
00105
00111 bool isDirectory(const std::string& path) const;
00112
00119 RawData* open(const std::string& path);
00120
00126 std::set<std::string> listFiles(const std::string& path) const;
00127
00137 std::set<std::string> listFiles(const std::string& path, const std::string& filterregex) const;
00138
00144 std::set<std::string> listDirectories(const std::string& path) const;
00145
00152 std::set<std::string> listDirectories(const std::string& path, const std::string& filterregex) const;
00153
00154 private:
00155 typedef std::vector<VFSSourceProvider*> type_providers;
00156 type_providers m_providers;
00157
00158 typedef std::vector<VFSSource*> type_sources;
00159 type_sources m_sources;
00160
00161 typedef std::set<std::string> type_usedfiles;
00162 mutable type_usedfiles m_usedfiles;
00163
00164 std::set<std::string> filterList(const std::set<std::string>& list, const std::string& fregex) const;
00165 VFSSource* getSourceForFile(const std::string& file) const;
00166 };
00167
00168 }
00169
00170 #endif