mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-04-21 21:05:50 +12:00
Refactor Rust::Result
into std::expected
The standard library already has support for this type as of C++23: https://en.cppreference.com/w/cpp/header/expected [This is also supported by all major compilers](https://en.cppreference.com/w/cpp/compiler_support#:~:text=Yes-,%3Cexpected%3E,-P0323R12%0AP2549R1)
This commit is contained in:
parent
57193e7944
commit
3d0a0ccc0b
21 changed files with 349 additions and 1621 deletions
|
@ -2,11 +2,13 @@
|
|||
#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) {}
|
||||
public:
|
||||
ExtSaveDataArchive(Memory& mem, const std::string& folder, bool isShared = false) : ArchiveBase(mem), isShared(isShared), backingFolder(folder) {}
|
||||
|
||||
u64 getFreeBytes() override { Helpers::panic("ExtSaveData::GetFreeBytes unimplemented"); return 0; }
|
||||
u64 getFreeBytes() override {
|
||||
Helpers::panic("ExtSaveData::GetFreeBytes unimplemented");
|
||||
return 0;
|
||||
}
|
||||
std::string name() override { return "ExtSaveData::" + backingFolder; }
|
||||
|
||||
HorizonResult createDirectory(const FSPath& path) override;
|
||||
|
@ -14,14 +16,14 @@ public:
|
|||
HorizonResult deleteFile(const FSPath& path) override;
|
||||
HorizonResult renameFile(const FSPath& oldPath, const FSPath& newPath) override;
|
||||
|
||||
Rust::Result<ArchiveBase*, HorizonResult> openArchive(const FSPath& path) override;
|
||||
Rust::Result<DirectorySession, HorizonResult> openDirectory(const FSPath& path) override;
|
||||
std::expected<ArchiveBase*, HorizonResult> openArchive(const FSPath& path) override;
|
||||
std::expected<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;
|
||||
|
||||
Rust::Result<FormatInfo, HorizonResult> getFormatInfo(const FSPath& path) override {
|
||||
std::expected<FormatInfo, HorizonResult> getFormatInfo(const FSPath& path) override {
|
||||
Helpers::warn("Stubbed ExtSaveData::GetFormatInfo");
|
||||
return Ok(FormatInfo{.size = 1_GB, .numOfDirectories = 255, .numOfFiles = 255, .duplicateData = false});
|
||||
return FormatInfo{.size = 1_GB, .numOfDirectories = 255, .numOfFiles = 255, .duplicateData = false};
|
||||
}
|
||||
|
||||
// Takes in a binary ExtSaveData path, outputs a combination of the backing folder with the low and high save entries of the path
|
||||
|
@ -29,5 +31,5 @@ public:
|
|||
std::string getExtSaveDataPathFromBinary(const FSPath& path);
|
||||
|
||||
bool isShared = false;
|
||||
std::string backingFolder; // Backing folder for the archive. Can be NAND, Gamecard or SD depending on the archive path.
|
||||
std::string backingFolder; // Backing folder for the archive. Can be NAND, Gamecard or SD depending on the archive path.
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue