Spinning Topp Logo BlackTopp Studios
inc
Classes | Typedefs | Enumerations | Functions
Mezzanine::Resource Namespace Reference

This namespace is for all the classes belonging to the non-network I/O Subsystem. More...

Classes

class  Archive
 
class  Asset
 A convenience base class for objects that may need common IO operations exposed for them. More...
 
class  AssetGroup
 This is a class that stores a specific grouping of Assets, usually based on thier location. More...
 
class  AssetHandler
 
class  AssetID
 This is a simple class storing the name and group identification of an Asset/Stream. More...
 
class  DefaultResourceManagerFactory
 A factory responsible for the creation and destruction of the default resourcemanager. More...
 
class  FileStream
 This represents a stream to a file on disk using the C++ file stream API. More...
 
class  iInStream
 Interface class for input (read) streams. More...
 
class  IOStream
 Base class for streams that support both read and write operations. More...
 
class  iOutStream
 Interface class for output (write) streams. More...
 
class  IStream
 Base class for input (read) streams with minimal implementation. More...
 
class  iStreamBase
 Base class interface for resource streams. More...
 
class  MemoryStream
 An I/O stream to a buffer of memory. More...
 
class  MemoryStreamBuffer
 A stream buffer object to a chunk of memory. More...
 
class  OStream
 Base class for output (write) streams with minimal implementation. More...
 
class  ResourceManager
 This is the manager responsible for the loading and unloading of files. More...
 

Typedefs

typedef IOStream DataStream
 Convenience type for compatibility.
 
typedef CountedPtr< DataStreamDataStreamPtr
 This is a convenience type for a data stream in a counted pointer.
 
typedef CountedPtr< IStreamIStreamPtr
 Convenience type for a standard input stream in a CountedPtr.
 
typedef CountedPtr< OStreamOStreamPtr
 Convenience type for a standard output stream in a CountedPtr.
 
typedef std::istream StdInputStream
 Convenience type for a standard input stream.
 
typedef CountedPtr< StdInputStreamStdInputStreamPtr
 Convenience type for a standard input stream in a CountedPtr.
 
typedef std::ostream StdOutputStream
 Convenience type for a standard output stream.
 
typedef CountedPtr< StdOutputStreamStdOutputStreamPtr
 Convenience type for a standard output stream in a CountedPtr.
 
typedef std::iostream StdStream
 Convenience type for a standard input/output stream.
 
typedef CountedPtr< StdStreamStdStreamPtr
 Convenience type for a standard input/output stream in a CountedPtr.
 
typedef std::streamoff StreamOff
 Convenience define for the stream offset datatype.
 
typedef std::streampos StreamPos
 Convenience define for the stream position datatype.
 
typedef std::streamsize StreamSize
 Convenience define for the stream size datatype.
 

Enumerations

enum  ArchiveType { AT_FileSystem = 0, AT_Zip = 1, AT_Invalid = 32768 }
 Used to indicate what kind of resources the Entrosol should look for. More...
 
enum  LoadingState {
  LS_Uninitialized = 0, LS_Initializing = 1, LS_Initialized = 2, LS_Loading = 3,
  LS_Loaded = 4
}
 This enum describes the current state of loading for an asset.
 
enum  SeekOrigin { SO_Beginning = std::ios_base::beg, SO_Current = std::ios_base::cur, SO_End = std::ios_base::end }
 An enum describing which position should be considered the origin for changing the current position in a stream. More...
 
enum  StreamFlags {
  SF_None = 0, SF_Read = std::ios_base::in, SF_Write = std::ios_base::out, SF_Append = std::ios_base::app,
  SF_AtEnd = std::ios_base::ate, SF_Binary = std::ios_base::binary, SF_Truncate = std::ios_base::trunc
}
 This enum describes the flags that control certain behaviors of a stream. More...
 

Functions

String BaseName (const String &FileName)
 Get the filename portion of a string. More...
 
void CacheMainArgs (int ArgCount, char **ArgVars)
 Store the Main arguments for later use. More...
 
void ChangeWorkingDirectory (const String &ChangeTo)
 Change directory, to the directory indicated. More...
 
String CombinePathAndFileName (const String &FilePath, const String &FileName)
 Convenience method to verify the necessary system separator is present when concatenating. More...
 
Boole CreateDirectory (const String &DirectoryPath)
 Creates a single new directory. More...
 
Boole CreateDirectoryPath (const String &DirectoryPath)
 Creates all directories that do not exist in the provided path. More...
 
String DirName (const String &FileName)
 Get the directory portion of a string. More...
 
Boole DoesDirectoryExist (const String &DirectoryPath)
 Checks to see if the given path exists and if it is a folder.

Exceptions
OnError this might throw a Mezzanine::IOException with detail about why it failed.
More...
 
String GetCommonUserDataDir ()
 Gets the path to the directory intended for game saves and user profile data for all users. More...
 
String GetCurrentUserDataDir ()
 Gets the path to the directory intended for game saves and user profile data for the current user. More...
 
StringVector GetDirContents (const String &Dir=".")
 Get a Listing of the files and subdirectories in a directory. More...
 
Char8 GetDirectorySeparator ()
 Get the character used to separate directories. More...
 
String GetExecutableDir ()
 Get the Path to the current executable, in a fast way if possible. More...
 
String GetExecutableDir (int ArgCount, char **ArgVars)
 Get the Path to the current executable, fast from Args if Possible or from a system call otherwise. More...
 
String GetExecutableDirFromArg ()
 Uses the main parameters stored using "CacheMainArgs" to attempt determine executable directory. More...
 
String GetExecutableDirFromArg (int ArgCount, char **ArgVars)
 Attempt to get the executable directory from the a set of variables like those passed into Main. More...
 
String GetExecutableDirFromSystem ()
 Used a system call to get the curent Directory the executable is in. This make an external system call and is likely slower than GetExecutableDirFromArg. More...
 
String GetLocalAppDataDir ()
 Gets the path to the directory intended for game and engine config data that is not meant to be shared. More...
 
Char8 GetPathSeparator ()
 Get the character used to separate entries in the system PATH. More...
 
String GetShareableAppDataDir ()
 Gets the path to the directory intended for game and engine config data that is allowed to be shared. More...
 
StringVector GetSystemPATH (const String &PATH=String(getenv("PATH")))
 Get the $PATH or PATH% split and order for easy checking of how the OS does it. More...
 
String GetWorkingDirectory ()
 Get the working directory as a Mezzanine::String. More...
 
void RemoveDirectory (const String &DirectoryPath)
 Remove an empty directory.

Exceptions
OnError this might throw a Mezzanine::IOException with details about why it failed.
More...
 
String ResolveDataPathFromString (const String &PathVar)
 Resolves a string describing one of the platform data paths to the actual path it is. More...
 
String Which (const String &ExecutableName)
 Search the system path the same way most systems do to find an executable. More...
 

Detailed Description

This namespace is for all the classes belonging to the non-network I/O Subsystem.

The resource system is primarily responsible for the loading, reading, and writing of files as well as filesystem management.

Enumeration Type Documentation

Used to indicate what kind of resources the Entrosol should look for.

Enumerator
AT_FileSystem 

Look for raw files.

AT_Zip 

Look for stuff in zip files even if the extension is not '.zip'.

AT_Invalid 

Indicates this valid was messed up unrecoverably, most likely by a bug.

Definition at line 51 of file resourceenumerations.h.

An enum describing which position should be considered the origin for changing the current position in a stream.

Enumerator
SO_Beginning 

The beginning of the stream.

SO_Current 

The current position for read/write operations in the stream.

SO_End 

The end of the stream.

Definition at line 77 of file datastream.h.

This enum describes the flags that control certain behaviors of a stream.

It is important to note that not all of these flags are used by all streams.

Enumerator
SF_None 

Error/no special initialization.

SF_Read 

Permit read operations on the stream.

SF_Write 

Permit write operations on the stream.

SF_Append 

All write operations on the stream are done at the end of the stream.

SF_AtEnd 

Moves the starting position of the stream to the end upon initialization.

SF_Binary 

Tell the stream that the file in question is Binary.

SF_Truncate 

Clear the contents of the file when opening. Note that this will also create the file if it's not found.

Definition at line 65 of file datastream.h.

Function Documentation

String MEZZ_LIB Mezzanine::Resource::BaseName ( const String FileName)

Get the filename portion of a string.

Parameters
FileNameA complete path and filename.
Returns
If passed "/a/b/c.txt" or "c:\windirs\crash.exe" this will return "c.txt" or "crash.exe".

Definition at line 236 of file resourceutilities.cpp.

void MEZZ_LIB Mezzanine::Resource::CacheMainArgs ( int  ArgCount,
char **  ArgVars 
)

Store the Main arguments for later use.

Parameters
ArgCountHow many arguments will be passed in ArgVars.
ArgVarsA pointer to an array, with ArgCount elements, of char* which point to null terminated c strings.

Definition at line 104 of file resourceutilities.cpp.

void MEZZ_LIB Mezzanine::Resource::ChangeWorkingDirectory ( const String ChangeTo)

Change directory, to the directory indicated.

Parameters
ChangeToThe new directory to work from.

Definition at line 393 of file resourceutilities.cpp.

String MEZZ_LIB Mezzanine::Resource::CombinePathAndFileName ( const String FilePath,
const String FileName 
)

Convenience method to verify the necessary system separator is present when concatenating.

Parameters
FilePathThe directory path to the file.
FileNameThe name of the file.
Returns
Returns a full string that is the concatenated path and filename.

Definition at line 268 of file resourceutilities.cpp.

Boole MEZZ_LIB Mezzanine::Resource::CreateDirectory ( const String DirectoryPath)

Creates a single new directory.

Remarks
This function will only create the directory specified at the end of the path.
Parameters
DirectoryPathThe path for the newly created directory.
Returns
Returns true if the directory was created, false in the case of a non-critical error.

Definition at line 121 of file resourceutilities.cpp.

Boole MEZZ_LIB Mezzanine::Resource::CreateDirectoryPath ( const String DirectoryPath)

Creates all directories that do not exist in the provided path.

Parameters
DirectoryPathThe path for the newly created directory or directories.
Returns
Returns true if all directories were created, false in the case of a non-critical error.

Definition at line 152 of file resourceutilities.cpp.

String MEZZ_LIB Mezzanine::Resource::DirName ( const String FileName)

Get the directory portion of a string.

Parameters
FileNameA complete path and filename.
Returns
If passed "/a/b/c.txt" or "c:\windirs\crash.exe" this will return "/a/b/" or "c:\windirs\".

Definition at line 222 of file resourceutilities.cpp.

Boole MEZZ_LIB Mezzanine::Resource::DoesDirectoryExist ( const String DirectoryPath)

Checks to see if the given path exists and if it is a folder.

Exceptions
OnError this might throw a Mezzanine::IOException with detail about why it failed.

Parameters
DirectoryPathA String containing the path to test.
Returns
True if the item indicated by DirectoryPath exists and it is a directory, false if it does not exist or exists but is a file.

Definition at line 179 of file resourceutilities.cpp.

String MEZZ_LIB Mezzanine::Resource::GetCommonUserDataDir ( )

Gets the path to the directory intended for game saves and user profile data for all users.

Returns
Returns a string containing the path to the Common User Data Directory.

Definition at line 495 of file resourceutilities.cpp.

String MEZZ_LIB Mezzanine::Resource::GetCurrentUserDataDir ( )

Gets the path to the directory intended for game saves and user profile data for the current user.

Returns
Returns a string containing the path to the Current User Data Directory.

Definition at line 477 of file resourceutilities.cpp.

StringVector MEZZ_LIB Mezzanine::Resource::GetDirContents ( const String Dir = ".")

Get a Listing of the files and subdirectories in a directory.

This follows normal command line conventions, "." is the current directory, ".." is the parent directory. To access the file system root you will need to use a leading "c:/", "c:\\", or "/" as appropriate for the operating system the software will run on.

Parameters
DirThe directory to check.
Returns
This will return a pointer to a set of Strings the caller is responsible for deleting or a null pointer on an error.

Definition at line 200 of file resourceutilities.cpp.

Char8 MEZZ_LIB Mezzanine::Resource::GetDirectorySeparator ( )

Get the character used to separate directories.

Returns
Backslash '\' on windows and Forward slash '/' on other operating systems.

Definition at line 250 of file resourceutilities.cpp.

String MEZZ_LIB Mezzanine::Resource::GetExecutableDir ( )

Get the Path to the current executable, in a fast way if possible.

Returns
A String containing the path to the current executable.

Definition at line 317 of file resourceutilities.cpp.

String MEZZ_LIB Mezzanine::Resource::GetExecutableDir ( int  ArgCount,
char **  ArgVars 
)

Get the Path to the current executable, fast from Args if Possible or from a system call otherwise.

Parameters
ArgCountHow many arguments will be passed in ArgVars.
ArgVarsA pointer to an array, with ArgCount elements, of char* which point to null terminated c strings.
Warning
If you pass bogus arguments to this bad things can and will happen. Infinite loops, segfaults etc... Just pass what main gives you
Not all system provide all the needed information to determine the executable directory
Returns
A String containing the path to the current executable.

Definition at line 322 of file resourceutilities.cpp.

String MEZZ_LIB Mezzanine::Resource::GetExecutableDirFromArg ( )

Uses the main parameters stored using "CacheMainArgs" to attempt determine executable directory.

Returns
Either a valid Path, '.' if the working dir is likely correct or "" if nothing could be determined.

Definition at line 358 of file resourceutilities.cpp.

String MEZZ_LIB Mezzanine::Resource::GetExecutableDirFromArg ( int  ArgCount,
char **  ArgVars 
)

Attempt to get the executable directory from the a set of variables like those passed into Main.

Note
This is the fastest way to get the Executable location, but might not work on all platforms.
Warning
If you pass bogus arguments to this bad things can and will happen. Infinite loops, segfaults etc... Just pass what main gives you.
Not all systems provide all the needed information to determine the executable directory.
Parameters
ArgCountHow many arguments will be passed in ArgVars.
ArgVarsA pointer to an array, with ArgCount elements, of char* which point to null terminated c strings.
Returns
If a whole path is present in ArgVars[0] this returns the directory part of that path, if this uses the executable file this returns '.', otherwise this with return "" indicating it is not usable.

Definition at line 363 of file resourceutilities.cpp.

String MEZZ_LIB Mezzanine::Resource::GetExecutableDirFromSystem ( )

Used a system call to get the curent Directory the executable is in. This make an external system call and is likely slower than GetExecutableDirFromArg.

Returns
This will return the current path this executable is stored in.

Definition at line 332 of file resourceutilities.cpp.

String MEZZ_LIB Mezzanine::Resource::GetLocalAppDataDir ( )

Gets the path to the directory intended for game and engine config data that is not meant to be shared.

Returns
Returns a string containing the path to the Local Application Data Directory.

Definition at line 432 of file resourceutilities.cpp.

Char8 MEZZ_LIB Mezzanine::Resource::GetPathSeparator ( )

Get the character used to separate entries in the system PATH.

Returns
Semicolon ';' on windows and Forward slash ':' on other operating systems.

Definition at line 259 of file resourceutilities.cpp.

String MEZZ_LIB Mezzanine::Resource::GetShareableAppDataDir ( )

Gets the path to the directory intended for game and engine config data that is allowed to be shared.

Returns
Returns a string containing the path to the Shareable Application Data Directory.

Definition at line 459 of file resourceutilities.cpp.

StringVector MEZZ_LIB Mezzanine::Resource::GetSystemPATH ( const String PATH = String(getenv("PATH")))

Get the $PATH or PATH% split and order for easy checking of how the OS does it.

Parameters
PATHDefaults to the PATH environment variable. But any value like a system path will be split the return of GetPathSeparator().
Returns
A collection of directories that this system will for executables in the order they will be checked.

Definition at line 282 of file resourceutilities.cpp.

String MEZZ_LIB Mezzanine::Resource::GetWorkingDirectory ( )

Get the working directory as a Mezzanine::String.

Returns
The Directory the game was called from (not nescessarilly the location of the executable), as a Mezzanine::String

Definition at line 403 of file resourceutilities.cpp.

void MEZZ_LIB Mezzanine::Resource::RemoveDirectory ( const String DirectoryPath)

Remove an empty directory.

Exceptions
OnError this might throw a Mezzanine::IOException with details about why it failed.

Parameters
DirectoryPathThe Path to the directory to remove.

Definition at line 191 of file resourceutilities.cpp.

String MEZZ_LIB Mezzanine::Resource::ResolveDataPathFromString ( const String PathVar)

Resolves a string describing one of the platform data paths to the actual path it is.

Remarks
Currently there are only 4 preset path variables, and depending on platform they two or more may go to the same location. The valid variables are as follows: LocalAppData, ShareableAppData, CurrentUserData, and CommonUserData. These are not case sensative.
Parameters
PathVarString containing the name of the path variable.
Returns
Returns the actual path of the variable provided.

Definition at line 418 of file resourceutilities.cpp.

String MEZZ_LIB Mezzanine::Resource::Which ( const String ExecutableName)

Search the system path the same way most systems do to find an executable.

Warning
This function is case sensitive and not all operating systems are.
Todo:
Add support for extension handling on windows. "cmd" should find "cmd.exe" in system32, but currently "cmd.exe" needs to be searched.
Parameters
ExecutableNameThe executable to look for.
Returns
If the executable is not found "" is returned otherwise the first directory in the PATH containing it is returned.

Definition at line 300 of file resourceutilities.cpp.