Partially implement ExtSaveData

This commit is contained in:
Ada 2024-03-07 15:37:43 +00:00
parent 24705fe67e
commit a4e44cf060
No known key found for this signature in database
GPG key ID: 066E56D5C9F4E50D
5 changed files with 188 additions and 30 deletions

View file

@ -228,9 +228,19 @@ public:
return Ok(FormatInfo{ .size = 0, .numOfDirectories = 0, .numOfFiles = 0, .duplicateData = false });
}
virtual HorizonResult createDirectory(const FSPath& path) {
Helpers::panic("Unimplemented CreateDirectory for %s archive", name().c_str());
return Result::FS::AlreadyExists;
virtual HorizonResult createDirectory(const FSPath& path) {
Helpers::panic("Unimplemented CreateDirectory for %s archive", name().c_str());
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)
@ -263,4 +273,4 @@ struct ArchiveResource {
u32 clusterSize; // Size of a cluster in bytes
u32 partitionCapacityInClusters;
u32 freeSpaceInClusters;
};
};

View file

@ -10,6 +10,8 @@ public:
std::string name() override { return "ExtSaveData::" + backingFolder; }
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;
@ -18,16 +20,16 @@ public:
Rust::Result<DirectorySession, HorizonResult> openDirectory(const FSPath& path) override;
FileDescriptor openFile(const FSPath& path, const FilePerms& perms) override;
std::optional<u32> readFile(FileSession* file, u64 offset, u32 size, u32 dataPointer) override;
void format(const FSPath& path, const FormatInfo& info) override;
Rust::Result<FormatInfo, HorizonResult> getFormatInfo(const FSPath& path) 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});
}
std::filesystem::path getFormatInfoPath(const FSPath& path) const;
std::filesystem::path getUserDataPath() 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);
std::string getExtSaveDataPathFromBinary(const FSPath& path) const;
bool isShared = false;
std::string backingFolder; // Backing folder for the archive. Can be NAND, Gamecard or SD depending on the archive path.
};
};