From e9a8c2cb2e16c729d2ee775d3028d6d96145a5d1 Mon Sep 17 00:00:00 2001 From: wheremyfoodat Date: Sat, 3 Jun 2023 22:04:26 +0300 Subject: [PATCH] ExtSaveData pls --- include/services/fs.hpp | 8 +++---- src/core/fs/archive_ext_save_data.cpp | 9 ++++---- src/core/services/fs.cpp | 31 +++++++++------------------ 3 files changed, 18 insertions(+), 30 deletions(-) diff --git a/include/services/fs.hpp b/include/services/fs.hpp index b4cc1fb6..93e28d18 100644 --- a/include/services/fs.hpp +++ b/include/services/fs.hpp @@ -25,10 +25,8 @@ class FSService { SDMCArchive sdmc; NCCHArchive ncch; - ExtSaveDataArchive extSaveData_nand; - ExtSaveDataArchive extSaveData_cart; + ExtSaveDataArchive extSaveData_sdmc; ExtSaveDataArchive sharedExtSaveData_nand; - ExtSaveDataArchive sharedExtSaveData_cart; ArchiveBase* getArchiveFromID(u32 id, const FSPath& archivePath); Rust::Result openArchiveHandle(u32 archiveID, const FSPath& path); @@ -60,8 +58,8 @@ class FSService { u32 priority; public: - FSService(Memory& mem, Kernel& kernel) : mem(mem), saveData(mem), extSaveData_nand(mem, "NAND"), - sharedExtSaveData_nand(mem, "NAND", true), extSaveData_cart(mem, "CartSave"), sharedExtSaveData_cart(mem, "CartSave", true), + FSService(Memory& mem, Kernel& kernel) : mem(mem), saveData(mem), + sharedExtSaveData_nand(mem, "../SharedFiles/NAND", true), extSaveData_sdmc(mem, "SDMC"), sdmc(mem), selfNcch(mem), ncch(mem), kernel(kernel) {} diff --git a/src/core/fs/archive_ext_save_data.cpp b/src/core/fs/archive_ext_save_data.cpp index 788fd251..bb7ce1a7 100644 --- a/src/core/fs/archive_ext_save_data.cpp +++ b/src/core/fs/archive_ext_save_data.cpp @@ -100,12 +100,13 @@ Rust::Result ExtSaveDataArchive::openArchive(const FSPat Helpers::panic("ExtSaveData accessed with an invalid path in OpenArchive"); } + // TODO: Readd the format check. I didn't manage to fix it sadly // Create a format info path in the style of AppData/FormatInfo/Cartridge10390390194.format - fs::path formatInfopath = IOFile::getAppData() / "FormatInfo" / (getExtSaveDataPathFromBinary(path) + ".format"); + // fs::path formatInfopath = IOFile::getAppData() / "FormatInfo" / (getExtSaveDataPathFromBinary(path) + ".format"); // Format info not found so the archive is not formatted - if (!fs::is_regular_file(formatInfopath)) { - return isShared ? Err(FSResult::NotFormatted) : Err(FSResult::NotFoundInvalid); - } + // if (!fs::is_regular_file(formatInfopath)) { + // return isShared ? Err(FSResult::NotFormatted) : Err(FSResult::NotFoundInvalid); + //} return Ok((ArchiveBase*)this); } diff --git a/src/core/services/fs.cpp b/src/core/services/fs.cpp index 9aebe375..fe8bce8d 100644 --- a/src/core/services/fs.cpp +++ b/src/core/services/fs.cpp @@ -46,19 +46,20 @@ void FSService::reset() { // Creates directories for NAND, ExtSaveData, etc if they don't already exist. Should be executed after loading a new ROM. void FSService::initializeFilesystem() { - const auto nandPath = IOFile::getAppData() / "NAND"; // Create NAND - const auto cartPath = IOFile::getAppData() / "CartSave"; // Create cartridge save folder for use with ExtSaveData + const auto sdmcPath = IOFile::getAppData() / "SDMC"; // Create SDMC directory + const auto nandSharedpath = IOFile::getAppData() / ".." / "SharedFiles" / "NAND"; + const auto savePath = IOFile::getAppData() / "SaveData"; // Create SaveData const auto formatPath = IOFile::getAppData() / "FormatInfo"; // Create folder for storing archive formatting info namespace fs = std::filesystem; - // TODO: SDMC, etc - if (!fs::is_directory(nandPath)) { - fs::create_directories(nandPath); + + if (!fs::is_directory(nandSharedpath)) { + fs::create_directories(nandSharedpath); } - if (!fs::is_directory(cartPath)) { - fs::create_directories(cartPath); + if (!fs::is_directory(sdmcPath)) { + fs::create_directories(sdmcPath); } if (!fs::is_directory(savePath)) { @@ -75,22 +76,10 @@ ArchiveBase* FSService::getArchiveFromID(u32 id, const FSPath& archivePath) { case ArchiveID::SelfNCCH: return &selfNcch; case ArchiveID::SaveData: return &saveData; case ArchiveID::ExtSaveData: - if (archivePath.type == PathType::Binary) { - switch (archivePath.binary[0]) { - case 0: return &extSaveData_nand; - case 2: return &extSaveData_cart; - } - } - return nullptr; + return &extSaveData_sdmc; case ArchiveID::SharedExtSaveData: - if (archivePath.type == PathType::Binary) { - switch (archivePath.binary[0]) { - case 0: return &sharedExtSaveData_nand; - case 2: return &sharedExtSaveData_cart; - } - } - return nullptr; + return &sharedExtSaveData_nand; case ArchiveID::SDMC: return &sdmc; case ArchiveID::SavedataAndNcch: return &ncch; // This can only access NCCH outside of FSPXI