FileSystem Class Reference

#include <FileSystem.h>

List of all members.

Public Types

typedef std::list< std::string > FileList

Public Member Functions

 FileSystem (bool noforcedvpaths=false)
 ~FileSystem ()
void initBuiltinData (bool allowoverride)
IDataSourceReadFile (const std::string &vfn, bool is_text=false)
ODataSourceWriteFile (const std::string &vfn, bool is_text=false)
bool AddVirtualPath (const std::string &vpath, const std::string &realpath, bool create=false)
bool RemoveVirtualPath (const std::string &vpath)
int MkDir (const std::string &path)
int ListFiles (const std::string mask, FileList &files)

Static Public Member Functions

static FileSystemget_instance ()

Private Member Functions

void switch_slashes (std::string &name)
bool base_to_uppercase (std::string &str, int count)
bool rawopen (std::ifstream &in, const std::string &fname, bool is_text=false)
bool rawopen (std::ofstream &out, const std::string &fname, bool is_text=false)
bool IsDir (const std::string &path)
bool rewrite_virtual_path (std::string &vfn)
IDataSourcecheckBuiltinData (const std::string &vfn, bool is_text=false)

Private Attributes

bool noforcedvpaths
bool allowdataoverride
std::map< std::string, std::string > virtualpaths
std::map< std::string, MemoryFile * > memoryfiles

Static Private Attributes

static FileSystemfilesystem = 0

Classes

struct  MemoryFile


Detailed Description

Definition at line 32 of file FileSystem.h.


Member Typedef Documentation

typedef std::list<std::string> FileSystem::FileList

Definition at line 73 of file FileSystem.h.


Constructor & Destructor Documentation

FileSystem::FileSystem ( bool  noforcedvpaths = false  ) 

Parameters:
noforcedvpaths if false, all file operations must use vpaths

Definition at line 43 of file FileSystem.cpp.

References AddVirtualPath(), con, filesystem, MM_INFO, and Console::Print().

FileSystem::~FileSystem (  ) 

Definition at line 85 of file FileSystem.cpp.

References con, filesystem, MM_INFO, and Console::Print().


Member Function Documentation

bool FileSystem::AddVirtualPath ( const std::string &  vpath,
const std::string &  realpath,
bool  create = false 
)

Mount a virtual path

Parameters:
vpath the name of the vpath (should start with '@')
realpath the name of the path to mount (note that this can be a virtual path itself)
create create realpath directory if it doesn't exist?
Returns:
true if succesful

Referenced by GameDetector::detect(), FileSystem(), CoreApp::loadConfig(), CoreApp::setupGamePaths(), and CoreApp::setupVirtualPaths().

bool FileSystem::base_to_uppercase ( std::string &  str,
int  count 
) [private]

IDataSource * FileSystem::checkBuiltinData ( const std::string &  vfn,
bool  is_text = false 
) [private]

Check if the given file is a builtin data file. If so, return an IDataSource for it. If not, return 0.

Definition at line 370 of file FileSystem.cpp.

References memoryfiles.

static FileSystem* FileSystem::get_instance (  )  [inline, static]

Definition at line 42 of file FileSystem.h.

References filesystem.

Referenced by choosePalette(), GameMapGump::ConCmd_dumpMap(), MovieGump::ConCmd_play(), FixedWidthFont::Create(), GameDetector::detect(), DirFile::exists(), DirFile::getObject(), DirFile::getSize(), GameData::getSpeechFlex(), FontManager::getTTF_Font(), PentagramMenuGump::InitGump(), U8SaveGump::loadDescriptions(), U8Game::loadFiles(), RemorseGame::loadFiles(), GameData::loadRemorseData(), GameData::loadU8Data(), U8Game::playCredits(), U8Game::playEndgameMovie(), U8Game::playIntroMovie(), U8Game::playQuotes(), DirFile::readMetadata(), U8Game::startGame(), ShapeViewerGump::U8ShapeViewer(), and INIFile::write().

void FileSystem::initBuiltinData ( bool  allowoverride  ) 

Initialize builtin data files.

Definition at line 27 of file data.cpp.

References allowdataoverride, memoryfiles, and perr.

Referenced by GUIApp::startup().

bool FileSystem::IsDir ( const std::string &  path  )  [private]

int FileSystem::ListFiles ( const std::string  mask,
FileList files 
)

List files matching a mask

Parameters:
mask the mask to match
files the FileList to which the found files are appended
return OS-specific (FIXME!)

Definition at line 96 of file ListFiles.h.

References perr, and rewrite_virtual_path().

Referenced by CompileUnit::CompileUnit(), and DirFile::readMetadata().

int FileSystem::MkDir ( const std::string &  path  ) 

Create a directory

Parameters:
path the directory to create. (Can be virtual)
Returns:
OS-specific (FIXME!)

Referenced by CoreApp::setupGamePaths().

bool FileSystem::rawopen ( std::ofstream &  out,
const std::string &  fname,
bool  is_text = false 
) [private]

bool FileSystem::rawopen ( std::ifstream &  in,
const std::string &  fname,
bool  is_text = false 
) [private]

IDataSource* FileSystem::ReadFile ( const std::string &  vfn,
bool  is_text = false 
)

Open a file as readable. Streamed.

Parameters:
vfn the (virtual) filename
is_text open in text mode?
Returns:
0 on failure

Referenced by choosePalette(), MovieGump::ConCmd_play(), FixedWidthFont::Create(), GameDetector::detect(), DirFile::exists(), DirFile::getObject(), DirFile::getSize(), GameData::getSpeechFlex(), FontManager::getTTF_Font(), GUIApp::GraphicSysInit(), PentagramMenuGump::InitGump(), U8SaveGump::loadDescriptions(), U8Game::loadFiles(), RemorseGame::loadFiles(), GUIApp::loadGame(), GameData::loadRemorseData(), GameData::loadU8Data(), main(), CompileUnit::parse(), U8Game::playCredits(), U8Game::playEndgameMovie(), U8Game::playIntroMovie(), U8Game::playQuotes(), run(), U8Game::startGame(), and ShapeViewerGump::U8ShapeViewer().

bool FileSystem::RemoveVirtualPath ( const std::string &  vpath  ) 

Unmount a virtual path.

Referenced by CoreApp::killGame().

bool FileSystem::rewrite_virtual_path ( std::string &  vfn  )  [private]

Referenced by ListFiles().

void FileSystem::switch_slashes ( std::string &  name  )  [private]

ODataSource* FileSystem::WriteFile ( const std::string &  vfn,
bool  is_text = false 
)

Open a file as writable. Streamed.

Parameters:
vfn the (virtual) filename
is_text open in text mode?
Returns:
0 on failure

Referenced by GameMapGump::ConCmd_dumpMap(), main(), GUIApp::saveGame(), and INIFile::write().


Member Data Documentation

bool FileSystem::allowdataoverride [private]

Definition at line 108 of file FileSystem.h.

Referenced by initBuiltinData().

FileSystem * FileSystem::filesystem = 0 [static, private]

Definition at line 101 of file FileSystem.h.

Referenced by FileSystem(), get_instance(), and ~FileSystem().

std::map<std::string, MemoryFile*> FileSystem::memoryfiles [private]

Definition at line 127 of file FileSystem.h.

Referenced by checkBuiltinData(), and initBuiltinData().

bool FileSystem::noforcedvpaths [private]

Definition at line 105 of file FileSystem.h.

std::map<std::string, std::string> FileSystem::virtualpaths [private]

Definition at line 114 of file FileSystem.h.


The documentation for this class was generated from the following files:
Generated on Fri Jul 27 22:29:11 2007 for pentagram by  doxygen 1.4.7