Utility class to manage various forms of file caching. Disabled by default.
More...
#include <FileCache.h>
|
int | getFile (const string &filename, string &outFilePath) |
|
int | getFile (const string &domain, const string &filename, string &outFilePath) |
|
|
static int | makeFileCache (const string &app, const string &parentFolder={}) |
|
static void | disableFileCache () |
| To disable the file cache. Safe to call even if not enabled.
|
|
static FileCache * | getFileCache () |
|
|
| FileCache (string mainFolder) |
|
Utility class to manage various forms of file caching. Disabled by default.
There is a main file cache, which needs to be created for file caching to be enabled.
◆ getFile() [1/2]
int vrs::FileCache::getFile |
( |
const string & |
domain, |
|
|
const string & |
filename, |
|
|
string & |
outFilePath |
|
) |
| |
Look-up a file in the cache, specifying a domain. Useful, if you want to cache a bunch of derived objects from a particular object, placing all those cached objects in a folder named after the main object.
- Parameters
-
domain | the primary domain. Might be an identifier for a specific VRS file... |
filename | a filename for the object. |
outFilePath | a path to the object in the cache. |
- Returns
- 0 if the file exists, and outFilePath has been set. Returns FILE_NOT_FOUND if the file doesn't exist, and outFilePath has been set, for you to add the object in the cache at that location. Returns another error code and outFilePath isn't set, if some error occurred, and the object doesn't exist and can't be created, maybe because some files or folders are in the way.
◆ getFile() [2/2]
int vrs::FileCache::getFile |
( |
const string & |
filename, |
|
|
string & |
outFilePath |
|
) |
| |
Look-up a file in the cache.
- Parameters
-
filename | a filename for the object. |
outFilePath | a path to the object in the cache. |
- Returns
- 0 if the file exists, and outFilePath has been set. Returns FILE_NOT_FOUND if the file doesn't exist, and outFilePath has been set, for you to add the object in the cache at that location. Returns another error code and outFilePath isn't set, if some error occurred, and the object doesn't exist and can't be created, maybe because some files or folders are in the way.
◆ getFileCache()
Get file cache, if one has been created.
- Returns
- The existing file cache, or nullptr if none was created.
◆ makeFileCache()
int vrs::FileCache::makeFileCache |
( |
const string & |
app, |
|
|
const string & |
parentFolder = {} |
|
) |
| |
|
static |
Make the file cache. You need to create it to enable caching features. Note that there is only one of these file cache in any running app, but there could be multiple ones in the file system.
- Parameters
-
app | name for the app, to have its own space, maybe shared with other apps of the same team. VRS apps like VRStool & VRSplayer will use kDefaultVrsAppsCache. |
parentFolder | an optional cache folder location. If empty, the cache will be created in the home folder. |
- Returns
- A status code, 0 meaning success.
The documentation for this class was generated from the following files: