mirror of
				https://github.com/PabloMK7/citra.git
				synced 2025-10-30 21:30:04 +00:00 
			
		
		
		
	Fixed file services serialization
This commit is contained in:
		
							parent
							
								
									c24ea0f0ee
								
							
						
					
					
						commit
						2217b3558d
					
				
					 6 changed files with 26 additions and 14 deletions
				
			
		|  | @ -881,8 +881,9 @@ std::string SanitizePath(std::string_view path_, DirectorySeparator directory_se | ||||||
| 
 | 
 | ||||||
| IOFile::IOFile() {} | IOFile::IOFile() {} | ||||||
| 
 | 
 | ||||||
| IOFile::IOFile(const std::string& filename, const char openmode[], int flags) { | IOFile::IOFile(const std::string& filename, const char openmode[], int flags) | ||||||
|     Open(filename, openmode, flags); |     : filename(filename), openmode(openmode), flags(flags) { | ||||||
|  |     Open(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| IOFile::~IOFile() { | IOFile::~IOFile() { | ||||||
|  | @ -906,13 +907,9 @@ void IOFile::Swap(IOFile& other) { | ||||||
|     std::swap(flags, other.flags); |     std::swap(flags, other.flags); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| bool IOFile::Open(const std::string& filename, const char openmode[], int flags) { | bool IOFile::Open() { | ||||||
|     Close(); |     Close(); | ||||||
| 
 | 
 | ||||||
|     this->filename = filename; |  | ||||||
|     this->openmode = openmode; |  | ||||||
|     this->flags = flags; |  | ||||||
| 
 |  | ||||||
| #ifdef _WIN32 | #ifdef _WIN32 | ||||||
|     if (flags != 0) { |     if (flags != 0) { | ||||||
|         m_file = _wfsopen(Common::UTF8ToUTF16W(filename).c_str(), |         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()); |                   Common::UTF8ToUTF16W(openmode).c_str()); | ||||||
|     } |     } | ||||||
| #else | #else | ||||||
|     m_file = fopen(filename.c_str(), openmode); |     m_file = fopen(filename.c_str(), openmode.c_str()); | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
|     m_good = IsOpen(); |     m_good = IsOpen(); | ||||||
|  |  | ||||||
|  | @ -306,7 +306,7 @@ public: | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| private: | private: | ||||||
|     bool Open(const std::string& filename, const char openmode[], int flags = 0); |     bool Open(); | ||||||
| 
 | 
 | ||||||
|     std::FILE* m_file = nullptr; |     std::FILE* m_file = nullptr; | ||||||
|     bool m_good = true; |     bool m_good = true; | ||||||
|  | @ -330,6 +330,7 @@ private: | ||||||
|         ar >> flags; |         ar >> flags; | ||||||
|         u64 pos; |         u64 pos; | ||||||
|         ar >> pos; |         ar >> pos; | ||||||
|  |         Open(); | ||||||
|         Seek(pos, SEEK_SET); |         Seek(pos, SEEK_SET); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -113,12 +113,16 @@ System::ResultStatus System::RunLoop(bool tight_loop) { | ||||||
|         return ResultStatus::ShutdownRequested; |         return ResultStatus::ShutdownRequested; | ||||||
|         break; |         break; | ||||||
|     case Signal::Load: { |     case Signal::Load: { | ||||||
|  |         LOG_INFO(Core, "Begin load"); | ||||||
|         auto stream = std::ifstream("save0.citrasave", std::fstream::binary); |         auto stream = std::ifstream("save0.citrasave", std::fstream::binary); | ||||||
|         System::Load(stream); |         System::Load(stream); | ||||||
|  |         LOG_INFO(Core, "Load completed"); | ||||||
|     } break; |     } break; | ||||||
|     case Signal::Save: { |     case Signal::Save: { | ||||||
|  |         LOG_INFO(Core, "Begin save"); | ||||||
|         auto stream = std::ofstream("save0.citrasave", std::fstream::binary); |         auto stream = std::ofstream("save0.citrasave", std::fstream::binary); | ||||||
|         System::Save(stream); |         System::Save(stream); | ||||||
|  |         LOG_INFO(Core, "Save completed"); | ||||||
|     } break; |     } break; | ||||||
|     default: |     default: | ||||||
|         break; |         break; | ||||||
|  |  | ||||||
|  | @ -19,11 +19,14 @@ void Directory::serialize(Archive& ar, const unsigned int) { | ||||||
|     ar& backend; |     ar& backend; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| Directory::Directory() : ServiceFramework("", 1) {} |  | ||||||
| 
 |  | ||||||
| Directory::Directory(std::unique_ptr<FileSys::DirectoryBackend>&& backend, | Directory::Directory(std::unique_ptr<FileSys::DirectoryBackend>&& backend, | ||||||
|                      const FileSys::Path& path) |                      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[] = { |     static const FunctionInfo functions[] = { | ||||||
|         // clang-format off
 |         // clang-format off
 | ||||||
|         {0x08010042, &Directory::Read, "Read"}, |         {0x08010042, &Directory::Read, "Read"}, | ||||||
|  |  | ||||||
|  | @ -26,11 +26,17 @@ void File::serialize(Archive& ar, const unsigned int) { | ||||||
|     ar& backend; |     ar& backend; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| File::File() : ServiceFramework("", 1), kernel(Core::Global<Kernel::KernelSystem>()) {} | File::File() : File(Core::Global<Kernel::KernelSystem>()) {} | ||||||
| 
 | 
 | ||||||
| File::File(Kernel::KernelSystem& kernel, std::unique_ptr<FileSys::FileBackend>&& backend, | File::File(Kernel::KernelSystem& kernel, std::unique_ptr<FileSys::FileBackend>&& backend, | ||||||
|            const FileSys::Path& path) |            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[] = { |     static const FunctionInfo functions[] = { | ||||||
|         {0x08010100, &File::OpenSubFile, "OpenSubFile"}, |         {0x08010100, &File::OpenSubFile, "OpenSubFile"}, | ||||||
|         {0x080200C2, &File::Read, "Read"}, |         {0x080200C2, &File::Read, "Read"}, | ||||||
|  |  | ||||||
|  | @ -74,6 +74,7 @@ private: | ||||||
| 
 | 
 | ||||||
|     Kernel::KernelSystem& kernel; |     Kernel::KernelSystem& kernel; | ||||||
| 
 | 
 | ||||||
|  |     File(Kernel::KernelSystem& kernel); | ||||||
|     File(); |     File(); | ||||||
| 
 | 
 | ||||||
|     template <class Archive> |     template <class Archive> | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue