Encapsulates embedded directories, i.e. More...
#include <OSDLEmbeddedDirectory.h>
Public Member Functions | |
virtual | ~EmbeddedDirectory () throw () |
Destroys the directory reference, not the directory itself. | |
virtual bool | hasDirectory (const std::string &subdirectoryName) const |
q Tells whether this directory with a direct subdirectory named subdirectoryName can be found in the search path. | |
virtual bool | hasFile (const std::string &fileName) const |
Tells whether this directory with a direct file or symbolic link named fileName can be found in the search path. | |
virtual bool | hasEntry (const std::string &entryName) const |
Tells whether the directory has a direct entry named entryName, whatever the entry is (file, directory, named FIFO, socket, etc. | |
virtual void | getSubdirectories (std::list< std::string > &subDirectories) const |
Returns the names of all direct subdirectories of this directory, in the specified list. | |
virtual void | getFiles (std::list< std::string > &files) const |
Returns the names of all regular files and symbolic links of this directory, in the specified list. | |
virtual void | getEntries (std::list< std::string > &entries) const |
Returns the names of all files in specified search path, stored in the specified list. | |
virtual void | getSortedEntries (std::list< std::string > &subDirectories, std::list< std::string > &files, std::list< std::string > &otherEntries) const |
Returns the names of all direct entries of any type of this directory (including files and directories), in the corresponding specified list. | |
virtual const std::string | toString (Ceylan::VerbosityLevels level=Ceylan::high) const |
Returns a user-friendly description of the state of this object. | |
EmbeddedDirectory (const std::string &directoryName, bool create=true) | |
Creates an EmbeddedDirectory reference on a directory either already existing, or to be created on disk thanks to the operating system facilities. | |
Static Public Member Functions | |
static EmbeddedDirectory & | Create (const std::string &newDirectoryName) |
Returns an EmbeddedDirectory reference on a directory newly created on disk, thanks to the operating system facilities. | |
static EmbeddedDirectory & | Open (const std::string &directoryName="") |
Returns an EmbeddedDirectory reference on specified already-existing directory, which will be "opened" (i.e. | |
Protected Member Functions | |
virtual Ceylan::System::FileSystemManager & | getCorrespondingFileSystemManager () const |
Returns the embedded filesystem manager. | |
Static Protected Attributes | |
static const std::string | RootDirectoryPrefix |
static const std::string | CurrentDirectoryAlias |
static const std::string | UpperDirectoryAlias |
static const char | Separator |
Private Member Functions | |
EmbeddedDirectory (const EmbeddedDirectory &source) | |
Copy constructor made private to ensure that it will be never called. | |
EmbeddedDirectory & | operator= (const EmbeddedDirectory &source) |
Assignment operator made private to ensure that it will be never called. |
Encapsulates embedded directories, i.e.
directories in a virtual filesystem stored in an actual standard file, as provided by the PhysicsFS back-end.
Actual directories should be created and opened with respectively the Directory::Create and Directory::Open factories, that allow the user program to be cross-platform by hiding each filesystem-related per-platform specificity.
Definition at line 69 of file OSDLEmbeddedDirectory.h.
EmbeddedDirectory::~EmbeddedDirectory | ( | ) | throw () [virtual] |
Destroys the directory reference, not the directory itself.
The destructor must be public as instances created by factories have to be deallocated by the user.
Definition at line 79 of file OSDLEmbeddedDirectory.cc.
EmbeddedDirectory::EmbeddedDirectory | ( | const std::string & | directoryName, | |
bool | create = true | |||
) | [explicit] |
Creates an EmbeddedDirectory reference on a directory either already existing, or to be created on disk thanks to the operating system facilities.
directoryName | the name of the directory to create, specified in platform-independent notation in relation to the write directory. All missing parent directories are also created if they do not exist. |
So if the write directory is set to "C:\mygame\writedir" and directoryName is "downloads/maps", then the directories "C:\mygame\writedir\downloads" and "C:\mygame\writedir\downloads\maps" will be created if possible. If the creation of "maps" fails after we have successfully created "downloads", then the method leaves the created directory behind and throws an exception.
This is an EmbeddedDirectory helper constructor, user code should rely on the higher level and cross-platform factories, Directory::Create and Directory::Open instead.
DirectoryException,including | DirectoryCreationFailed if the operation failed or is not supported on this platform, or DirectoryDelegatingException if the relevant filesystem manager could not be retrieved. |
Definition at line 339 of file OSDLEmbeddedDirectory.cc.
References OSDL::EmbeddedFileSystemManager::GetBackendLastError(), and OSDL::EmbeddedFileSystemManager::SecureEmbeddedFileSystemManager().
OSDL::EmbeddedDirectory::EmbeddedDirectory | ( | const EmbeddedDirectory & | source | ) | [private] |
Copy constructor made private to ensure that it will be never called.
The compiler should complain whenever this undefined constructor is called, implicitly or not.
EmbeddedDirectory & EmbeddedDirectory::Create | ( | const std::string & | newDirectoryName | ) | [static] |
Returns an EmbeddedDirectory reference on a directory newly created on disk, thanks to the operating system facilities.
newDirectoryName | the name of the directory to create. |
This is an EmbeddedDirectory helper factory, user code should rely on the higher level and cross-platform Directory::Create instead.
DirectoryException,including | DirectoryCreationFailed if the operation failed or is not supported on this platform, or DirectoryDelegatingException if the relevant filesystem manager could not be retrieved. |
Definition at line 321 of file OSDLEmbeddedDirectory.cc.
References EmbeddedDirectory().
Referenced by OSDL::EmbeddedFileSystemManager::createDirectory().
FileSystemManager & EmbeddedDirectory::getCorrespondingFileSystemManager | ( | ) | const [protected, virtual] |
Returns the embedded filesystem manager.
DirectoryDelegatingException | if the operation failed. |
Definition at line 375 of file OSDLEmbeddedDirectory.cc.
References OSDL::EmbeddedFileSystemManager::GetEmbeddedFileSystemManager().
Referenced by hasDirectory(), hasEntry(), and hasFile().
void EmbeddedDirectory::getEntries | ( | std::list< std::string > & | entries | ) | const [virtual] |
Returns the names of all files in specified search path, stored in the specified list.
If "C:\mydir" is in the search path and contains a directory "savegames" that contains "x.sav", "y.sav", and "z.sav", and there is also a "C:\userdir" in the search path that has a "savegames" subdirectory with "w.sav", then for the directory corresponding to "savegames" this method will return: [ "x.sav", "y.sav", "z.sav", "w.sav" ].
There will be no duplicates, but the order the list is not specified.
entries | the caller-provided list in which entries will be added. |
DirectoryLookupFailed | if the operation failed or is not supported. |
Definition at line 257 of file OSDLEmbeddedDirectory.cc.
void EmbeddedDirectory::getFiles | ( | std::list< std::string > & | files | ) | const [virtual] |
Returns the names of all regular files and symbolic links of this directory, in the specified list.
files | the caller-provided list in which regular files and symbolic links will be added. |
DirectoryLookupFailed | if the operation failed or is not supported. |
Definition at line 231 of file OSDLEmbeddedDirectory.cc.
void EmbeddedDirectory::getSortedEntries | ( | std::list< std::string > & | subDirectories, | |
std::list< std::string > & | files, | |||
std::list< std::string > & | otherEntries | |||
) | const [virtual] |
Returns the names of all direct entries of any type of this directory (including files and directories), in the corresponding specified list.
subDirectories | the caller-provided list in which subDirectories of this directory will be added. | |
files | the caller-provided list in which files of this directory will be added. | |
otherEntries | the caller-provided list in which other entries (named FIFO, sockets, etc.) of this directory will be added. |
DirectoryLookupFailed | if the operation failed or is not supported. |
Definition at line 283 of file OSDLEmbeddedDirectory.cc.
void EmbeddedDirectory::getSubdirectories | ( | std::list< std::string > & | subDirectories | ) | const [virtual] |
Returns the names of all direct subdirectories of this directory, in the specified list.
subDirectories | the caller-provided list in which subdirectories will be added. |
DirectoryLookupFailed | if the operation failed or is not supported. |
Definition at line 216 of file OSDLEmbeddedDirectory.cc.
bool EmbeddedDirectory::hasDirectory | ( | const std::string & | subdirectoryName | ) | const [virtual] |
q Tells whether this directory with a direct subdirectory named subdirectoryName can be found in the search path.
subdirectoryName | the name of the directory entry to look-up, in the search path. |
DirectoryLookupFailed | is the operation failed or is not supported. |
Definition at line 101 of file OSDLEmbeddedDirectory.cc.
References getCorrespondingFileSystemManager().
bool EmbeddedDirectory::hasEntry | ( | const std::string & | entryName | ) | const [virtual] |
Tells whether the directory has a direct entry named entryName, whatever the entry is (file, directory, named FIFO, socket, etc.
).
entryName | the name of the entry to look-up. |
DirectoryLookupFailed | is the operation failed or is not supported. |
Definition at line 179 of file OSDLEmbeddedDirectory.cc.
References getCorrespondingFileSystemManager().
bool EmbeddedDirectory::hasFile | ( | const std::string & | fileName | ) | const [virtual] |
Tells whether this directory with a direct file or symbolic link named fileName can be found in the search path.
fileName | the name of the file to look-up, in the search path. |
DirectoryLookupFailed | is the operation failed or is not supported. |
Definition at line 137 of file OSDLEmbeddedDirectory.cc.
References getCorrespondingFileSystemManager().
EmbeddedDirectory & EmbeddedDirectory::Open | ( | const std::string & | directoryName = "" |
) | [static] |
Returns an EmbeddedDirectory reference on specified already-existing directory, which will be "opened" (i.e.
referred to), thanks to the operating system facilities.
directoryName | the name of the directory. If not specified (the string is empty), returns a reference to the current working directory. |
This is an EmbeddedDirectory helper factory, user code should rely on the higher level and cross-platform Directory::Open instead.
DirectoryException,including | DirectoryOpeningFailed if the operation failed or is not supported on this platform, or DirectoryDelegatingException if the relevant filesystem manager could not be retrieved. |
Definition at line 330 of file OSDLEmbeddedDirectory.cc.
References EmbeddedDirectory().
Referenced by OSDL::EmbeddedFileSystemManager::openDirectory().
EmbeddedDirectory& OSDL::EmbeddedDirectory::operator= | ( | const EmbeddedDirectory & | source | ) | [private] |
Assignment operator made private to ensure that it will be never called.
The compiler should complain whenever this undefined operator is called, implicitly or not.
const std::string EmbeddedDirectory::toString | ( | Ceylan::VerbosityLevels | level = Ceylan::high |
) | const [virtual] |
Returns a user-friendly description of the state of this object.
level | the requested verbosity level. |
Definition at line 304 of file OSDLEmbeddedDirectory.cc.
const std::string OSDL::EmbeddedDirectory::CurrentDirectoryAlias [static, protected] |
Definition at line 375 of file OSDLEmbeddedDirectory.h.
const std::string OSDL::EmbeddedDirectory::RootDirectoryPrefix [static, protected] |
Definition at line 365 of file OSDLEmbeddedDirectory.h.
const char OSDL::EmbeddedDirectory::Separator [static, protected] |
Definition at line 393 of file OSDLEmbeddedDirectory.h.
const std::string OSDL::EmbeddedDirectory::UpperDirectoryAlias [static, protected] |
Definition at line 385 of file OSDLEmbeddedDirectory.h.