Functions for managing resource types.
Namespace: | dmResource |
Include: | #include <dmsdk/resource/resource.hpp> |
TYPES | |
---|---|
FDecryptResource | Decrypts a file |
dmResource::Result AddFile(dmResource::HFactory factory, const char* path, uint32_t size, const void* resource)
Adds a file to the resource system Any request for this path will go through any existing mounts first. If you wish to provide file overrides, please use the LiveUpdate feature for that. The file isn't persisted between sessions.
PARAMETERS
dmResource::HFactory |
factory |
Factory handle |
const char* |
path |
The path of the resource |
uint32_t |
size |
The size of the resource (in bytes) |
const void* |
resource |
The resource payload |
RETURNS
dmResource::Result |
on success. |
dmResource::Result CreateResource(dmResource::HFactory factory, dmhash_t name, data, data_size, void** resource)
Creates and inserts a resource into the factory
PARAMETERS
dmResource::HFactory |
factory |
Factory handle |
dmhash_t |
name |
Resource name |
|
data |
Resource data |
|
data_size |
Resource data size |
void** |
resource |
(out) Created resource |
RETURNS
dmResource::Result |
RESULT_OK on success |
dmResource::Result Get(dmResource::HFactory factory, const char* name, void** resource)
Get a resource from factory
PARAMETERS
dmResource::HFactory |
factory |
Factory handle |
const char* |
name |
Resource name |
void** |
resource |
(out) Created resource |
RETURNS
dmResource::Result |
RESULT_OK on success |
dmResource::Result Get(dmResource::HFactory factory, dmhash_t name, void** resource)
Get a resource from factory
PARAMETERS
dmResource::HFactory |
factory |
Factory handle |
dmhash_t |
name |
Resource name |
void** |
resource |
(out) Created resource |
RETURNS
dmResource::Result |
RESULT_OK on success |
uint32_t GetCanonicalPath(const char* path, char* buf, uint32_t buf_len)
Gets the normalized resource path: "/my//icon.texturec" -> "/my/icon.texturec". "my/icon.texturec" -> "/my/icon.texturec".
PARAMETERS
const char* |
path |
the relative dir of the resource |
char* |
buf |
(out) the output of the normalization |
uint32_t |
buf_len |
the size of the output buffer |
RETURNS
uint32_t |
the length of the output string |
GetPath(dmResource::HFactory factory, const void* resource, uint64_t* hash)
Returns the canonical path hash of a resource
PARAMETERS
dmResource::HFactory |
factory |
Factory handle |
const void* |
resource |
Resource |
uint64_t* |
hash |
Returned hash |
RETURNS
|
on success |
dmResult::Result GetTypeFromExtension(dmResource::HFactory factory, const char* extension, HResourceType* type)
Get type from extension
PARAMETERS
dmResource::HFactory |
factory |
Factory handle |
const char* |
extension |
File extension, without leading "." character. E.g. "ttf" |
HResourceType* |
type |
returned type is successful |
RETURNS
dmResult::Result |
RESULT_OK on success |
dmResult::Result GetTypeFromExtensionHash(dmResource::HFactory factory, const char* extension_hash, HResourceType* type)
Get type from extension hash
PARAMETERS
dmResource::HFactory |
factory |
Factory handle |
const char* |
extension_hash |
Hash of file extension, without leading "." character. E.g. hash("ttf") |
HResourceType* |
type |
returned type is successful |
RETURNS
dmResult::Result |
RESULT_OK on success |
bool PreloadHint(dmResource::HResourcePreloadHintInfo factory, const char* name)
Hint the preloader what to load before Create is called on the resource. The resources are not guaranteed to be loaded before Create is called. This function can be called from a worker thread.
PARAMETERS
dmResource::HResourcePreloadHintInfo |
factory |
Preloader handle |
const char* |
name |
Resource name |
RETURNS
bool |
if successfully invoking preloader. |
void RegisterResourceDecryptionFunction(dmResource::FDecryptResource decrypt_resource)
Registers a custom resource decryption function
PARAMETERS
dmResource::FDecryptResource |
decrypt_resource |
The decryption function |
void RegisterResourceReloadedCallback(dmResource::HFactory factory, dmResource::FResourceReloadedCallback callback, void* user_data)
Function called when a resource has been reloaded.
PARAMETERS
dmResource::HFactory |
factory |
Handle of the factory to which the callback will be registered |
dmResource::FResourceReloadedCallback |
callback |
Callback function to register |
void* |
user_data |
User data that to |
void Release(dmResource::HFactory factory, void* resource)
Release resource
PARAMETERS
dmResource::HFactory |
factory |
Factory handle |
void* |
resource |
Resource pointer |
dmResource::Result RemoveFile(dmResource::HFactory factory, const char* path)
Removes a previously registered file from the resource system
PARAMETERS
dmResource::HFactory |
factory |
Factory handle |
const char* |
path |
The path of the resource |
RETURNS
dmResource::Result |
on success. |
Decrypts a file