Public Member Functions | Private Member Functions | Private Attributes

Filesystem Class Reference

Implements a virtual file system. More...

#include <Filesystem.h>

List of all members.

Public Member Functions

 Filesystem (const std::string &argv_0, const std::string &startPath)
 Filesystem ()
 ~Filesystem ()
void init (const std::string &argv_0, const std::string &startPath)
File getFile (const std::string &fileName) const
std::string getUserPath () const
std::string getDataPath () const
std::string getWorkingDir (const std::string &fileName) const
bool addToSearchPath (const std::string &pathName) const
StringList getSearchPath () const
StringList enumerateDir (const std::string &dir) const
StringList enumerateDir (const std::string &dir, const std::string &filter) const
bool writeFile (const File &file, bool overwrite=true) const
bool deleteFile (const std::string &filename) const
bool makeDirectory (const std::string &dirPath) const
bool isDirectory (const std::string &path) const
bool exists (const std::string &fileName) const
std::string getLastError () const
void toggleVerbose () const
void debug ()
std::string getFileExtension (const std::string path)

Private Member Functions

 Filesystem (const Filesystem &)
Filesystemoperator= (const Filesystem &)
bool closeFile (PHYSFS_File *file) const

Private Attributes

std::string mDataPath
std::string mStartPath
std::string mDirSeparator
bool mVerbose
StringList mErrorMessages

Detailed Description

Implements a virtual file system.

Provides cross-platform and transparent archive Filesystem functions.


Constructor & Destructor Documentation

Filesystem::Filesystem ( const std::string &  argv_0,
const std::string &  startPath 
)
Filesystem::Filesystem (  ) 
Filesystem::~Filesystem (  ) 

Shuts down PhysFS and cleans up.

Filesystem::Filesystem ( const Filesystem  )  [private]

Member Function Documentation

bool Filesystem::addToSearchPath ( const std::string &  pathName  )  const
bool Filesystem::closeFile ( PHYSFS_File *  file  )  const [private]

Closes a file handle.

Parameters:
file A handle to a PHYSFS_file.
Returns:
True on success, false otherwise.
Note:
This function sets its paramter to NULL after the file is closed. This effectively invalidates the file handle and so it should not be used again unless properly initialized. This is an intentional design feature to ensure that the use of a file that's been closed cannot be used again.
void Filesystem::debug (  ) 

Writes basic Filesystem debug information to the global Log File.

bool Filesystem::deleteFile ( const std::string &  filename  )  const
StringList Filesystem::enumerateDir ( const std::string &  dir,
const std::string &  filter 
) const
StringList Filesystem::enumerateDir ( const std::string &  dir  )  const

Returns a list of files within a given directory.

Parameters:
searchDir Directory to search within the searchpath.
Note:
This function will also return the names of any directories in a specified search path
bool Filesystem::exists ( const std::string &  fileName  )  const [inline]

Checks for the existence of a file.

Returns Returns true if the specified file exists. Otherwise, returns false.

std::string Filesystem::getDataPath (  )  const [inline]

Gets the base data path.

File Filesystem::getFile ( const std::string &  fileName  )  const
std::string Filesystem::getFileExtension ( const std::string  path  ) 
std::string Filesystem::getLastError (  )  const [inline]

Returns the last error that occurred.

StringList Filesystem::getSearchPath (  )  const

Returns a list of directories in the Search Path.

std::string Filesystem::getUserPath (  )  const [inline]

Gets the current User path.

std::string Filesystem::getWorkingDir ( const std::string &  fileName  )  const
void Filesystem::init ( const std::string &  argv_0,
const std::string &  startPath 
)

Shuts down PhysFS and cleans up.

bool Filesystem::isDirectory ( const std::string &  path  )  const [inline]

Determines if a given path is a directory rather than a file.

bool Filesystem::makeDirectory ( const std::string &  dirPath  )  const [inline]

Creates a new directory within the primary search path.

Returns:
Returns true if successful. Otherwise, returns false.
Filesystem& Filesystem::operator= ( const Filesystem  )  [private]
void Filesystem::toggleVerbose (  )  const [inline]
bool Filesystem::writeFile ( const File file,
bool  overwrite = true 
) const

Writes a file to disk.

Parameters:
file A reference to a const File object.
Returns:
Returns true if successful. Otherwise, returns false.

Member Data Documentation

std::string Filesystem::mDataPath [private]

Data path string. Specific to each platform.

std::string Filesystem::mDirSeparator [private]

Platform dependant directory separator.

List of error messages.

std::string Filesystem::mStartPath [private]

Path to start in. This will typically be 'data/'.

bool Filesystem::mVerbose [mutable, private]

Displays lots of messages when true. Otherwise only critical messages are displayed.


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