Pyrogenesis  13997
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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)
 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.

Definition at line 40 of file CacheLoader.h.

Constructor & Destructor Documentation

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

Definition at line 27 of file CacheLoader.cpp.

Member Function Documentation

VfsPath CCacheLoader::ArchiveCachePath ( const VfsPath sourcePath)

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

Definition at line 112 of file CacheLoader.cpp.

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.

Definition at line 71 of file CacheLoader.cpp.

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

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

Definition at line 117 of file CacheLoader.cpp.

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.

Definition at line 32 of file CacheLoader.cpp.

Member Data Documentation

std::wstring CCacheLoader::m_FileExtension
private

Definition at line 71 of file CacheLoader.h.

PIVFS CCacheLoader::m_VFS
private

Definition at line 70 of file CacheLoader.h.


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