FIFE
be64c707dea6b3250bd4355bf5c825d25920087d
|
the main VFS (virtual file system) class More...
#include <vfs.h>
Public Member Functions | |
VFS () | |
Constructor Called by the Engine on startup. More... | |
virtual | ~VFS () |
Destructor. More... | |
void | cleanup () |
void | addProvider (VFSSourceProvider *provider) |
add new VFSSourceProvider More... | |
VFSSource * | createSource (const std::string &path) |
tries to create a new VFSSource for the given file More... | |
void | addNewSource (const std::string &path) |
create a new Source and add it to VFS More... | |
void | addSource (VFSSource *source) |
Add a new VFSSource. More... | |
void | removeSource (VFSSource *source) |
remove a VFSSource More... | |
void | removeSource (const std::string &path) |
bool | exists (const std::string &file) const |
Check if the given file exists. More... | |
bool | isDirectory (const std::string &path) const |
Check if the given path is a directory. More... | |
RawData * | open (const std::string &path) |
Open a file. More... | |
std::set< std::string > | listFiles (const std::string &path) const |
Get a filelist of the given directory. More... | |
std::set< std::string > | listFiles (const std::string &path, const std::string &filterregex) const |
List the files of a given directory matching a regex. More... | |
std::set< std::string > | listDirectories (const std::string &path) const |
Get a directorylist of the given directory. More... | |
std::set< std::string > | listDirectories (const std::string &path, const std::string &filterregex) const |
List the subdirectorys of a given directory matching a regex. More... | |
bool | hasSource (const std::string &path) const |
Checks if a source is already present in a provider. More... | |
Public Member Functions inherited from FIFE::DynamicSingleton< VFS > | |
DynamicSingleton () | |
virtual | ~DynamicSingleton () |
Private Types | |
typedef std::vector< VFSSourceProvider * > | type_providers |
typedef std::vector< VFSSource * > | type_sources |
Private Member Functions | |
std::set< std::string > | filterList (const std::set< std::string > &list, const std::string &fregex) const |
VFSSource * | getSourceForFile (const std::string &file) const |
Private Attributes | |
type_providers | m_providers |
type_sources | m_sources |
Additional Inherited Members | |
Static Public Member Functions inherited from FIFE::DynamicSingleton< VFS > | |
static VFS * | instance () |
the main VFS (virtual file system) class
The VFS is intended to provide transparent and portable access to files.
|
private |
|
private |
FIFE::VFS::VFS | ( | ) |
|
virtual |
void FIFE::VFS::addNewSource | ( | const std::string & | path | ) |
create a new Source and add it to VFS
Definition at line 101 of file vfs.cpp.
References FIFE::_log, addSource(), createSource(), and FL_WARN.
void FIFE::VFS::addProvider | ( | VFSSourceProvider * | provider | ) |
add new VFSSourceProvider
provider | the new provider |
Definition at line 66 of file vfs.cpp.
References FIFE::_log, FL_LOG, FIFE::VFSSourceProvider::getName(), m_providers, and FIFE::VFSSourceProvider::setVFS().
Referenced by FIFE::Engine::init().
void FIFE::VFS::addSource | ( | VFSSource * | source | ) |
Add a new VFSSource.
Definition at line 110 of file vfs.cpp.
References m_sources.
Referenced by addNewSource(), and FIFE::Engine::init().
void FIFE::VFS::cleanup | ( | ) |
Definition at line 53 of file vfs.cpp.
References m_providers, and m_sources.
Referenced by ~VFS().
VFSSource * FIFE::VFS::createSource | ( | const std::string & | path | ) |
tries to create a new VFSSource for the given file
all currently known VFSSourceProviders are tried until one succeeds - if no provider succeeds 0 is returned
path | the archive-file |
Definition at line 72 of file vfs.cpp.
References FIFE::_log, FIFE::VFSSourceProvider::createSource(), FL_WARN, FIFE::VFSSourceProvider::getName(), hasSource(), FIFE::VFSSourceProvider::isReadable(), m_providers, and FIFE::Exception::what().
Referenced by addNewSource().
bool FIFE::VFS::exists | ( | const std::string & | file | ) | const |
Check if the given file exists.
file | the filename |
Definition at line 146 of file vfs.cpp.
References getSourceForFile().
Referenced by FIFE::ZipProvider::isReadable().
|
private |
Definition at line 214 of file vfs.cpp.
Referenced by listDirectories(), and listFiles().
|
private |
Definition at line 135 of file vfs.cpp.
References FIFE::_log, FIFE::VFSSource::fileExists(), FL_WARN, and m_sources.
Referenced by exists(), and open().
bool FIFE::VFS::hasSource | ( | const std::string & | path | ) | const |
Checks if a source is already present in a provider.
path | the directory |
Definition at line 228 of file vfs.cpp.
References FIFE::VFSSourceProvider::getSource(), FIFE::VFSSourceProvider::hasSource(), m_providers, and m_sources.
Referenced by createSource().
bool FIFE::VFS::isDirectory | ( | const std::string & | path | ) | const |
Check if the given path is a directory.
path | to check |
Definition at line 150 of file vfs.cpp.
References listDirectories().
std::set< std::string > FIFE::VFS::listDirectories | ( | const std::string & | path | ) | const |
Get a directorylist of the given directory.
path | the directory |
Definition at line 198 of file vfs.cpp.
References m_sources.
Referenced by isDirectory(), listDirectories(), FIFE::ObjectLoader::loadImportDirectory(), and FIFE::MapLoader::loadImportDirectory().
std::set< std::string > FIFE::VFS::listDirectories | ( | const std::string & | path, |
const std::string & | filterregex | ||
) | const |
List the subdirectorys of a given directory matching a regex.
path | the directory |
filterregex | the regex the files have to match |
Definition at line 209 of file vfs.cpp.
References filterList(), and listDirectories().
std::set< std::string > FIFE::VFS::listFiles | ( | const std::string & | path | ) | const |
Get a filelist of the given directory.
path | the directory |
Definition at line 182 of file vfs.cpp.
References m_sources.
Referenced by listFiles(), FIFE::ObjectLoader::loadImportDirectory(), and FIFE::MapLoader::loadImportDirectory().
std::set< std::string > FIFE::VFS::listFiles | ( | const std::string & | path, |
const std::string & | filterregex | ||
) | const |
List the files of a given directory matching a regex.
The whole string has to match the regex, this means if you want all files that end with .map don't search for "\.map" but ".*\.map" (and escape the )
path | the directory |
filterregex | the regex the files have to match |
Definition at line 193 of file vfs.cpp.
References filterList(), and listFiles().
RawData * FIFE::VFS::open | ( | const std::string & | path | ) |
Open a file.
path | the file to open |
NotFound | if the file cannot be found |
Definition at line 172 of file vfs.cpp.
References FIFE::_log, FL_DBG, getSourceForFile(), and FIFE::VFSSource::open().
Referenced by FIFE::AnimationLoader::isLoadable(), FIFE::ObjectLoader::isLoadable(), FIFE::MapLoader::isLoadable(), FIFE::AtlasLoader::isLoadable(), FIFE::ImageLoader::load(), FIFE::OggLoader::load(), FIFE::ControllerMappingLoader::load(), FIFE::AnimationLoader::load(), FIFE::ObjectLoader::load(), FIFE::MapLoader::load(), FIFE::AtlasLoader::load(), FIFE::AnimationLoader::loadMultiple(), FIFE::AtlasLoader::loadMultiple(), FIFE::RawDataDAT1::RawDataDAT1(), and FIFE::RawDataDAT2::RawDataDAT2().
void FIFE::VFS::removeSource | ( | VFSSource * | source | ) |
remove a VFSSource
Definition at line 114 of file vfs.cpp.
References m_sources.
Referenced by removeSource(), and FIFE::VFSSource::~VFSSource().
void FIFE::VFS::removeSource | ( | const std::string & | path | ) |
Definition at line 120 of file vfs.cpp.
References FIFE::VFSSourceProvider::getSource(), FIFE::VFSSourceProvider::hasSource(), m_providers, m_sources, and removeSource().
|
private |
Definition at line 164 of file vfs.h.
Referenced by addProvider(), cleanup(), createSource(), hasSource(), and removeSource().
|
private |
Definition at line 167 of file vfs.h.
Referenced by addSource(), cleanup(), getSourceForFile(), hasSource(), listDirectories(), listFiles(), and removeSource().