diff options
| author | 2018-03-04 13:03:58 -0500 | |
|---|---|---|
| committer | 2018-03-04 14:30:07 -0500 | |
| commit | 0eefe6e4d15cbc7a5902dfbe5e7742ef4ea71902 (patch) | |
| tree | d6fbf1e18b6b17fcb089306af26c48331100814c /src/core/file_sys | |
| parent | Merge pull request #226 from Subv/buffer_queue_event (diff) | |
| download | yuzu-0eefe6e4d15cbc7a5902dfbe5e7742ef4ea71902.tar.gz yuzu-0eefe6e4d15cbc7a5902dfbe5e7742ef4ea71902.tar.xz yuzu-0eefe6e4d15cbc7a5902dfbe5e7742ef4ea71902.zip | |
FS: Make EnsureSaveData create the savedata folder when called for the first time.
Diffstat (limited to 'src/core/file_sys')
| -rw-r--r-- | src/core/file_sys/filesystem.h | 3 | ||||
| -rw-r--r-- | src/core/file_sys/romfs_factory.cpp | 2 | ||||
| -rw-r--r-- | src/core/file_sys/romfs_factory.h | 2 | ||||
| -rw-r--r-- | src/core/file_sys/savedata_factory.cpp | 34 | ||||
| -rw-r--r-- | src/core/file_sys/savedata_factory.h | 4 |
5 files changed, 30 insertions, 15 deletions
diff --git a/src/core/file_sys/filesystem.h b/src/core/file_sys/filesystem.h index df4e66a0b..94ad2abf2 100644 --- a/src/core/file_sys/filesystem.h +++ b/src/core/file_sys/filesystem.h | |||
| @@ -183,10 +183,9 @@ public: | |||
| 183 | /** | 183 | /** |
| 184 | * Deletes the archive contents and then re-creates the base folder | 184 | * Deletes the archive contents and then re-creates the base folder |
| 185 | * @param path Path to the archive | 185 | * @param path Path to the archive |
| 186 | * @param format_info Format information for the new archive | ||
| 187 | * @return ResultCode of the operation, 0 on success | 186 | * @return ResultCode of the operation, 0 on success |
| 188 | */ | 187 | */ |
| 189 | virtual ResultCode Format(const Path& path, const FileSys::ArchiveFormatInfo& format_info) = 0; | 188 | virtual ResultCode Format(const Path& path) = 0; |
| 190 | 189 | ||
| 191 | /** | 190 | /** |
| 192 | * Retrieves the format info about the archive with the specified path | 191 | * Retrieves the format info about the archive with the specified path |
diff --git a/src/core/file_sys/romfs_factory.cpp b/src/core/file_sys/romfs_factory.cpp index e0de49f05..b21427948 100644 --- a/src/core/file_sys/romfs_factory.cpp +++ b/src/core/file_sys/romfs_factory.cpp | |||
| @@ -23,7 +23,7 @@ ResultVal<std::unique_ptr<FileSystemBackend>> RomFS_Factory::Open(const Path& pa | |||
| 23 | return MakeResult<std::unique_ptr<FileSystemBackend>>(std::move(archive)); | 23 | return MakeResult<std::unique_ptr<FileSystemBackend>>(std::move(archive)); |
| 24 | } | 24 | } |
| 25 | 25 | ||
| 26 | ResultCode RomFS_Factory::Format(const Path& path, const FileSys::ArchiveFormatInfo& format_info) { | 26 | ResultCode RomFS_Factory::Format(const Path& path) { |
| 27 | LOG_ERROR(Service_FS, "Unimplemented Format archive %s", GetName().c_str()); | 27 | LOG_ERROR(Service_FS, "Unimplemented Format archive %s", GetName().c_str()); |
| 28 | // TODO(bunnei): Find the right error code for this | 28 | // TODO(bunnei): Find the right error code for this |
| 29 | return ResultCode(-1); | 29 | return ResultCode(-1); |
diff --git a/src/core/file_sys/romfs_factory.h b/src/core/file_sys/romfs_factory.h index 10ea13966..e0698e642 100644 --- a/src/core/file_sys/romfs_factory.h +++ b/src/core/file_sys/romfs_factory.h | |||
| @@ -23,7 +23,7 @@ public: | |||
| 23 | return "ArchiveFactory_RomFS"; | 23 | return "ArchiveFactory_RomFS"; |
| 24 | } | 24 | } |
| 25 | ResultVal<std::unique_ptr<FileSystemBackend>> Open(const Path& path) override; | 25 | ResultVal<std::unique_ptr<FileSystemBackend>> Open(const Path& path) override; |
| 26 | ResultCode Format(const Path& path, const FileSys::ArchiveFormatInfo& format_info) override; | 26 | ResultCode Format(const Path& path) override; |
| 27 | ResultVal<ArchiveFormatInfo> GetFormatInfo(const Path& path) const override; | 27 | ResultVal<ArchiveFormatInfo> GetFormatInfo(const Path& path) const override; |
| 28 | 28 | ||
| 29 | private: | 29 | private: |
diff --git a/src/core/file_sys/savedata_factory.cpp b/src/core/file_sys/savedata_factory.cpp index 4d83e100f..c3329ce52 100644 --- a/src/core/file_sys/savedata_factory.cpp +++ b/src/core/file_sys/savedata_factory.cpp | |||
| @@ -17,20 +17,26 @@ SaveData_Factory::SaveData_Factory(std::string nand_directory) | |||
| 17 | : nand_directory(std::move(nand_directory)) {} | 17 | : nand_directory(std::move(nand_directory)) {} |
| 18 | 18 | ||
| 19 | ResultVal<std::unique_ptr<FileSystemBackend>> SaveData_Factory::Open(const Path& path) { | 19 | ResultVal<std::unique_ptr<FileSystemBackend>> SaveData_Factory::Open(const Path& path) { |
| 20 | u64 title_id = Kernel::g_current_process->program_id; | 20 | std::string save_directory = GetFullPath(); |
| 21 | // TODO(Subv): Somehow obtain this value. | 21 | // Return an error if the save data doesn't actually exist. |
| 22 | u32 user = 0; | 22 | if (!FileUtil::IsDirectory(save_directory)) { |
| 23 | std::string save_directory = Common::StringFromFormat("%ssave/%016" PRIX64 "/%08X", | 23 | // TODO(Subv): Find out correct error code. |
| 24 | nand_directory.c_str(), title_id, user); | 24 | return ResultCode(-1); |
| 25 | } | ||
| 26 | |||
| 25 | auto archive = std::make_unique<Disk_FileSystem>(save_directory); | 27 | auto archive = std::make_unique<Disk_FileSystem>(save_directory); |
| 26 | return MakeResult<std::unique_ptr<FileSystemBackend>>(std::move(archive)); | 28 | return MakeResult<std::unique_ptr<FileSystemBackend>>(std::move(archive)); |
| 27 | } | 29 | } |
| 28 | 30 | ||
| 29 | ResultCode SaveData_Factory::Format(const Path& path, | 31 | ResultCode SaveData_Factory::Format(const Path& path) { |
| 30 | const FileSys::ArchiveFormatInfo& format_info) { | 32 | LOG_WARNING(Service_FS, "Format archive %s", GetName().c_str()); |
| 31 | LOG_ERROR(Service_FS, "Unimplemented Format archive %s", GetName().c_str()); | 33 | // Create the save data directory. |
| 32 | // TODO(bunnei): Find the right error code for this | 34 | if (!FileUtil::CreateFullPath(GetFullPath())) { |
| 33 | return ResultCode(-1); | 35 | // TODO(Subv): Find the correct error code. |
| 36 | return ResultCode(-1); | ||
| 37 | } | ||
| 38 | |||
| 39 | return RESULT_SUCCESS; | ||
| 34 | } | 40 | } |
| 35 | 41 | ||
| 36 | ResultVal<ArchiveFormatInfo> SaveData_Factory::GetFormatInfo(const Path& path) const { | 42 | ResultVal<ArchiveFormatInfo> SaveData_Factory::GetFormatInfo(const Path& path) const { |
| @@ -39,4 +45,12 @@ ResultVal<ArchiveFormatInfo> SaveData_Factory::GetFormatInfo(const Path& path) c | |||
| 39 | return ResultCode(-1); | 45 | return ResultCode(-1); |
| 40 | } | 46 | } |
| 41 | 47 | ||
| 48 | std::string SaveData_Factory::GetFullPath() const { | ||
| 49 | u64 title_id = Kernel::g_current_process->program_id; | ||
| 50 | // TODO(Subv): Somehow obtain this value. | ||
| 51 | u32 user = 0; | ||
| 52 | return Common::StringFromFormat("%ssave/%016" PRIX64 "/%08X/", nand_directory.c_str(), title_id, | ||
| 53 | user); | ||
| 54 | } | ||
| 55 | |||
| 42 | } // namespace FileSys | 56 | } // namespace FileSys |
diff --git a/src/core/file_sys/savedata_factory.h b/src/core/file_sys/savedata_factory.h index 726743fde..73a42aab6 100644 --- a/src/core/file_sys/savedata_factory.h +++ b/src/core/file_sys/savedata_factory.h | |||
| @@ -21,11 +21,13 @@ public: | |||
| 21 | return "SaveData_Factory"; | 21 | return "SaveData_Factory"; |
| 22 | } | 22 | } |
| 23 | ResultVal<std::unique_ptr<FileSystemBackend>> Open(const Path& path) override; | 23 | ResultVal<std::unique_ptr<FileSystemBackend>> Open(const Path& path) override; |
| 24 | ResultCode Format(const Path& path, const FileSys::ArchiveFormatInfo& format_info) override; | 24 | ResultCode Format(const Path& path) override; |
| 25 | ResultVal<ArchiveFormatInfo> GetFormatInfo(const Path& path) const override; | 25 | ResultVal<ArchiveFormatInfo> GetFormatInfo(const Path& path) const override; |
| 26 | 26 | ||
| 27 | private: | 27 | private: |
| 28 | std::string nand_directory; | 28 | std::string nand_directory; |
| 29 | |||
| 30 | std::string GetFullPath() const; | ||
| 29 | }; | 31 | }; |
| 30 | 32 | ||
| 31 | } // namespace FileSys | 33 | } // namespace FileSys |