#include <fileserver.h>
Inheritance diagram for zeitgeist::FileServer:
Public Types | |
typedef int | THandle |
Public Member Functions | |
FileServer () | |
constructs the fileserver | |
~FileServer () | |
boost::shared_ptr< salt::RFile > | Open (const std::string &inName) |
searchs each registered file system for a file with this name. | |
THandle | Register (const std::string &inName) |
tries to open the requested file and registers it. | |
boost::shared_ptr< salt::RFile > | Get (THandle handle) const |
returns the file corresponding to the given handle. | |
void | Close (THandle handle) |
closes the file corresponding to the given handle | |
bool | Exist (const std::string &inName) |
returns true if the file 'inName' exists. | |
bool | Mount (const std::string &inFileSysName, const std::string &inPath) |
registers a filesystem to the fileserver. | |
bool | Unmount (const std::string &inPath) |
unmounts a file system at the mount point inPath. | |
bool | Unmount (const std::string &inClass, const std::string &inPath) |
unmounts a file system at the mount point inPath. | |
int | ForEachFile (const std::string &directory, const std::string &name, const std::string &extension, FileSystem::TCallback callback, void *param) |
iterates through files. | |
Protected Types | |
typedef std::map< THandle, boost::shared_ptr< salt::RFile > > | TFileMap |
Protected Member Functions | |
virtual void | OnUnlink () |
This rountine is called, before the FileServer hierarchy object is removed from the parent. | |
Protected Attributes | |
TFileMap | mFileMap |
registry of opened files using the handle base system | |
THandle | mNextHandle |
the next free handle | |
Private Member Functions | |
FileServer (const FileServer &) | |
FileServer & | operator= (const FileServer &) |
What the FileServer does:
The file server is an extremely useful subsystem, since it allows to access various implemented file systems. The regular file system is a standard directory-based implementation. The ZIP file system can load files from within ZIP-files. Before actually being able to open files, the FileServer is initialized with several FileSystems, which are associated with different paths. For each path, you have to pass in a file system. Now, when trying to open a file, each registered file system is asked to open the file. Filesystems are searched in the inverse order in wich they were registered- think of a filesystem stack. The first succesful opened file wins. This allows for some nice effects. File systems are associated with id strings like 'STD' or 'ZIP'.
Definition at line 81 of file fileserver.h.
|
Definition at line 90 of file fileserver.h. |
|
Definition at line 87 of file fileserver.h. |
|
constructs the fileserver
Definition at line 32 of file fileserver.cpp. |
|
Definition at line 36 of file fileserver.cpp. |
|
|
|
closes the file corresponding to the given handle
Definition at line 96 of file fileserver.cpp. References zeitgeist::Object::GetLog(), mFileMap, and mNextHandle. Here is the call graph for this function: ![]() |
|
returns true if the file 'inName' exists.
|
|
iterates through files. 'directory', 'name' and 'extension' give directory, name and extension a file must match. directory,name and extension may be NULL, in wich case every directory,extension and/or name matches. For each match the function callback is called with the name of the matched file and the additional user parameter 'param'. param is just passed through to the callback and has no meaning to the filesystem. |
|
returns the file corresponding to the given handle.
Definition at line 81 of file fileserver.cpp. References zeitgeist::Object::GetLog(), and mFileMap. Here is the call graph for this function: ![]() |
|
registers a filesystem to the fileserver. A file system may be registered only once, on each further try nothing is done and false returned
|
|
This rountine is called, before the FileServer hierarchy object is removed from the parent.
Reimplemented from zeitgeist::Leaf. Definition at line 117 of file fileserver.cpp. References zeitgeist::Object::GetLog(), and mFileMap. Here is the call graph for this function: ![]() |
|
searchs each registered file system for a file with this name. Filesystems are searched in the inverse order in which they are registered to the fileserve, i.e. a filesystem stack. The first succesful opened file is returned. |
|
|
|
tries to open the requested file and registers it. On success it returns a non 0 handle assiociated with the file object. |
|
unmounts a file system at the mount point inPath. Returns true on success. |
|
unmounts a file system at the mount point inPath. if no file system id is given, for a first try FileSystemSTD is assumed, then the type is ignored. Returns true on success. |
|
registry of opened files using the handle base system
Definition at line 167 of file fileserver.h. Referenced by Close(), Get(), and OnUnlink(). |
|
the next free handle
Definition at line 170 of file fileserver.h. Referenced by Close(). |