Blamite Game Engine - blam!  00296.01.12.21.0102.blamite
The core library for the Blamite Game Engine.
cache.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <Windows.h>
4 #include <string>
5 #include <vector>
6 
7 #ifndef BLAM
8 #define BLAM
9 #endif
10 
11 #define CACHE_FOLDER "./cache/"
12 
13 
17 {
18  std::string id;
19  std::string old_address;
20  int size;
21  std::string path;
22 };
23 
24 namespace Blam
25 {
29  namespace Cache
30  {
31  // Writes a file to the cache.
32  std::string WriteFileToCache(void* data, int length, std::string id);
33 
34  // Retrieves a file from the cache.
35  // Ensure that you remember to call free(data) at some point before program exit!
36  HRESULT ReadFileFromCache(void** data, int* length, std::string id);
37 
38  // Deletes a specific file from the cache.
39  HRESULT DeleteFileFromCache(std::string id);
40 
41  // Deletes all files stored in the cache. This should only be run at engine shutdown.
42  void ClearCachedFiles();
43  }
44 }
Blam
Namespace surrounding all major engine components.
Definition: blam_api.h:18
Blam::Cache::ClearCachedFiles
void ClearCachedFiles()
Clears all files from the cache.
Definition: cache.cpp:107
Blam::Cache::WriteFileToCache
std::string WriteFileToCache(void *data, int length, std::string id)
Writes a block of data to the cache as a file.
Definition: cache.cpp:21
CachedDataFile::path
std::string path
The path to the cached file.
Definition: cache.h:21
Blam::Cache::DeleteFileFromCache
HRESULT DeleteFileFromCache(std::string id)
Deletes a file from the local cache storage.
Definition: cache.cpp:83
CachedDataFile::size
int size
The length of the data, in bytes.
Definition: cache.h:20
CachedDataFile
Structure to contain a cached data file.
Definition: cache.h:16
Blam::Cache::ReadFileFromCache
HRESULT ReadFileFromCache(void **data, int *length, std::string id)
Reads a file from the cache into memory.
Definition: cache.cpp:56
CachedDataFile::id
std::string id
The ID of the cached file.
Definition: cache.h:18
CachedDataFile::old_address
std::string old_address
The original address of the data when it was written to the cache.
Definition: cache.h:19