syBR::Core::FileSystem Class Reference

File system management class. More...

#include <FileSystem.hpp>

List of all members.

Public Types

typedef std::list
< DirectoryEntry
DirectoryEntryList
 List of directory entries.
typedef std::list
< DirectoryEntry >
::iterator 
DirectoryEntryListIterator
 Iterator for lists of directory entries.
typedef std::list
< DirectoryEntry >
::const_iterator 
DirectoryEntryListConstIterator
 Constant iterator for lists of directory entries.

Public Member Functions

 FileSystem (Logger *pLogger)
 Constructor.
 ~FileSystem ()
 Destructor.
bool mount (const std::string &location, const bool recursive)
 Mount a directory or an archive.
void unmount (const std::string &location)
 Unmount a directory or an archive.
const
DirectoryEntryList
getLocation (const std::string &location) const
 Get the content of a location.
const bool find (const std::string &location, const std::string &name, const bool searchRelativePath, const bool matchWithoutExtension, DirectoryEntry &entry) const
 Find a directory entry in a mounted location.
const bool find (const std::string &name, const bool searchRelativePath, const bool matchWithoutExtension, DirectoryEntry &entry) const
 Find a directory entry in all the mounted locations.

Static Public Member Functions

static const char * getDynamicLibraryExtension ()
 Get the extension of a dynamic library on this platform.
static const unsigned int getDynamicLibraryExtensionLength ()
 Get the length of the extension of a dynamic library on this platform.

Private Member Functions

bool readDirectoryContent (const std::string &location, const std::string &relativeLocation, const bool recursive, DirectoryEntryList &content)
 Get the content of a directory.

Private Attributes

Loggerm_pLogger
 Pointer to the logger to be used.
std::map
< std::string,
DirectoryEntryList
m_mapMountedDirectories
 Content of the mounted directories.

Static Private Attributes

static const char sm_dynamicLibraryExtension []
 Extension of a dynamic library on this platform.
static const unsigned int sm_dynamicLibraryExtensionLength
 Length of the extension of a dynamic library on this platform.

Classes

struct  DirectoryEntry
 Directory entry i.e. a file or a sub-directory. More...


Detailed Description

File system management class.

Member Typedef Documentation

typedef std::list<DirectoryEntry> syBR::Core::FileSystem::DirectoryEntryList

List of directory entries.

typedef std::list<DirectoryEntry>::iterator syBR::Core::FileSystem::DirectoryEntryListIterator

Iterator for lists of directory entries.

typedef std::list<DirectoryEntry>::const_iterator syBR::Core::FileSystem::DirectoryEntryListConstIterator

Constant iterator for lists of directory entries.


Constructor & Destructor Documentation

syBR::Core::FileSystem::FileSystem ( Logger pLogger  ) 

Constructor.

Parameters:
pLogger Pointer to the instance of the logger to use

syBR::Core::FileSystem::~FileSystem (  ) 

Destructor.


Member Function Documentation

bool syBR::Core::FileSystem::mount ( const std::string &  location,
const bool  recursive 
)

Mount a directory or an archive.

Mount and read the structure of a location. The following location types are currently supported:

Parameters:
location Location to be mounted (directories must end by "/")
recursive One of these:
  • true if the structure of the location must be recursively mounted
  • false otherwise
Returns:
One of these:
  • true in case of success
  • false otherwise

void syBR::Core::FileSystem::unmount ( const std::string &  location  ) 

Unmount a directory or an archive.

Unmount a location which has been previously mounted by mount()

Parameters:
location Location to be unmounted

const FileSystem::DirectoryEntryList & syBR::Core::FileSystem::getLocation ( const std::string &  location  )  const

Get the content of a location.

Parameters:
location Location to be retrieved
Returns:
List of directory entries of the mounted location

const bool syBR::Core::FileSystem::find ( const std::string &  location,
const std::string &  name,
const bool  searchRelativePath,
const bool  matchWithoutExtension,
DirectoryEntry entry 
) const

Find a directory entry in a mounted location.

Parameters:
location Location to be searched
name Name of the file to search
searchRelativePath One of these:
  • true to search for Name in the relative path of the entry
  • false to search for Name in the name of the entry
matchWithoutExtension One of these:
  • true if the name must match the name of an entry without its extension
  • false otherwise
entry Resulting directory entry
Returns:
One of these:
  • true if a matching entry has been found
  • false otherwise

const bool syBR::Core::FileSystem::find ( const std::string &  name,
const bool  searchRelativePath,
const bool  matchWithoutExtension,
DirectoryEntry entry 
) const

Find a directory entry in all the mounted locations.

Parameters:
name Name of the file to search
searchRelativePath One of these:
  • true to search for Name in the relative path of the entry
  • false to search for Name in the name of the entry
matchWithoutExtension One of these:
  • true if the name must match the name of an entry without its extension
  • false otherwise
entry Resulting directory entry
Returns:
One of these:
  • true if a matching entry has been found
  • false otherwise

const char * syBR::Core::FileSystem::getDynamicLibraryExtension (  )  [static]

Get the extension of a dynamic library on this platform.

Returns:
Extension of a dynamic library on this platform

const unsigned int syBR::Core::FileSystem::getDynamicLibraryExtensionLength (  )  [static]

Get the length of the extension of a dynamic library on this platform.

Returns:
Number of characters in the the extension of a dynamic library on this platform

bool syBR::Core::FileSystem::readDirectoryContent ( const std::string &  location,
const std::string &  relativeLocation,
const bool  recursive,
DirectoryEntryList content 
) [private]

Get the content of a directory.

Parameters:
location Location of the directory which content must be retrieved
relativeLocation Location of the directory which content must be retrieved, relative to the mount directory
content List to be filled with the files and subdirectories of the location
recursive One of these:
  • true if the structure of the directory must be recursively mounted
  • false otherwise
Returns:
One of these:
  • true if the content has been retrieved
  • false otherwise
Todo:
Use FindFirstFile and other functions under WIN32 to allow compilation with other compilers than MingW


Member Data Documentation

const char syBR::Core::FileSystem::sm_dynamicLibraryExtension[] [static, private]

Extension of a dynamic library on this platform.

const unsigned int syBR::Core::FileSystem::sm_dynamicLibraryExtensionLength [static, private]

Length of the extension of a dynamic library on this platform.

Logger* syBR::Core::FileSystem::m_pLogger [private]

Pointer to the logger to be used.

std::map<std::string, DirectoryEntryList> syBR::Core::FileSystem::m_mapMountedDirectories [private]

Content of the mounted directories.


The documentation for this class was generated from the following files:

Copyright © 2008 by Sebastien Frippiat
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 License.
Last modified Tue Dec 30 17:57:33 2008