1#include <game/bases/d_res.hpp>
2#include <game/mLib/m_heap.hpp>
3#include <lib/rvl/vi/VI.h>
4#include <lib/rvl/os/OSCache.h>
5#include <lib/MSL_C/string.h>
18 if (!mpDvdCmd->mDone) {
22 }
while (!mpDvdCmd->mDone);
29 if (mpDvdCmd !=
nullptr) {
30 if (!mpDvdCmd->mDone) {
33 mpArchive = mpDvdCmd->mpArchive;
34 mpArcBinary = mpDvdCmd->getArcBinary();
35 mpMountHeap = mpDvdCmd->mpHeap;
36 mArchiveSize = mpDvdCmd->mArchiveSize;
43 if (mpArchive !=
nullptr) {
44 if (mDataHeap !=
nullptr) {
45 mHeap::destroyFrmHeap(mDataHeap);
55 if (mpArcBinary !=
nullptr) {
56 EGG::Heap::free(mpArcBinary,
nullptr);
58 mpArcBinary =
nullptr;
65 snprintf(pathBuf,
sizeof(pathBuf),
"/%s/%s.arc", containingFolder, arcName);
66 mpDvdCmd = mDvd_mountMemArchive_c::create(pathBuf, allocDir, heap);
68 if (mpDvdCmd ==
nullptr) {
72 strncpy(mName, arcName,
sizeof(mName));
80 if (mpArchive ==
nullptr) {
81 if (mpDvdCmd ==
nullptr) {
84 if (!mpDvdCmd->mDone) {
85 return LOAD_IN_PROGRESS;
89 mpArchive = mpDvdCmd->mpArchive;
90 mpArcBinary = mpDvdCmd->getArcBinary();
91 mpMountHeap = mpDvdCmd->mpHeap;
92 mArchiveSize = mpDvdCmd->mArchiveSize;
96 if (mpArchive ==
nullptr) {
101 EGG::Heap *heap = (mpMountHeap !=
nullptr) ? mpMountHeap : mHeap::g_gameHeaps[0];
102 mDataHeap = mHeap::makeFrmHeapAndUpdate(-1, heap,
"dRes_c::info_c::mDataHeap", 0x20, 0);
103 if (mDataHeap ==
nullptr) {
110 mHeap::restoreCurrentHeap();
111 mHeap::adjustFrmHeap(mDataHeap);
112 if (resStatus == LOAD_ERROR) {
117 DCStoreRangeNoSync(mDataHeap, (
size_t) mDataHeap->mpHeapHead->mpHeapEnd - (
size_t) mDataHeap);
124 if (dirEntry->mIsDirectory) {
126 const char *name = dirEntry->mpName;
128 int nameLen = strlen(name);
129 memcpy(&mFolderSig, name, (nameLen <= 4) ? nameLen : 4);
133 if (mFileIdx < mNumFiles) {
134 mpFiles[mFileIdx++] = cbRes;
144 int numFiles = mpArchive->countFile();
145 mpFiles =
new u8 *[numFiles];
146 if (mpFiles ==
nullptr) {
151 for (
unsigned int i = 0; i < numFiles; i++) {
152 mpFiles[i] =
nullptr;
155 if (callback !=
nullptr) {
157 callback->
init(mName);
162 mpArchive->getFileArray(mpFiles, numFiles);
A callback class for processing resources.
virtual void init(const char *name)=0
Initializes the callback with the resource name.
virtual void * execute(void *data, u32 folderSig, const char *path)=0
Executes the callback.
bool set(const char *arcName, const char *containingFolder, u8 allocDirection, EGG::Heap *heap)
Sets information about the archive to be loaded.
~info_c()
Destroys the archive holder.
LOAD_STATUS_e
The loading status of the archive.
info_c()
Constructs a new archive holder.
LOAD_STATUS_e loadRes(callback_c *callback)
Builds the resource list and executes a callback on each file and directory.
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.
A callback class for EGG::Archive::searchInside.
static void callback(void *cbInfo, void *file, const ARCDirEntry *dirEntry, const char *path)
The callback function.
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.