Pyrogenesis  trunk
Public Member Functions | Private Attributes | List of all members
CCacheLoader Class Reference

Helper class for systems that have an expensive cacheable conversion process when loading files. More...

#include <CacheLoader.h>

Public Member Functions

 CCacheLoader (PIVFS vfs, const std::wstring &fileExtension)
 
Status TryLoadingCached (const VfsPath &sourcePath, const MD5 &initialHash, u32 version, VfsPath &loadPath)
 Attempts to find a valid cached which can be loaded. More...
 
bool CanUseArchiveCache (const VfsPath &sourcePath, const VfsPath &archiveCachePath)
 Determines whether we can safely use the archived cache file, or need to re-convert the source file. More...
 
VfsPath ArchiveCachePath (const VfsPath &sourcePath) const
 Return the path of the archive cache for the given source file. More...
 
VfsPath LooseCachePath (const VfsPath &sourcePath, const MD5 &initialHash, u32 version)
 Return the path of the loose cache for the given source file. More...
 

Private Attributes

PIVFS m_VFS
 
std::wstring m_FileExtension
 

Detailed Description

Helper class for systems that have an expensive cacheable conversion process when loading files.

Conversion output can be automatically cached as loose files, indexed by a hash of the file's timestamp and size plus any other data the caller provides. This allows developers and modders to easily produce new files, with the conversion happening transparently.

For release packages, files can be precached by appending ".cached.{extension}" to their name, which will be used instead of doing runtime conversion. These cache files will typically be packed into an archive for faster loading; if no archive cache is available then the source file will be converted and stored as a loose cache file instead.

Constructor & Destructor Documentation

◆ CCacheLoader()

CCacheLoader::CCacheLoader ( PIVFS  vfs,
const std::wstring &  fileExtension 
)

Member Function Documentation

◆ ArchiveCachePath()

VfsPath CCacheLoader::ArchiveCachePath ( const VfsPath sourcePath) const

Return the path of the archive cache for the given source file.

◆ CanUseArchiveCache()

bool CCacheLoader::CanUseArchiveCache ( const VfsPath sourcePath,
const VfsPath archiveCachePath 
)

Determines whether we can safely use the archived cache file, or need to re-convert the source file.

◆ LooseCachePath()

VfsPath CCacheLoader::LooseCachePath ( const VfsPath sourcePath,
const MD5 initialHash,
u32  version 
)

Return the path of the loose cache for the given source file.

◆ TryLoadingCached()

Status CCacheLoader::TryLoadingCached ( const VfsPath sourcePath,
const MD5 initialHash,
u32  version,
VfsPath loadPath 
)

Attempts to find a valid cached which can be loaded.

Returns INFO::OK and sets loadPath to the cached file if there is one. Returns INFO::SKIPPED and sets loadPath to the desire loose cache name if there isn't one. Returns a value < 0 on error (e.g. the source file doesn't exist). No error is logged or thrown.

Member Data Documentation

◆ m_FileExtension

std::wstring CCacheLoader::m_FileExtension
private

◆ m_VFS

PIVFS CCacheLoader::m_VFS
private

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