diff --git a/src/common/file_util.cpp b/src/common/file_util.cpp index ca86f7bfc..c5da82973 100644 --- a/src/common/file_util.cpp +++ b/src/common/file_util.cpp @@ -881,8 +881,9 @@ std::string SanitizePath(std::string_view path_, DirectorySeparator directory_se IOFile::IOFile() {} -IOFile::IOFile(const std::string& filename, const char openmode[], int flags) { - Open(filename, openmode, flags); +IOFile::IOFile(const std::string& filename, const char openmode[], int flags) + : filename(filename), openmode(openmode), flags(flags) { + Open(); } IOFile::~IOFile() { @@ -906,13 +907,9 @@ void IOFile::Swap(IOFile& other) { std::swap(flags, other.flags); } -bool IOFile::Open(const std::string& filename, const char openmode[], int flags) { +bool IOFile::Open() { Close(); - this->filename = filename; - this->openmode = openmode; - this->flags = flags; - #ifdef _WIN32 if (flags != 0) { m_file = _wfsopen(Common::UTF8ToUTF16W(filename).c_str(), @@ -922,7 +919,7 @@ bool IOFile::Open(const std::string& filename, const char openmode[], int flags) Common::UTF8ToUTF16W(openmode).c_str()); } #else - m_file = fopen(filename.c_str(), openmode); + m_file = fopen(filename.c_str(), openmode.c_str()); #endif m_good = IsOpen(); diff --git a/src/common/file_util.h b/src/common/file_util.h index 71f943ed3..0368d3665 100644 --- a/src/common/file_util.h +++ b/src/common/file_util.h @@ -306,7 +306,7 @@ public: } private: - bool Open(const std::string& filename, const char openmode[], int flags = 0); + bool Open(); std::FILE* m_file = nullptr; bool m_good = true; @@ -330,6 +330,7 @@ private: ar >> flags; u64 pos; ar >> pos; + Open(); Seek(pos, SEEK_SET); } diff --git a/src/core/core.cpp b/src/core/core.cpp index fa60035dc..985d37291 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -113,12 +113,16 @@ System::ResultStatus System::RunLoop(bool tight_loop) { return ResultStatus::ShutdownRequested; break; case Signal::Load: { + LOG_INFO(Core, "Begin load"); auto stream = std::ifstream("save0.citrasave", std::fstream::binary); System::Load(stream); + LOG_INFO(Core, "Load completed"); } break; case Signal::Save: { + LOG_INFO(Core, "Begin save"); auto stream = std::ofstream("save0.citrasave", std::fstream::binary); System::Save(stream); + LOG_INFO(Core, "Save completed"); } break; default: break; diff --git a/src/core/hle/service/fs/directory.cpp b/src/core/hle/service/fs/directory.cpp index 16b12905c..c7fb085ea 100644 --- a/src/core/hle/service/fs/directory.cpp +++ b/src/core/hle/service/fs/directory.cpp @@ -19,11 +19,14 @@ void Directory::serialize(Archive& ar, const unsigned int) { ar& backend; } -Directory::Directory() : ServiceFramework("", 1) {} - Directory::Directory(std::unique_ptr&& backend, const FileSys::Path& path) - : ServiceFramework("", 1), path(path), backend(std::move(backend)) { + : Directory() { + this->backend = std::move(backend); + this->path = path; +} + +Directory::Directory() : ServiceFramework("", 1), path(""), backend(nullptr) { static const FunctionInfo functions[] = { // clang-format off {0x08010042, &Directory::Read, "Read"}, diff --git a/src/core/hle/service/fs/file.cpp b/src/core/hle/service/fs/file.cpp index b878197d7..e86d93723 100644 --- a/src/core/hle/service/fs/file.cpp +++ b/src/core/hle/service/fs/file.cpp @@ -26,11 +26,17 @@ void File::serialize(Archive& ar, const unsigned int) { ar& backend; } -File::File() : ServiceFramework("", 1), kernel(Core::Global()) {} +File::File() : File(Core::Global()) {} File::File(Kernel::KernelSystem& kernel, std::unique_ptr&& backend, const FileSys::Path& path) - : ServiceFramework("", 1), path(path), backend(std::move(backend)), kernel(kernel) { + : File(kernel) { + this->backend = std::move(backend); + this->path = path; +} + +File::File(Kernel::KernelSystem& kernel) + : ServiceFramework("", 1), path(""), backend(nullptr), kernel(kernel) { static const FunctionInfo functions[] = { {0x08010100, &File::OpenSubFile, "OpenSubFile"}, {0x080200C2, &File::Read, "Read"}, diff --git a/src/core/hle/service/fs/file.h b/src/core/hle/service/fs/file.h index 98d448755..6aa301a7b 100644 --- a/src/core/hle/service/fs/file.h +++ b/src/core/hle/service/fs/file.h @@ -74,6 +74,7 @@ private: Kernel::KernelSystem& kernel; + File(Kernel::KernelSystem& kernel); File(); template