diff options
| author | 2018-03-19 21:17:15 -0500 | |
|---|---|---|
| committer | 2018-03-19 21:17:15 -0500 | |
| commit | c4ca802b9dc7f0d3f3aed5aa937240bf85370c15 (patch) | |
| tree | 12199ad7acfb7b1b886eda7ad01d968e10c9051c | |
| parent | Merge pull request #251 from Subv/tic_tsc (diff) | |
| download | yuzu-c4ca802b9dc7f0d3f3aed5aa937240bf85370c15.tar.gz yuzu-c4ca802b9dc7f0d3f3aed5aa937240bf85370c15.tar.xz yuzu-c4ca802b9dc7f0d3f3aed5aa937240bf85370c15.zip | |
FS: Added an SDMC archive factory and registered it to the SDMC archive on startup.
| -rw-r--r-- | src/core/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | src/core/file_sys/sdmc_factory.cpp | 40 | ||||
| -rw-r--r-- | src/core/file_sys/sdmc_factory.h | 31 | ||||
| -rw-r--r-- | src/core/hle/service/filesystem/filesystem.cpp | 5 | ||||
| -rw-r--r-- | src/core/hle/service/filesystem/filesystem.h | 1 |
5 files changed, 79 insertions, 0 deletions
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index faaa50e4d..d2275d9a9 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt | |||
| @@ -22,6 +22,8 @@ add_library(core STATIC | |||
| 22 | file_sys/romfs_filesystem.h | 22 | file_sys/romfs_filesystem.h |
| 23 | file_sys/savedata_factory.cpp | 23 | file_sys/savedata_factory.cpp |
| 24 | file_sys/savedata_factory.h | 24 | file_sys/savedata_factory.h |
| 25 | file_sys/sdmc_factory.cpp | ||
| 26 | file_sys/sdmc_factory.h | ||
| 25 | file_sys/storage.h | 27 | file_sys/storage.h |
| 26 | frontend/emu_window.cpp | 28 | frontend/emu_window.cpp |
| 27 | frontend/emu_window.h | 29 | frontend/emu_window.h |
diff --git a/src/core/file_sys/sdmc_factory.cpp b/src/core/file_sys/sdmc_factory.cpp new file mode 100644 index 000000000..00e80d2a7 --- /dev/null +++ b/src/core/file_sys/sdmc_factory.cpp | |||
| @@ -0,0 +1,40 @@ | |||
| 1 | // Copyright 2018 yuzu emulator team | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #include <cinttypes> | ||
| 6 | #include <memory> | ||
| 7 | #include "common/common_types.h" | ||
| 8 | #include "common/logging/log.h" | ||
| 9 | #include "common/string_util.h" | ||
| 10 | #include "core/core.h" | ||
| 11 | #include "core/file_sys/disk_filesystem.h" | ||
| 12 | #include "core/file_sys/sdmc_factory.h" | ||
| 13 | |||
| 14 | namespace FileSys { | ||
| 15 | |||
| 16 | SDMC_Factory::SDMC_Factory(std::string sd_directory) : sd_directory(std::move(sd_directory)) {} | ||
| 17 | |||
| 18 | ResultVal<std::unique_ptr<FileSystemBackend>> SDMC_Factory::Open(const Path& path) { | ||
| 19 | // Create the SD Card directory if it doesn't already exist. | ||
| 20 | if (!FileUtil::IsDirectory(sd_directory)) { | ||
| 21 | FileUtil::CreateFullPath(sd_directory); | ||
| 22 | } | ||
| 23 | |||
| 24 | auto archive = std::make_unique<Disk_FileSystem>(sd_directory); | ||
| 25 | return MakeResult<std::unique_ptr<FileSystemBackend>>(std::move(archive)); | ||
| 26 | } | ||
| 27 | |||
| 28 | ResultCode SDMC_Factory::Format(const Path& path) { | ||
| 29 | LOG_ERROR(Service_FS, "Unimplemented Format archive %s", GetName().c_str()); | ||
| 30 | // TODO(Subv): Find the right error code for this | ||
| 31 | return ResultCode(-1); | ||
| 32 | } | ||
| 33 | |||
| 34 | ResultVal<ArchiveFormatInfo> SDMC_Factory::GetFormatInfo(const Path& path) const { | ||
| 35 | LOG_ERROR(Service_FS, "Unimplemented GetFormatInfo archive %s", GetName().c_str()); | ||
| 36 | // TODO(bunnei): Find the right error code for this | ||
| 37 | return ResultCode(-1); | ||
| 38 | } | ||
| 39 | |||
| 40 | } // namespace FileSys | ||
diff --git a/src/core/file_sys/sdmc_factory.h b/src/core/file_sys/sdmc_factory.h new file mode 100644 index 000000000..93becda25 --- /dev/null +++ b/src/core/file_sys/sdmc_factory.h | |||
| @@ -0,0 +1,31 @@ | |||
| 1 | // Copyright 2018 yuzu emulator team | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #pragma once | ||
| 6 | |||
| 7 | #include <memory> | ||
| 8 | #include <string> | ||
| 9 | #include "common/common_types.h" | ||
| 10 | #include "core/file_sys/filesystem.h" | ||
| 11 | #include "core/hle/result.h" | ||
| 12 | |||
| 13 | namespace FileSys { | ||
| 14 | |||
| 15 | /// File system interface to the SDCard archive | ||
| 16 | class SDMC_Factory final : public FileSystemFactory { | ||
| 17 | public: | ||
| 18 | explicit SDMC_Factory(std::string sd_directory); | ||
| 19 | |||
| 20 | std::string GetName() const override { | ||
| 21 | return "SDMC_Factory"; | ||
| 22 | } | ||
| 23 | ResultVal<std::unique_ptr<FileSystemBackend>> Open(const Path& path) override; | ||
| 24 | ResultCode Format(const Path& path) override; | ||
| 25 | ResultVal<ArchiveFormatInfo> GetFormatInfo(const Path& path) const override; | ||
| 26 | |||
| 27 | private: | ||
| 28 | std::string sd_directory; | ||
| 29 | }; | ||
| 30 | |||
| 31 | } // namespace FileSys | ||
diff --git a/src/core/hle/service/filesystem/filesystem.cpp b/src/core/hle/service/filesystem/filesystem.cpp index ef05955b9..945832e98 100644 --- a/src/core/hle/service/filesystem/filesystem.cpp +++ b/src/core/hle/service/filesystem/filesystem.cpp | |||
| @@ -6,6 +6,7 @@ | |||
| 6 | #include "common/file_util.h" | 6 | #include "common/file_util.h" |
| 7 | #include "core/file_sys/filesystem.h" | 7 | #include "core/file_sys/filesystem.h" |
| 8 | #include "core/file_sys/savedata_factory.h" | 8 | #include "core/file_sys/savedata_factory.h" |
| 9 | #include "core/file_sys/sdmc_factory.h" | ||
| 9 | #include "core/hle/service/filesystem/filesystem.h" | 10 | #include "core/hle/service/filesystem/filesystem.h" |
| 10 | #include "core/hle/service/filesystem/fsp_srv.h" | 11 | #include "core/hle/service/filesystem/fsp_srv.h" |
| 11 | 12 | ||
| @@ -60,9 +61,13 @@ void RegisterFileSystems() { | |||
| 60 | filesystem_map.clear(); | 61 | filesystem_map.clear(); |
| 61 | 62 | ||
| 62 | std::string nand_directory = FileUtil::GetUserPath(D_NAND_IDX); | 63 | std::string nand_directory = FileUtil::GetUserPath(D_NAND_IDX); |
| 64 | std::string sd_directory = FileUtil::GetUserPath(D_SDMC_IDX); | ||
| 63 | 65 | ||
| 64 | auto savedata = std::make_unique<FileSys::SaveData_Factory>(std::move(nand_directory)); | 66 | auto savedata = std::make_unique<FileSys::SaveData_Factory>(std::move(nand_directory)); |
| 65 | RegisterFileSystem(std::move(savedata), Type::SaveData); | 67 | RegisterFileSystem(std::move(savedata), Type::SaveData); |
| 68 | |||
| 69 | auto sdcard = std::make_unique<FileSys::SDMC_Factory>(std::move(sd_directory)); | ||
| 70 | RegisterFileSystem(std::move(sdcard), Type::SDMC); | ||
| 66 | } | 71 | } |
| 67 | 72 | ||
| 68 | void InstallInterfaces(SM::ServiceManager& service_manager) { | 73 | void InstallInterfaces(SM::ServiceManager& service_manager) { |
diff --git a/src/core/hle/service/filesystem/filesystem.h b/src/core/hle/service/filesystem/filesystem.h index 8d30e94a1..56d26146e 100644 --- a/src/core/hle/service/filesystem/filesystem.h +++ b/src/core/hle/service/filesystem/filesystem.h | |||
| @@ -26,6 +26,7 @@ namespace FileSystem { | |||
| 26 | enum class Type { | 26 | enum class Type { |
| 27 | RomFS = 1, | 27 | RomFS = 1, |
| 28 | SaveData = 2, | 28 | SaveData = 2, |
| 29 | SDMC = 3, | ||
| 29 | }; | 30 | }; |
| 30 | 31 | ||
| 31 | /** | 32 | /** |