From 876835852d0b0fe59997347f4f3d956a5a0c2bb7 Mon Sep 17 00:00:00 2001 From: wheremyfoodat Date: Sun, 2 Apr 2023 01:21:19 +0300 Subject: [PATCH] [SaveData] Implement OpenDirectory with filename --- include/fs/archive_base.hpp | 3 ++- src/core/fs/archive_save_data.cpp | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/include/fs/archive_base.hpp b/include/fs/archive_base.hpp index 9f2cf43d..eaa55006 100644 --- a/include/fs/archive_base.hpp +++ b/include/fs/archive_base.hpp @@ -132,7 +132,8 @@ enum class FSResult : u32 { Success = 0, AlreadyExists = 0x82044BE, FileTooLarge = 0x86044D2, - FileNotFound = 0xC8804470 + FileNotFound = 0xC8804470, + UnexpectedFileOrDir = 0xE0C04702 }; class ArchiveBase { diff --git a/src/core/fs/archive_save_data.cpp b/src/core/fs/archive_save_data.cpp index 499036fd..e6aa0db1 100644 --- a/src/core/fs/archive_save_data.cpp +++ b/src/core/fs/archive_save_data.cpp @@ -66,8 +66,10 @@ Rust::Result SaveDataArchive::openDirectory(const FS fs::path p = IOFile::getAppData() / "SaveData"; p += fs::path(path.utf16_string).make_preferred(); - if (fs::is_regular_file(p)) - Helpers::panic("OpenDirectory: Tried to open directory but it's actually a file"); + if (fs::is_regular_file(p)) { + printf("SaveData: OpenArchive used with a file path"); + return Err(FSResult::UnexpectedFileOrDir); + } if (fs::is_directory(p)) { return Ok(DirectorySession(this, p));