[FS] Better GetFormatInfo

This commit is contained in:
wheremyfoodat 2023-05-20 15:39:31 +03:00
parent 01d16fdfd1
commit 4767a2053b
4 changed files with 34 additions and 11 deletions

View file

@ -204,10 +204,11 @@ public:
virtual u64 getFreeBytes() = 0;
virtual FSResult createFile(const FSPath& path, u64 size) = 0;
virtual FSResult deleteFile(const FSPath& path) = 0;
virtual FormatInfo getFormatInfo(const FSPath& path) {
virtual Rust::Result<FormatInfo, FSResult> getFormatInfo(const FSPath& path) {
Helpers::panic("Unimplemented GetFormatInfo for %s archive", name().c_str());
// Return a dummy struct just to avoid the UB of not returning anything, even if we panic
return FormatInfo{ .size = 0, .numOfDirectories = 0, .numOfFiles = 0, .duplicateData = false };
return Ok(FormatInfo{ .size = 0, .numOfDirectories = 0, .numOfFiles = 0, .duplicateData = false });
}
virtual FSResult createDirectory(const FSPath& path) {

View file

@ -18,7 +18,7 @@ public:
std::optional<u32> readFile(FileSession* file, u64 offset, u32 size, u32 dataPointer) override;
void format(const FSPath& path, const FormatInfo& info) override;
FormatInfo getFormatInfo(const FSPath& path) override;
Rust::Result<FormatInfo, FSResult> getFormatInfo(const FSPath& path) override;
std::filesystem::path getFormatInfoPath() {
return IOFile::getAppData() / "FormatInfo" / "SaveData.format";