Class ContentManager
- Namespace
- OmegaEngine.Foundation.Storage
- Assembly
- OmegaEngine.Foundation.dll
Provides a virtual file system for combining data from multiple directories (useful for modding).
public static class ContentManager
- Inheritance
-
ContentManager
- Inherited Members
Fields
EnvVarNameBaseDir
The name of an environment variable that can be used to configure the content manager.
[PublicAPI]
public const string EnvVarNameBaseDir = "OMEGAENGINE_CONTENT"
Field Value
EnvVarNameModDir
The name of an environment variable that can be used to configure the content manager.
[PublicAPI]
public const string EnvVarNameModDir = "OMEGAENGINE_CONTENT_MOD"
Field Value
Properties
BaseDir
The base directory where content files are stored.
public static DirectoryInfo BaseDir { get; set; }
Property Value
Remarks
You can use the environment variable EnvVarNameBaseDir to set this value. When using the environment variable, you can also specify multiple directories to be overlaid. This property will then only expose the last directory.
Exceptions
- DirectoryNotFoundException
The specified directory could not be found.
ModDir
A directory overriding the base directory for creating mods. null
if there is no active mod.
public static DirectoryInfo? ModDir { get; set; }
Property Value
Remarks
You can use the environment variable EnvVarNameModDir to set this value. When using the environment variable, you can also specify multiple directories to be overlaid. This property will then only expose the last directory.
Exceptions
- DirectoryNotFoundException
The specified directory could not be found.
Methods
CreateDirPath(string)
Creates a path for a content directory (using the ModDir if available).
public static string CreateDirPath(string type)
Parameters
type
stringThe type of file (e.g. Textures, Sounds, ...).
Returns
- string
The absolute path to the requested directory.
Exceptions
- DirectoryNotFoundException
The specified directory could not be found.
CreateFilePath(string, string)
Creates a path for a content file (using ModDir if available).
public static string CreateFilePath(string type, string id)
Parameters
Returns
- string
The absolute path to the requested content file.
DeleteModFile(string, string)
public static void DeleteModFile(string type, string id)
Parameters
Exceptions
- InvalidOperationException
ModDir is not set.
- FileNotFoundException
The specified file could not be found.
- IOException
The specified file could not be deleted.
- UnauthorizedAccessException
You have insufficient rights to delete the file.
FileExists(string, string)
Checks whether a certain content file exists.
public static bool FileExists(string type, string id)
Parameters
Returns
- bool
true
if the requested content file exists.
GetFileList(string, string)
Gets a list of all files of a certain type
public static NamedCollection<FileEntry> GetFileList(string type, string extension)
Parameters
type
stringThe type of files you want (e.g. Textures, Sounds, ...)
extension
stringThe file extension to so search for
Returns
- NamedCollection<FileEntry>
A collection of strings with file IDs
GetFilePath(string, string)
Gets the file path for a content file
public static string GetFilePath(string type, string id)
Parameters
Returns
- string
The absolute path to the requested content file
Exceptions
- FileNotFoundException
The specified file could not be found.
GetFileStream(string, string)
Gets a reading stream for a content file
public static Stream GetFileStream(string type, string id)
Parameters
Returns
- Stream
The absolute path to the requested content file
Exceptions
- FileNotFoundException
The specified file could not be found.
- IOException
There was an error reading the file.
- UnauthorizedAccessException
Read access to the file is not permitted.