C4 Engine
C4 Engine API Documentation

Resource::OpenLoader

Defined in:  C4Resources.h
Opens a loader object for a particular resource.
Prototype

ResourceResult OpenLoader(ResourceLoader *loader, ResourceLocation *location = nullptr);

Parameters
loader A pointer to a newly constructed loader object.
location If not nullptr, then the path to the directory containing the resource is returned here when the resource is loaded from the virtual catalog.
Description
The OpenLoader function opens a ResourceLoader object that can be used to read the data for a particular resource. Once the loader object is finished being used, it should be closed using the Resource::CloseLoader function.

If the loader object is successfully opened, then the return value is kResourceOkay. If the resource data does not exist, then the return value is kResourceNotFound.

Once a loader object is opened, the functions of the ResourceLoader class may be used to load resource data outside of the resource object. Alternatively, the Resource::LoadResource function may be used to load all of the resource data into the resource object. When a resource is created using the virtual catalog and the OpenLoader function is called with a location parameter that is not nullptr, then the path stored in the ResourceLocation object is set to the path to the folder containing the resource file. If the resource was loaded from a pack file, then the path is set to that of the pack file without the extension.
See Also

Resource::CloseLoader

Resource::LoadResource

ResourceLoader