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