![]() |
ezEngine
Release 25.03
|
The base class for all data directory types. More...
#include <DataDirType.h>
Public Member Functions | |
const ezString128 & | GetDataDirectoryPath () const |
Returns the absolute path to the data directory. | |
virtual const ezString128 & | 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 | |
ezResult | InitializeDataDirectory (ezStringView 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 ezDataDirectoryReader * | OpenFileToRead (ezStringView sFile, ezFileShareMode::Enum FileShareMode, bool bSpecificallyThisDataDir)=0 |
Must be implemented to create a ezDataDirectoryReader for accessing the given file. Returns nullptr if the file could not be opened. More... | |
virtual ezDataDirectoryWriter * | OpenFileToWrite (ezStringView sFile, ezFileShareMode::Enum FileShareMode) |
Must be implemented to create a ezDataDirectoryWriter for accessing the given file. Returns nullptr if the file could not be opened. More... | |
virtual void | RemoveDataDirectory ()=0 |
This function is called by the filesystem when a data directory is removed. More... | |
virtual void | DeleteFile (ezStringView sFile) |
If a Data Directory Type supports it, this function will remove the given file from it. | |
virtual bool | ExistsFile (ezStringView sFile, bool bOneSpecificDataDir) |
This function checks whether the given file exists in this data directory. More... | |
virtual ezResult | GetFileStats (ezStringView sFileOrFolder, bool bOneSpecificDataDir, ezFileStats &out_Stats)=0 |
Upon success returns the ezFileStats for a file in this data directory. | |
virtual bool | ResolveAssetRedirection (ezStringView sPathOrAssetGuid, ezStringBuilder &out_sRedirection) |
If this data directory knows how to redirect the given path, it should do so and return true. Called by ezFileSystem::ResolveAssetRedirection. | |
virtual void | OnReaderWriterClose (ezDataDirectoryReaderWriterBase *pClosed) |
This is automatically called whenever a ezDataDirectoryReaderWriterBase that was opened by this type is being closed. More... | |
virtual ezResult | InternalInitializeDataDirectory (ezStringView sDirectory)=0 |
This function should only be used by a Factory (which should be a static function in the respective ezDataDirectoryType). More... | |
Protected Attributes | |
ezString128 | m_sDataDirectoryPath |
Derived classes can use 'GetDataDirectoryPath' to access this data. | |
Friends | |
class | ezFileSystem |
class | ezDataDirectoryReaderWriterBase |
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 ezFileSystem, which uses factories to decide which ezDataDirectoryType to use for handling which data directory.
|
protectedvirtual |
This function checks whether the given file exists in this data directory.
The default implementation simply calls ezOSFile::ExistsFile An optimized implementation might look this information up in some hash-map.
Reimplemented in ezDataDirectory::FolderType, ezDataDirectory::FileserveType, and ezDataDirectory::ArchiveType.
|
protectedpure virtual |
This function should only be used by a Factory (which should be a static function in the respective ezDataDirectoryType).
It is used to initialize the data directory. If this ezDataDirectoryType cannot handle the given type, it must return EZ_FAILURE and the Factory needs to clean it up properly.
Implemented in ezDataDirectory::FolderType, ezDataDirectory::FileserveType, and ezDataDirectory::ArchiveType.
|
inlineprotectedvirtual |
This is automatically called whenever a ezDataDirectoryReaderWriterBase that was opened by this type is being closed.
It allows the ezDataDirectoryType to return the reader/writer to a pool of reusable objects, or to destroy it using the proper allocator.
Reimplemented in ezDataDirectory::FolderType, and ezDataDirectory::ArchiveType.
|
protectedpure virtual |
Must be implemented to create a ezDataDirectoryReader 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 ezDataDirectory::FolderType, ezDataDirectory::FileserveType, and ezDataDirectory::ArchiveType.
|
inlineprotectedvirtual |
Must be implemented to create a ezDataDirectoryWriter 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 ezDataDirectory::FolderType, and ezDataDirectory::FileserveType.
|
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 ezDataDirectory::FolderType, ezDataDirectory::FileserveType, and ezDataDirectory::ArchiveType.