FIFE 2008.0
FIFE::VFS Class Reference

#include <vfs.h>

List of all members.

Public Member Functions

 VFS ()
virtual ~VFS ()
void addProvider (VFSSourceProvider *provider)
VFSSourcecreateSource (const std::string &path) const
void addNewSource (const std::string &path)
void addSource (VFSSource *source)
void removeSource (VFSSource *source)
bool exists (const std::string &file) const
bool isDirectory (const std::string &path) const
RawDataopen (const std::string &path)
std::set< std::string > listFiles (const std::string &path) const
std::set< std::string > listFiles (const std::string &path, const std::string &filterregex) const
std::set< std::string > listDirectories (const std::string &path) const
std::set< std::string > listDirectories (const std::string &path, const std::string &filterregex) const

Detailed Description

the main VFS (virtual file system) class

The VFS is intended to provide transparent and portable access to files.

Note:
The VFS searches for a provider in the order they are added to the VFS. Since the VFSHostSystem is added first, this implies, that host filesystem files will override whatever might be in other VFS Sources (e.g. the DAT files)
All filenames have to be lowercase. The VFS will convert them to lowercase and emit a warning. This is done to avoid problems with filesystems which are not case sensitive.

Definition at line 56 of file vfs.h.


Constructor & Destructor Documentation

FIFE::VFS::VFS ( )

Constructor Called by the Engine on startup. Never create one yourself.

Definition at line 46 of file vfs.cpp.

FIFE::VFS::~VFS ( ) [virtual]

Destructor

Definition at line 48 of file vfs.cpp.


Member Function Documentation

void FIFE::VFS::addNewSource ( const std::string &  path)

create a new Source and add it to VFS

See also:
VFSSource* createSource(const std::string& file) const

Definition at line 100 of file vfs.cpp.

References addSource(), and createSource().

void FIFE::VFS::addProvider ( VFSSourceProvider provider)

add new VFSSourceProvider

VFS assumes ownership over the given provider - so don't do anything with it after you call this function, especialy don't delete it!

Parameters:
providerthe new provider

Definition at line 65 of file vfs.cpp.

References FIFE::VFSSourceProvider::getName(), and FIFE::VFSSourceProvider::setVFS().

void FIFE::VFS::addSource ( VFSSource source)

Add a new VFSSource

Definition at line 109 of file vfs.cpp.

Referenced by addNewSource().

Here is the caller graph for this function:

VFSSource * FIFE::VFS::createSource ( const std::string &  path) const

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

Parameters:
filethe archive-file
Returns:
the new VFSSource or 0 if no provider was succesfull or the file was already used as source

Definition at line 71 of file vfs.cpp.

References FIFE::VFSSourceProvider::createSource(), FIFE::VFSSourceProvider::getName(), FIFE::VFSSourceProvider::isReadable(), and FIFE::Exception::what().

Referenced by addNewSource().

Here is the caller graph for this function:

bool FIFE::VFS::exists ( const std::string &  file) const

Check if the given file exists

Parameters:
filethe filename
Returns:
true if it exists, false if not

Definition at line 130 of file vfs.cpp.

Referenced by FIFE::ZipProvider::isReadable().

Here is the caller graph for this function:

bool FIFE::VFS::isDirectory ( const std::string &  path) const

Check if the given path is a directory

Parameters:
pathto check
Returns:
true if it is a directory, false if not

Definition at line 134 of file vfs.cpp.

References listDirectories().

Referenced by FIFE::DirectoryProvider::isReadable().

Here is the caller graph for this function:

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

Parameters:
paththe directory
filterregexthe regex the files have to match
Returns:
the filelist

Definition at line 193 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

Parameters:
paththe directory
Returns:
the directorylist

Definition at line 182 of file vfs.cpp.

Referenced by isDirectory(), and listDirectories().

Here is the caller graph for this function:

std::set< std::string > FIFE::VFS::listFiles ( const std::string &  path) const

Get a filelist of the given directory

Parameters:
paththe directory
Returns:
the filelist

Definition at line 166 of file vfs.cpp.

Referenced by listFiles().

Here is the caller graph for this function:

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 \)

Parameters:
paththe directory
filterregexthe regex the files have to match
Returns:
the filelist

Definition at line 177 of file vfs.cpp.

References listFiles().

RawData * FIFE::VFS::open ( const std::string &  path)

Open a file

Parameters:
paththe file to open
Returns:
the opened file; delete this when done.
Exceptions:
NotFoundif the file cannot be found

Definition at line 156 of file vfs.cpp.

References FIFE::VFSSource::open().

Referenced by FIFE::RawDataDAT1::RawDataDAT1(), and FIFE::RawDataDAT2::RawDataDAT2().

Here is the caller graph for this function:

void FIFE::VFS::removeSource ( VFSSource source)

remove a VFSSource

Definition at line 113 of file vfs.cpp.


The documentation for this class was generated from the following files:
 All Classes Namespaces Functions Variables Enumerations Enumerator