![]() |
XII Release 0.1.0
|
The base class for all data directory types. More...
#include <DataDirType.h>
Public Member Functions | |
const xiiString128 & | GetDataDirectoryPath () const |
Returns the absolute path to the data directory. | |
virtual const xiiString128 & | GetRedirectedDataDirectoryPath () const |
By default this is the same as GetDataDirectoryPath(), but derived implementations may use a different location where they actually get the files from. | |
virtual void | ReloadExternalConfigs () |
Some data directory types may use external configuration files (e.g. asset lookup tables) that may get updated, while the directory is mounted. This function allows each directory type to implement reloading and reapplying of configurations, without dismounting and remounting the data directory. | |
Protected Member Functions | |
xiiResult | InitializeDataDirectory (xiiStringView sDataDirPath) |
Tries to setup the data directory. Can fail, if the type is incorrect (e.g. a ZIP file data directory type cannot handle a simple folder and vice versa) | |
virtual xiiDataDirectoryReader * | OpenFileToRead (xiiStringView sFile, xiiFileShareMode::Enum FileShareMode, bool bSpecificallyThisDataDir)=0 |
Must be implemented to create a xiiDataDirectoryReader for accessing the given file. Returns nullptr if the file could not be opened. | |
virtual xiiDataDirectoryWriter * | OpenFileToWrite (xiiStringView sFile, xiiFileShareMode::Enum fileShareMode) |
Must be implemented to create a xiiDataDirectoryWriter for accessing the given file. Returns nullptr if the file could not be opened. | |
virtual void | RemoveDataDirectory ()=0 |
This function is called by the filesystem when a data directory is removed. | |
virtual void | DeleteFile (xiiStringView sFile) |
If a Data Directory Type supports it, this function will remove the given file from it. | |
virtual bool | ExistsFile (xiiStringView sFile, bool bOneSpecificDataDir) |
This function checks whether the given file exists in this data directory. | |
virtual xiiResult | GetFileStats (xiiStringView sFileOrFolder, bool bOneSpecificDataDir, xiiFileStats &out_Stats)=0 |
Upon success returns the xiiFileStats for a file in this data directory. | |
virtual bool | ResolveAssetRedirection (xiiStringView sPathOrAssetGuid, xiiStringBuilder &out_sRedirection) |
If this data directory knows how to redirect the given path, it should do so and return true. Called by xiiFileSystem::ResolveAssetRedirection. | |
virtual void | OnReaderWriterClose (xiiDataDirectoryReaderWriterBase *pClosed) |
This is automatically called whenever a xiiDataDirectoryReaderWriterBase that was opened by this type is being closed. | |
virtual xiiResult | InternalInitializeDataDirectory (xiiStringView sDirectory)=0 |
This function should only be used by a Factory (which should be a static function in the respective xiiDataDirectoryType). | |
Protected Attributes | |
xiiString128 | m_sDataDirectoryPath |
Derived classes can use 'GetDataDirectoryPath' to access this data. | |
Friends | |
class | xiiFileSystem |
class | xiiDataDirectoryReaderWriterBase |
The base class for all data directory types.
There are different data directory types, such as a simple folder, a ZIP file or some kind of library (e.g. image files from procedural data). Even a HTTP server that actually transmits files over a network can provided by implementing it as a data directory type. Data directories are added through xiiFileSystem, which uses factories to decide which xiiDataDirectoryType to use for handling which data directory.
|
inlineprotectedvirtual |
If a Data Directory Type supports it, this function will remove the given file from it.
Reimplemented in xiiDataDirectory::FileserveType, and xiiDataDirectory::FolderType.
|
protectedvirtual |
This function checks whether the given file exists in this data directory.
The default implementation simply calls xiiOSFile::ExistsFile An optimized implementation might look this information up in some hash-map.
Reimplemented in xiiDataDirectory::ArchiveType, xiiDataDirectory::FileserveType, and xiiDataDirectory::FolderType.
|
protectedpure virtual |
Upon success returns the xiiFileStats for a file in this data directory.
Implemented in xiiDataDirectory::ArchiveType, xiiDataDirectory::FileserveType, and xiiDataDirectory::FolderType.
|
inlinevirtual |
By default this is the same as GetDataDirectoryPath(), but derived implementations may use a different location where they actually get the files from.
Reimplemented in xiiDataDirectory::ArchiveType, and xiiDataDirectory::FolderType.
|
protectedpure virtual |
This function should only be used by a Factory (which should be a static function in the respective xiiDataDirectoryType).
It is used to initialize the data directory. If this xiiDataDirectoryType cannot handle the given type, it must return XII_FAILURE and the Factory needs to clean it up properly.
Implemented in xiiDataDirectory::ArchiveType, xiiDataDirectory::FileserveType, and xiiDataDirectory::FolderType.
|
inlineprotectedvirtual |
This is automatically called whenever a xiiDataDirectoryReaderWriterBase that was opened by this type is being closed.
It allows the xiiDataDirectoryType to return the reader/writer to a pool of reusable objects, or to destroy it using the proper allocator.
Reimplemented in xiiDataDirectory::ArchiveType, and xiiDataDirectory::FolderType.
|
protectedpure virtual |
Must be implemented to create a xiiDataDirectoryReader for accessing the given file. Returns nullptr if the file could not be opened.
szFile | is given as a path relative to the data directory's path. So unless the data directory path is empty, this will never be an absolute path. If a rooted path was given, the root name is also removed and only the relative part is passed along. |
bSpecificallyThisDataDir | This is true when the original path specified to open the file through exactly this data directory, by using a rooted path. If an absolute path is used, which incidentally matches the prefix of this data directory, bSpecificallyThisDataDir is NOT set to true, as there might be other data directories that also match. |
Implemented in xiiDataDirectory::ArchiveType, xiiDataDirectory::FileserveType, and xiiDataDirectory::FolderType.
|
inlineprotectedvirtual |
Must be implemented to create a xiiDataDirectoryWriter for accessing the given file. Returns nullptr if the file could not be opened.
If it always returns nullptr (default) the data directory is read-only (at least through this type).
Reimplemented in xiiDataDirectory::FileserveType, and xiiDataDirectory::FolderType.
|
inlinevirtual |
Some data directory types may use external configuration files (e.g. asset lookup tables) that may get updated, while the directory is mounted. This function allows each directory type to implement reloading and reapplying of configurations, without dismounting and remounting the data directory.
Reimplemented in xiiDataDirectory::FileserveType, and xiiDataDirectory::FolderType.
|
protectedpure virtual |
This function is called by the filesystem when a data directory is removed.
It should delete itself using the proper allocator.
Implemented in xiiDataDirectory::ArchiveType, xiiDataDirectory::FileserveType, and xiiDataDirectory::FolderType.
|
inlineprotectedvirtual |
If this data directory knows how to redirect the given path, it should do so and return true. Called by xiiFileSystem::ResolveAssetRedirection.
Reimplemented in xiiDataDirectory::FolderType.