27 #include <boost/functional.hpp> 28 #include <boost/algorithm/string.hpp> 55 type_sources::const_iterator end = sources.end();
56 for (type_sources::iterator i = sources.begin(); i != end; ++i)
59 type_providers::const_iterator end2 =
m_providers.end();
60 for (type_providers::iterator j =
m_providers.begin(); j != end2; ++j)
79 type_providers::const_iterator end =
m_providers.end();
80 for (type_providers::const_iterator i =
m_providers.begin(); i != end; ++i) {
92 FL_WARN(
_log,
LMsg(provider->
getName()) <<
" thought it could load " << path <<
" but didn't succeed (unknown exception)");
122 for (type_providers::iterator i =
m_providers.begin(); i != end; ++i) {
151 std::vector<std::string> tokens;
153 const std::string newpath = path +
"/";
154 boost::algorithm::split(tokens, newpath, boost::algorithm::is_any_of(
"/"));
156 std::string currentpath =
"/";
157 std::vector<std::string>::const_iterator token=tokens.begin();
158 while (token != tokens.end()) {
160 if (*token !=
"." && *token !=
".." &&
listDirectories(currentpath, *token).size() == 0) {
163 currentpath += *token +
"/";
177 throw NotFound(path);
179 return source->
open(path);
183 std::set<std::string> list;
184 type_sources::const_iterator end =
m_sources.end();
185 for (type_sources::const_iterator i =
m_sources.begin(); i != end; ++i) {
186 std::set<std::string> sourcelist = (*i)->listFiles(pathstr);
187 list.insert(sourcelist.begin(), sourcelist.end());
193 std::set<std::string>
VFS::listFiles(
const std::string& path,
const std::string& filterregex)
const {
194 std::set<std::string> list =
listFiles(path);
199 std::set<std::string> list;
200 type_sources::const_iterator end =
m_sources.end();
201 for (type_sources::const_iterator i =
m_sources.begin(); i != end; ++i) {
202 std::set<std::string> sourcelist = (*i)->listDirectories(pathstr);
203 list.insert(sourcelist.begin(), sourcelist.end());
214 std::set<std::string>
VFS::filterList(
const std::set<std::string>& list,
const std::string& fregex)
const {
215 std::set<std::string> results;
216 std::regex regex(fregex);
217 std::set<std::string>::const_iterator end = list.end();
218 for (std::set<std::string>::const_iterator i = list.begin(); i != end;) {
220 if (std::regex_match((*i).c_str(), match, regex)) {
229 type_providers::const_iterator end =
m_providers.end();
230 for (type_providers::const_iterator i =
m_providers.begin(); i != end; ++i) {
234 type_sources::const_iterator i = std::find(
m_sources.begin(),
m_sources.end(), source);
#define FL_WARN(logger, msg)
void addProvider(VFSSourceProvider *provider)
add new VFSSourceProvider
virtual bool fileExists(const std::string &file) const =0
check if the given file exists
bool exists(const std::string &file) const
Check if the given file exists.
Helper class to create log strings out from separate parts Usage: LMsg("some text") << variable << "...
const std::string & getName() const
Returns the name of this VFSSourceProvider.
VFSSource abstract baseclass.
RawData * open(const std::string &path)
Open a file.
static Logger _log(LM_AUDIO)
VFSSource * getSourceForFile(const std::string &file) const
virtual bool isReadable(const std::string &file) const =0
Check if a given file is readable for this VFSSource.
virtual VFSSource * getSource(const std::string &path) const =0
Get the source instance of the path.
std::set< std::string > listFiles(const std::string &path) const
Get a filelist of the given directory.
void removeSource(VFSSource *source)
remove a VFSSource
VFSSourceProvider abstract baseclass.
void addSource(VFSSource *source)
Add a new VFSSource.
virtual ~VFS()
Destructor.
virtual const char * what() const
Returns the error message.
VFS()
Constructor Called by the Engine on startup.
#define FL_LOG(logger, msg)
std::set< std::string > listDirectories(const std::string &path) const
Get a directorylist of the given directory.
void addNewSource(const std::string &path)
create a new Source and add it to VFS
VFSSource * createSource(const std::string &path)
tries to create a new VFSSource for the given file
virtual bool hasSource(const std::string &path) const =0
Check whether the provider already has created a source with that path.
void setVFS(VFS *vfs)
Get the VFS this provider is using.
bool hasSource(const std::string &path) const
Checks if a source is already present in a provider.
#define FL_DBG(logger, msg)
bool isDirectory(const std::string &path) const
Check if the given path is a directory.
type_providers m_providers
virtual VFSSource * createSource(const std::string &file)=0
Create a new instance of a VFSSource initialized with the given file.
virtual RawData * open(const std::string &file) const =0
open a file inside this source
std::set< std::string > filterList(const std::set< std::string > &list, const std::string &fregex) const
Used to access diffrent kinds of data.
std::vector< VFSSource * > type_sources