OmegaEngine API  1.0.3
Static Public Member Functions | Public Attributes | Properties | List of all members
OmegaEngine.Storage.ContentManager Class Reference

Provides a virtual file system for combining data from multiple directories and archives (useful for modding). More...

Static Public Member Functions

static void LoadArchives ()
 Loads any ArchiveFileExt archives in BaseDir and ModDir or specified by EnvVarNameBaseArchives or EnvVarNamerModArchives. More...
 
static void CloseArchives ()
 Closes the content archives loaded by LoadArchives. More...
 
static string CreateDirPath ([NotNull, Localizable(false)] string type)
 Creates a path for a content directory (using the ModDir if available). More...
 
static string CreateFilePath ([NotNull, Localizable(false)] string type, [NotNull, Localizable(false)] string id)
 Creates a path for a content file (using ModDir if available). More...
 
static bool FileExists ([NotNull, Localizable(false)] string type, [NotNull, Localizable(false)] string id, bool searchArchives=true)
 Checks whether a certain content file exists. More...
 
static NamedCollection< FileEntryGetFileList ([NotNull, Localizable(false)] string type, [NotNull, Localizable(false)] string extension)
 Gets a list of all files of a certain type More...
 
static string GetFilePath ([NotNull, Localizable(false)] string type, [NotNull, Localizable(false)] string id)
 Gets the file path for a content file (does not search in archives) More...
 
static Stream GetFileStream ([NotNull, Localizable(false)] string type, [NotNull, Localizable(false)] string id)
 Gets a reading stream for a content file (searches in archives) More...
 
static void DeleteModFile ([NotNull, Localizable(false)] string type, [NotNull, Localizable(false)] string id)
 Deletes a file in ModDir. Will not touch files in archives or in BaseDir. More...
 

Public Attributes

const string ArchiveFileExt = ".pk5"
 The file extensions of content archives. More...
 
const string EnvVarNameBaseDir = "CONTENTMANAGER_BASE_DIR"
 The name of an environment variable that can be used to configure the content manager externally. More...
 

Properties

static DirectoryInfo BaseDir [get, set]
 The base directory where all the content files are stored; should not be null. More...
 
static DirectoryInfo ModDir [get, set]
 A directory overriding the base directory for creating mods; can be null. More...
 

Detailed Description

Provides a virtual file system for combining data from multiple directories and archives (useful for modding).

Member Function Documentation

◆ CloseArchives()

static void OmegaEngine.Storage.ContentManager.CloseArchives ( )
inlinestatic

Closes the content archives loaded by LoadArchives.

◆ CreateDirPath()

static string OmegaEngine.Storage.ContentManager.CreateDirPath ( [NotNull, Localizable(false)] string  type)
inlinestatic

Creates a path for a content directory (using the ModDir if available).

Parameters
typeThe type of file (e.g. Textures, Sounds, ...).
Returns
The absolute path to the requested directory.
Exceptions
DirectoryNotFoundExceptionThe specified directory could not be found.

◆ CreateFilePath()

static string OmegaEngine.Storage.ContentManager.CreateFilePath ( [NotNull, Localizable(false)] string  type,
[NotNull, Localizable(false)] string  id 
)
inlinestatic

Creates a path for a content file (using ModDir if available).

Parameters
typeThe type of file (e.g. Textures, Sounds, ...).
idThe file name of the content.
Returns
The absolute path to the requested content file.

◆ DeleteModFile()

static void OmegaEngine.Storage.ContentManager.DeleteModFile ( [NotNull, Localizable(false)] string  type,
[NotNull, Localizable(false)] string  id 
)
inlinestatic

Deletes a file in ModDir. Will not touch files in archives or in BaseDir.

Parameters
typeThe type of file (e.g. Textures, Sounds, ...).
idThe file name of the content.
Exceptions
InvalidOperationExceptionModDir is not set.
FileNotFoundExceptionThe specified file could not be found.
IOExceptionThe specified file could not be deleted.
UnauthorizedAccessExceptionYou have insufficient rights to delete the file.

◆ FileExists()

static bool OmegaEngine.Storage.ContentManager.FileExists ( [NotNull, Localizable(false)] string  type,
[NotNull, Localizable(false)] string  id,
bool  searchArchives = true 
)
inlinestatic

Checks whether a certain content file exists.

Parameters
typeThe type of file (e.g. Textures, Sounds, ...).
idThe file name of the content.
searchArchivesWhether to search for the file in archives as well.
Returns
true if the requested content file exists.

◆ GetFileList()

static NamedCollection<FileEntry> OmegaEngine.Storage.ContentManager.GetFileList ( [NotNull, Localizable(false)] string  type,
[NotNull, Localizable(false)] string  extension 
)
inlinestatic

Gets a list of all files of a certain type

Parameters
typeThe type of files you want (e.g. Textures, Sounds, ...)
extensionThe file extension to so search for
Returns
An collection of strings with file IDs

◆ GetFilePath()

static string OmegaEngine.Storage.ContentManager.GetFilePath ( [NotNull, Localizable(false)] string  type,
[NotNull, Localizable(false)] string  id 
)
inlinestatic

Gets the file path for a content file (does not search in archives)

Parameters
typeThe type of file (e.g. Textures, Sounds, ...).
idThe file name of the content.
Returns
The absolute path to the requested content file
Exceptions
FileNotFoundExceptionThe specified file could not be found.

◆ GetFileStream()

static Stream OmegaEngine.Storage.ContentManager.GetFileStream ( [NotNull, Localizable(false)] string  type,
[NotNull, Localizable(false)] string  id 
)
inlinestatic

Gets a reading stream for a content file (searches in archives)

Parameters
typeThe type of file (e.g. Textures, Sounds, ...).
idThe file name of the content.
Returns
The absolute path to the requested content file
Exceptions
FileNotFoundExceptionThe specified file could not be found.
IOExceptionThere was an error reading the file.
UnauthorizedAccessExceptionRead access to the file is not permitted.

◆ LoadArchives()

static void OmegaEngine.Storage.ContentManager.LoadArchives ( )
inlinestatic

Loads any ArchiveFileExt archives in BaseDir and ModDir or specified by EnvVarNameBaseArchives or EnvVarNamerModArchives.

Member Data Documentation

◆ ArchiveFileExt

const string OmegaEngine.Storage.ContentManager.ArchiveFileExt = ".pk5"

The file extensions of content archives.

◆ EnvVarNameBaseDir

const string OmegaEngine.Storage.ContentManager.EnvVarNameBaseDir = "CONTENTMANAGER_BASE_DIR"

The name of an environment variable that can be used to configure the content manager externally.

Property Documentation

◆ BaseDir

DirectoryInfo OmegaEngine.Storage.ContentManager.BaseDir
staticgetset

The base directory where all the content files are stored; should not be null.

Can be set externally with EnvVarNameBaseDir.

Exceptions
DirectoryNotFoundExceptionThe specified directory could not be found.

◆ ModDir

DirectoryInfo OmegaEngine.Storage.ContentManager.ModDir
staticgetset

A directory overriding the base directory for creating mods; can be null.

Can be set externally with EnvVarNameModDir.

Exceptions
DirectoryNotFoundExceptionThe specified directory could not be found.

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