OSDL::EmbeddedDirectory Class Reference

Encapsulates embedded directories, i.e. More...

#include <OSDLEmbeddedDirectory.h>

Collaboration diagram for OSDL::EmbeddedDirectory:
Collaboration graph
[legend]

List of all members.

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 EmbeddedDirectoryCreate (const std::string &newDirectoryName)
 Returns an EmbeddedDirectory reference on a directory newly created on disk, thanks to the operating system facilities.
static EmbeddedDirectoryOpen (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.
EmbeddedDirectoryoperator= (const EmbeddedDirectory &source)
 Assignment operator made private to ensure that it will be never called.

Detailed Description

Encapsulates embedded directories, i.e.

directories in a virtual filesystem stored in an actual standard file, as provided by the PhysicsFS back-end.

See also:
http://icculus.org/physfs/

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.

See also:
File, FileSystemManager for other file-related operations.

Definition at line 69 of file OSDLEmbeddedDirectory.h.


Constructor & Destructor Documentation

EmbeddedDirectory::~EmbeddedDirectory (  )  throw () [virtual]

Destroys the directory reference, not the directory itself.

See also:
Directory::Remove

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.

Parameters:
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.

Exceptions:
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().

Referenced by Create(), and Open().

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.


Member Function Documentation

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.

Parameters:
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.

Exceptions:
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.

Note:
It is not necessarily the current default one.
Exceptions:
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.

Parameters:
entries the caller-provided list in which entries will be added.
Exceptions:
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.

Parameters:
files the caller-provided list in which regular files and symbolic links will be added.
Exceptions:
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.

Parameters:
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.
Exceptions:
DirectoryLookupFailed if the operation failed or is not supported.
Note:
Aliases for current and parent directories (ex: '.' and '..') will be filtered out.

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.

Parameters:
subDirectories the caller-provided list in which subdirectories will be added.
Exceptions:
DirectoryLookupFailed if the operation failed or is not supported.
Note:
Aliases for current and parent directories (ex: '.' and '..') will be filtered out.

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.

Parameters:
subdirectoryName the name of the directory entry to look-up, in the search path.
Exceptions:
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.

).

Parameters:
entryName the name of the entry to look-up.
Exceptions:
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.

Parameters:
fileName the name of the file to look-up, in the search path.
Exceptions:
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.

Parameters:
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.

Exceptions:
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.

Parameters:
level the requested verbosity level.
Note:
Text output format is determined from overall settings.
See also:
TextDisplayable

Definition at line 304 of file OSDLEmbeddedDirectory.cc.


Member Data Documentation

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.


The documentation for this class was generated from the following files:
Generated on Mon Nov 29 14:05:27 2010 for OSDL by  doxygen 1.6.3