mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-04-19 20:19:13 +12:00
Update ExtData branch to current codebase
Co-Authored-By: Ada Ahmed <ada@chronovore.dev>
This commit is contained in:
parent
7257f34ff5
commit
667717ef91
7 changed files with 290 additions and 52 deletions
|
@ -64,6 +64,14 @@ namespace ArchiveID {
|
|||
}
|
||||
} // namespace ArchiveID
|
||||
|
||||
namespace MediaType {
|
||||
enum : u8 {
|
||||
NAND = 0,
|
||||
SD = 1,
|
||||
Gamecard = 2,
|
||||
};
|
||||
};
|
||||
|
||||
struct FSPath {
|
||||
u32 type = PathType::Invalid;
|
||||
|
||||
|
@ -246,6 +254,16 @@ class ArchiveBase {
|
|||
return Result::FS::AlreadyExists;
|
||||
}
|
||||
|
||||
virtual HorizonResult deleteDirectory(const FSPath& path) {
|
||||
Helpers::warn("Stubbed DeleteDirectory for %s archive", name().c_str());
|
||||
return Result::Success;
|
||||
}
|
||||
|
||||
virtual HorizonResult deleteDirectoryRecursively(const FSPath& path) {
|
||||
Helpers::warn("Stubbed DeleteDirectoryRecursively for %s archive", name().c_str());
|
||||
return Result::Success;
|
||||
}
|
||||
|
||||
// Returns nullopt if opening the file failed, otherwise returns a file descriptor to it (nullptr if none is needed)
|
||||
virtual FileDescriptor openFile(const FSPath& path, const FilePerms& perms) = 0;
|
||||
virtual Rust::Result<ArchiveBase*, HorizonResult> openArchive(const FSPath& path) = 0;
|
||||
|
|
|
@ -1,15 +1,33 @@
|
|||
#pragma once
|
||||
#include <unordered_map>
|
||||
|
||||
#include "archive_base.hpp"
|
||||
|
||||
class ExtSaveDataArchive : public ArchiveBase {
|
||||
public:
|
||||
ExtSaveDataArchive(Memory& mem, const std::string& folder, bool isShared = false) : ArchiveBase(mem),
|
||||
isShared(isShared), backingFolder(folder) {}
|
||||
#pragma pack(push, 1)
|
||||
struct ExtSaveDataInfo {
|
||||
u8 media_type;
|
||||
u8 unknown;
|
||||
u16 reserved;
|
||||
u64 save_id;
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
u64 getFreeBytes() override { Helpers::panic("ExtSaveData::GetFreeBytes unimplemented"); return 0; }
|
||||
std::string name() override { return "ExtSaveData::" + backingFolder; }
|
||||
class ExtSaveDataArchive : public ArchiveBase {
|
||||
public:
|
||||
ExtSaveDataArchive(Memory& mem, const std::string& folder, u64 saveId, bool isShared = false, bool isNAND = false)
|
||||
: ArchiveBase(mem), archiveSaveId(saveId), isShared(isShared), isNAND(isNAND), backingFolder(folder) {}
|
||||
|
||||
u64 getFreeBytes() override {
|
||||
Helpers::panic("ExtSaveData::GetFreeBytes unimplemented");
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::string name() override { return "ExtSaveData::" + backingFolder + "::" + std::to_string(archiveSaveId); }
|
||||
|
||||
HorizonResult createDirectory(const FSPath& path) override;
|
||||
HorizonResult deleteDirectory(const FSPath& path) override;
|
||||
HorizonResult deleteDirectoryRecursively(const FSPath& path) override;
|
||||
|
||||
HorizonResult createFile(const FSPath& path, u64 size) override;
|
||||
HorizonResult deleteFile(const FSPath& path) override;
|
||||
HorizonResult renameFile(const FSPath& oldPath, const FSPath& newPath) override;
|
||||
|
@ -19,15 +37,22 @@ public:
|
|||
FileDescriptor openFile(const FSPath& path, const FilePerms& perms) override;
|
||||
std::optional<u32> readFile(FileSession* file, u64 offset, u32 size, u32 dataPointer) override;
|
||||
|
||||
Rust::Result<FormatInfo, HorizonResult> getFormatInfo(const FSPath& path) override {
|
||||
Helpers::warn("Stubbed ExtSaveData::GetFormatInfo");
|
||||
return Ok(FormatInfo{.size = 1_GB, .numOfDirectories = 255, .numOfFiles = 255, .duplicateData = false});
|
||||
}
|
||||
void format(const FSPath& path, const FormatInfo& info) override;
|
||||
void clear(const FSPath& path) const;
|
||||
|
||||
Rust::Result<FormatInfo, HorizonResult> getFormatInfo(const FSPath& path) override;
|
||||
std::filesystem::path getFormatInfoPath(const FSPath& path) const;
|
||||
std::filesystem::path getUserDataPath() const;
|
||||
std::string getExtSaveDataPathFromBinary(const FSPath& path) const;
|
||||
std::string getExtSaveDataPath() const;
|
||||
|
||||
// Takes in a binary ExtSaveData path, outputs a combination of the backing folder with the low and high save entries of the path
|
||||
// Used for identifying the archive format info files
|
||||
std::string getExtSaveDataPathFromBinary(const FSPath& path);
|
||||
|
||||
u64 archiveSaveId = 0;
|
||||
bool isShared = false;
|
||||
std::string backingFolder; // Backing folder for the archive. Can be NAND, Gamecard or SD depending on the archive path.
|
||||
bool isNAND = false;
|
||||
|
||||
std::string backingFolder; // Backing folder for the archive. Can be NAND, Gamecard or SD depending on the archive path.
|
||||
};
|
|
@ -1,4 +1,6 @@
|
|||
#pragma once
|
||||
#include <unordered_map>
|
||||
|
||||
#include "config.hpp"
|
||||
#include "fs/archive_card_spi.hpp"
|
||||
#include "fs/archive_ext_save_data.hpp"
|
||||
|
@ -37,16 +39,20 @@ class FSService {
|
|||
// UserSaveData archives
|
||||
UserSaveDataArchive userSaveData1;
|
||||
UserSaveDataArchive userSaveData2;
|
||||
|
||||
ExtSaveDataArchive extSaveData_sdmc;
|
||||
ExtSaveDataArchive sharedExtSaveData_nand;
|
||||
SystemSaveDataArchive systemSaveData;
|
||||
|
||||
TWLPhotoArchive twlPhoto;
|
||||
TWLSoundArchive twlSound;
|
||||
CardSPIArchive cardSpi;
|
||||
|
||||
std::unordered_map<u64, ExtSaveDataArchive> extSaveData_sdmc;
|
||||
std::unordered_map<u64, ExtSaveDataArchive> nandExtSaveData_nand;
|
||||
|
||||
|
||||
ArchiveBase* getArchiveFromID(u32 id, const FSPath& archivePath);
|
||||
ExtSaveDataArchive* getExtArchiveFromID(u64 saveId, bool isShared);
|
||||
ExtSaveDataArchive* getNANDExtArchiveFromID(u64 saveId, bool isShared);
|
||||
|
||||
Rust::Result<Handle, HorizonResult> openArchiveHandle(u32 archiveID, const FSPath& path);
|
||||
Rust::Result<Handle, HorizonResult> openDirectoryHandle(ArchiveBase* archive, const FSPath& path);
|
||||
std::optional<Handle> openFileHandle(ArchiveBase* archive, const FSPath& path, const FSPath& archivePath, const FilePerms& perms);
|
||||
|
@ -63,6 +69,8 @@ class FSService {
|
|||
void closeArchive(u32 messagePointer);
|
||||
void controlArchive(u32 messagePointer);
|
||||
void deleteDirectory(u32 messagePointer);
|
||||
void deleteDirectoryRecursively(u32 messagePointer);
|
||||
|
||||
void deleteExtSaveData(u32 messagePointer);
|
||||
void deleteFile(u32 messagePointer);
|
||||
void formatSaveData(u32 messagePointer);
|
||||
|
@ -86,14 +94,14 @@ class FSService {
|
|||
void setArchivePriority(u32 messagePointer);
|
||||
void setPriority(u32 messagePointer);
|
||||
void setThisSaveDataSecureValue(u32 messagePointer);
|
||||
void readExtSaveDataIcon(u32 messagePointer);
|
||||
|
||||
// Used for set/get priority: Not sure what sort of priority this is referring to
|
||||
u32 priority;
|
||||
|
||||
public:
|
||||
FSService(Memory& mem, Kernel& kernel, const EmulatorConfig& config)
|
||||
: mem(mem), saveData(mem), sharedExtSaveData_nand(mem, "../SharedFiles/NAND", true), extSaveData_sdmc(mem, "SDMC"), sdmc(mem),
|
||||
sdmcWriteOnly(mem, true), selfNcch(mem), ncch(mem), userSaveData1(mem, ArchiveID::UserSaveData1),
|
||||
: mem(mem), saveData(mem), sdmc(mem), sdmcWriteOnly(mem, true), selfNcch(mem), ncch(mem), userSaveData1(mem, ArchiveID::UserSaveData1),
|
||||
userSaveData2(mem, ArchiveID::UserSaveData2), systemSaveData(mem), twlPhoto(mem), twlSound(mem), cardSpi(mem), kernel(kernel),
|
||||
config(config) {}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue