ezEngine  Milestone 7
ezDataDirectoryType Class Referenceabstract

The base class for all data directory types. More...

#include <DataDirType.h>

Inheritance diagram for ezDataDirectoryType:

Public Member Functions

const ezString128GetDataDirectoryPath () const
 Returns the absolute path to the data directory.
 
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 (const char *szDataDirPath)
 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 ezDataDirectoryReaderOpenFileToRead (const char *szFile)=0
 Must be implemented to create a ezDataDirectoryReader for accessing the given file. Returns nullptr if the file could not be opened.
 
virtual ezDataDirectoryWriterOpenFileToWrite (const char *szFile)
 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 (const char *szFile)
 If a Data Directory Type supports it, this function will remove the given file from it.
 
virtual bool ExistsFile (const char *szFile)
 This function checks whether the given file exists in this data directory. More...
 

Private Member Functions

 EZ_DISALLOW_COPY_AND_ASSIGN (ezDataDirectoryType)
 
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 (const char *szDirectory)=0
 This function should only be used by a Factory (which should be a static function in the respective ezDataDirectoryType). More...
 

Private Attributes

ezString128 m_sDataDirectoryPath
 Derived classes can use 'GetDataDirectoryPath' to access this data.
 

Friends

class ezFileSystem
 
class ezDataDirectoryReaderWriterBase
 

Detailed Description

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.

Member Function Documentation

bool ezDataDirectoryType::ExistsFile ( const char *  szFile)
protectedvirtual

This function checks whether the given file exists in this data directory.

The default implementation will simply try to open the file for reading. An optimized implementation might look this information up in some hash-map.

virtual ezResult ezDataDirectoryType::InternalInitializeDataDirectory ( const char *  szDirectory)
privatepure 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.

virtual void ezDataDirectoryType::OnReaderWriterClose ( ezDataDirectoryReaderWriterBase pClosed)
inlineprivatevirtual

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.

virtual ezDataDirectoryWriter* ezDataDirectoryType::OpenFileToWrite ( const char *  szFile)
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.

virtual void ezDataDirectoryType::RemoveDataDirectory ( )
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.


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