Blamite Game Engine - blam!  00296.01.12.21.0102.blamite
The core library for the Blamite Game Engine.
Blam::Cache Namespace Reference

Namespace containing functions related to caching. More...

Functions

std::string WriteFileToCache (void *data, int length, std::string id)
 Writes a block of data to the cache as a file. More...
 
HRESULT ReadFileFromCache (void **data, int *length, std::string id)
 Reads a file from the cache into memory. More...
 
HRESULT DeleteFileFromCache (std::string id)
 Deletes a file from the local cache storage. More...
 
void ClearCachedFiles ()
 Clears all files from the cache. More...
 

Detailed Description

Namespace containing functions related to caching.

Function Documentation

◆ ClearCachedFiles()

void Blam::Cache::ClearCachedFiles ( )

Clears all files from the cache.

Will log to console if any files failed to be removed.

◆ DeleteFileFromCache()

HRESULT Blam::Cache::DeleteFileFromCache ( std::string  id)

Deletes a file from the local cache storage.

Will log an error to console if the file could not be removed.

◆ ReadFileFromCache()

HRESULT Blam::Cache::ReadFileFromCache ( void **  data,
int *  length,
std::string  id 
)

Reads a file from the cache into memory.

Memory allocation does not need to be performed prior to calling, as this function will call malloc() on its own.

Parameters
data- Pointer at which to write the memory.
length- Pointer at which to store the size of the data.
id- The ID of the cached data to read
Returns
- Returns S_OK if the file was loaded without error, will return E_FAIL if no cached file could be found with the specified ID.

◆ WriteFileToCache()

std::string Blam::Cache::WriteFileToCache ( void *  data,
int  length,
std::string  id 
)

Writes a block of data to the cache as a file.

Parameters
data- The data to put in the file
length- The size of the data in bytes
id- The ID of the cached data, used to retrieve the file later on
Returns
- The path of the cached file