mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-04-11 08:39:48 +12:00
ExtSaveData pls
This commit is contained in:
parent
1d6235c903
commit
e9a8c2cb2e
3 changed files with 18 additions and 30 deletions
|
@ -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<Handle, FSResult> 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)
|
||||
{}
|
||||
|
||||
|
|
|
@ -100,12 +100,13 @@ Rust::Result<ArchiveBase*, FSResult> 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);
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue