1#include <game/bases/d_res.hpp>
2#include <lib/MSL_C/string.h>
35 if (info ==
nullptr) {
38 if (info ==
nullptr) {
41 if (!info->
set(arcName, containingFolder, allocDir, heap)) {
52 if (info ==
nullptr) {
57 if (info->getRefCount() == 0) {
67 if (info !=
nullptr && info->
getArchive() !=
nullptr) {
68 data = info->
getArchive()->getFile(resPath,
nullptr);
73void *
dRes_c::getRes(
const char *arcName,
const char *resPath,
unsigned long *size)
const {
77 if (info !=
nullptr && info->
getArchive() !=
nullptr) {
80 data = archive->getFile(resPath, &fi);
81 newSize = fi.mFileSize;
87void *
dRes_c::getRes(
const char *arcName,
const char *resPath,
unsigned long *size,
int *compressionType)
const {
91 if (info !=
nullptr && info->
getArchive() !=
nullptr) {
93 long entryID = archive->convertPathToEntryID(resPath);
97 data = archive->getFileFast(entryID, &fi);
99 if (data !=
nullptr) {
100 if (compressionType !=
nullptr) {
103 if (size !=
nullptr) {
104 *size = fi.mFileSize;
110 snprintf(path,
sizeof(path),
"%s.LZ", resPath);
111 entryID = archive->convertPathToEntryID(path);
114 data = archive->getFileFast(entryID,
nullptr);
116 if (data !=
nullptr) {
117 if (compressionType !=
nullptr) {
118 *compressionType = ((u8 *) data)[0] & 0xF0;
120 if (size !=
nullptr) {
121 *size = CXGetUncompressedSize(data);
131 memcpy(to, from, size);
138 CXUncompressLZ(from, to);
143 void *data =
nullptr;
146 if (info !=
nullptr && info->
getArchive() !=
nullptr) {
148 long entryID = archive->convertPathToEntryID(resPath);
152 data = archive->getFileFast(entryID,
nullptr);
160 void *data =
nullptr;
164 if (info !=
nullptr && info->
getArchive() !=
nullptr) {
166 long entryID = archive->convertPathToEntryID(resPath);
171 data = archive->getFileFast(entryID, &fi);
172 newSize = fi.mFileSize;
183 for (
int i = 0; i <
mNumArcs; i++) {
197 for (
int i = 0; i < count; i++) {
198 if (info->getRefCount() > 0 && strcmp(arcName, info->getName()) == 0) {
208 for (
int i = 0; i <
mNumArcs; i++) {
210 if (info->getRefCount() == 0) {
220 if (info ==
nullptr) {
@ CX_COMPRESSION_NONE
No compression.
A callback class for processing resources.
bool set(const char *arcName, const char *containingFolder, u8 allocDirection, EGG::Heap *heap)
Sets information about the archive to be loaded.
mDvd_mountMemArchive_c * getDvdCmd() const
Gets the file loading command.
@ LOAD_SUCCESS
The archive was loaded successfully.
void decRefCount()
Decrements the reference count.
void incRefCount()
Increments the reference count.
EGG::Archive * getArchive() const
Gets the archive accessor.
bool cleanup()
Unmounts the archive and frees the holder for use.
LOAD_STATUS_e setRes(callback_c *callback)
Attempts to load the archive into memory and load the resources with a callback.
~dRes_c()
Destroys the manager.
info_c * newResInfo()
Gets a free archive holder that can be used to store an archive reference.
u16 mNumArcs
The number of archive holders.
dRes_c()
Constructs a new manager.
static void copyRes(const void *from, void *to, int size)
Copies an uncompressed resource.
info_c * getResInfoLoaded(const char *arcName) const
Gets the holder for a loaded archive.
static void(* mSetCallback)(const char *arcName, EGG::Heap *heap)
[Unused]. The callback for when an archive is scheduled for loading.
callback_c * mpCallback
The callback for when a resource is loaded.
bool syncAllRes()
Attempts to load the resources of an archive that has finished loading since the last call to this fu...
bool deleteRes(const char *arcName)
Marks an archive as no longer needed.
void * getRes(const char *arcName, const char *resPath) const
Gets a resource.
info_c * mpArcInfos
An array of archive holders.
void * getResSilently(const char *arcName, const char *resPath) const
Gets a resource without logging a message if the resource is not found.
bool setRes(const char *arcName, const char *containingFolder, u8 allocDir, EGG::Heap *heap)
Schedules an archive for loading.
bool init(u16 maxCount, callback_c *callback)
Initializes the manager by allocating the archive holders and setting the callback.
info_c * getResInfo(const char *arcName) const
Gets the holder for an archive.