Reorganize library code into libs/ (#3119)

* Reorganize files into libs/{dolphin,JSystem,PowerPC_EABI_Support,revolution,TRK_MINNOW_DOLPHIN}

* Update configure.py and project.py for new libs structure

* Refactor `#include <dolphin/x.h>` -> `<x.h>`

* Remove `__REVOLUTION_SDK__` forwards from dolphin

* Fix dolphin/ references in revolution

* Wrap `#include <dolphin.h>` in `!__REVOLUTION_SDK__`

* Always build TRK against dolphin headers

* Resolve revolution SDK header resolution issues
This commit is contained in:
Luke Street
2026-03-01 15:35:36 -07:00
committed by GitHub
parent c9a46bd65b
commit 4df8ccc871
1740 changed files with 583 additions and 825 deletions
+125
View File
@@ -0,0 +1,125 @@
#include "JSystem/JSystem.h" // IWYU pragma: keep
#include "JSystem/JKernel/JKRFileLoader.h"
#define MSL_USE_INLINES 1 // needed to inline tolower call. not inlined elsewhere in the repo
#include <cstring>
#include <cctype>
#include "global.h"
JKRFileLoader* JKRFileLoader::sCurrentVolume;
JSUList<JKRFileLoader> JKRFileLoader::sVolumeList;
JKRFileLoader::JKRFileLoader(void)
: mFileLoaderLink(this), mVolumeName(NULL), mVolumeType(0), mMountCount(0) {}
JKRFileLoader::~JKRFileLoader() {
if (sCurrentVolume == this) {
sCurrentVolume = NULL;
}
}
void JKRFileLoader::unmount(void) {
if (mMountCount != 0) {
if (--mMountCount == 0) {
delete this;
}
}
}
void* JKRFileLoader::getGlbResource(const char* name) {
JKRFileLoader* fileLoader = findVolume(&name);
void* resource;
if (fileLoader == NULL) {
return NULL;
} else {
resource = fileLoader->getResource(name);
return resource;
}
}
void* JKRFileLoader::getGlbResource(const char* name, JKRFileLoader* fileLoader) {
void* resource = NULL;
if (fileLoader) {
resource = fileLoader->getResource(0, name);
} else {
for (JSUListIterator<JKRFileLoader> iterator = sVolumeList.getFirst(); iterator != sVolumeList.getEnd(); ++iterator) {
resource = iterator->getResource(0, name);
if (resource)
break;
}
}
return resource;
}
bool JKRFileLoader::removeResource(void* resource, JKRFileLoader* fileLoader) {
if (fileLoader) {
return fileLoader->removeResource(resource);
}
for (JSUListIterator<JKRFileLoader> iterator = sVolumeList.getFirst(); iterator != sVolumeList.getEnd(); ++iterator) {
if (iterator->removeResource(resource)) {
return true;
}
}
return false;
}
bool JKRFileLoader::detachResource(void* resource, JKRFileLoader* fileLoader) {
if (fileLoader) {
return fileLoader->detachResource(resource);
}
for (JSUListIterator<JKRFileLoader> iterator = sVolumeList.getFirst(); iterator != sVolumeList.getEnd(); ++iterator) {
if (iterator->detachResource(resource)) {
return true;
}
}
return false;
}
JKRFileLoader* JKRFileLoader::findVolume(const char** volumeName) {
if (*volumeName[0] != '/') {
return sCurrentVolume;
}
char volumeNameBuffer[0x101];
*volumeName = fetchVolumeName(volumeNameBuffer, ARRAY_SIZEU(volumeNameBuffer), *volumeName);
for (JSUListIterator<JKRFileLoader> iterator = sVolumeList.getFirst(); iterator != sVolumeList.getEnd(); ++iterator) {
if (strcmp(volumeNameBuffer, iterator->mVolumeName) == 0) {
return iterator.getObject();
}
}
return NULL;
}
const char* JKRFileLoader::fetchVolumeName(char* buffer, s32 bufferSize, const char* path) {
static char rootPath[2] = "/";
if (strcmp(path, "/") == 0) {
strcpy(buffer, rootPath);
return rootPath;
}
path++;
while (*path != 0 && *path != '/') {
if (1 < bufferSize) {
*buffer = tolower(*path);
buffer++;
bufferSize--;
}
path++;
}
*buffer = '\0';
if (*path == '\0') {
path = rootPath;
}
return path;
}