[FS] More concrete path impl

This commit is contained in:
wheremyfoodat 2023-01-14 01:46:48 +02:00
parent 1730ab9734
commit deaf7d518c
6 changed files with 55 additions and 21 deletions

View file

@ -11,12 +11,12 @@ bool ExtSaveDataArchive::openFile(const FSPath& path) {
}
ArchiveBase* ExtSaveDataArchive::openArchive(const FSPath& path) {
if (path.type != PathType::Binary || path.size != 12) {
if (path.type != PathType::Binary || path.binary.size() != 12) {
Helpers::panic("ExtSaveData accessed with an invalid path in OpenArchive");
}
u32 mediaType = mem.read32(path.pointer);
u64 saveID = mem.read64(path.pointer + 4);
u32 mediaType = *(u32*)&path.binary[0];
u64 saveID = *(u64*)&path.binary[4]; // TODO: Get rid of UB here.
Helpers::panic("ExtSaveData: media type = %d\n", mediaType);

View file

@ -7,13 +7,15 @@ bool SelfNCCHArchive::openFile(const FSPath& path) {
return false;
}
if (path.type != PathType::Binary) {
if (path.type != PathType::Binary || path.binary.size() != 12) {
printf("Invalid SelfNCCH path type\n");
return false;
}
// We currently only know how to read from an NCCH's RomFS
if (mem.read32(path.pointer) != 0) {
// Where to read the file from. (https://www.3dbrew.org/wiki/Filesystem_services#SelfNCCH_File_Path_Data_Format)
// We currently only know how to read from an NCCH's RomFS, ie type = 0
const u32 type = *(u32*)&path.binary[0]; // TODO: Get rid of UB here
if (type != 0) {
Helpers::panic("Read from NCCH's non-RomFS section!");
}

View file

@ -8,8 +8,8 @@ bool SaveDataArchive::openFile(const FSPath& path) {
return false;
}
if (path.type == PathType::UTF16 && mem.readString(path.pointer, path.size) == "/") {
printf("Reading root save data dir\n");
if (path.type == PathType::UTF16 /* && path.utf16_string == u"/game_header" */) {
printf("Opened file from the SaveData archive \n");
return true;
}