summaryrefslogtreecommitdiffstats
path: root/src/core/hle/service/filesystem
diff options
context:
space:
mode:
authorMat M <mathew1800@gmail.com>2018-08-25 05:47:46 +0200
committerGitHub <noreply@github.com>2018-08-25 05:47:46 +0200
commit6426b0f5514d6a7c5cc369368947eceb380bfc85 (patch)
treeb7acdc39a4344570a6f2c098c30ad20114bf84db /src/core/hle/service/filesystem
parentMerge pull request #1065 from DarkLordZach/window-title (diff)
parentfile_sys/crypto: Fix missing/unnecessary includes (diff)
downloadyuzu-6426b0f5514d6a7c5cc369368947eceb380bfc85.tar
yuzu-6426b0f5514d6a7c5cc369368947eceb380bfc85.tar.gz
yuzu-6426b0f5514d6a7c5cc369368947eceb380bfc85.tar.bz2
yuzu-6426b0f5514d6a7c5cc369368947eceb380bfc85.tar.lz
yuzu-6426b0f5514d6a7c5cc369368947eceb380bfc85.tar.xz
yuzu-6426b0f5514d6a7c5cc369368947eceb380bfc85.tar.zst
yuzu-6426b0f5514d6a7c5cc369368947eceb380bfc85.zip
Diffstat (limited to 'src/core/hle/service/filesystem')
-rw-r--r--src/core/hle/service/filesystem/filesystem.cpp42
-rw-r--r--src/core/hle/service/filesystem/filesystem.h6
2 files changed, 36 insertions, 12 deletions
diff --git a/src/core/hle/service/filesystem/filesystem.cpp b/src/core/hle/service/filesystem/filesystem.cpp
index 6f9c64263..914315d20 100644
--- a/src/core/hle/service/filesystem/filesystem.cpp
+++ b/src/core/hle/service/filesystem/filesystem.cpp
@@ -305,17 +305,38 @@ ResultVal<FileSys::VirtualDir> OpenSDMC() {
}
std::shared_ptr<FileSys::RegisteredCache> GetSystemNANDContents() {
+ LOG_TRACE(Service_FS, "Opening System NAND Contents");
+
+ if (bis_factory == nullptr)
+ return nullptr;
+
return bis_factory->GetSystemNANDContents();
}
std::shared_ptr<FileSys::RegisteredCache> GetUserNANDContents() {
+ LOG_TRACE(Service_FS, "Opening User NAND Contents");
+
+ if (bis_factory == nullptr)
+ return nullptr;
+
return bis_factory->GetUserNANDContents();
}
-void RegisterFileSystems(const FileSys::VirtualFilesystem& vfs) {
- romfs_factory = nullptr;
- save_data_factory = nullptr;
- sdmc_factory = nullptr;
+std::shared_ptr<FileSys::RegisteredCache> GetSDMCContents() {
+ LOG_TRACE(Service_FS, "Opening SDMC Contents");
+
+ if (sdmc_factory == nullptr)
+ return nullptr;
+
+ return sdmc_factory->GetSDMCContents();
+}
+
+void CreateFactories(const FileSys::VirtualFilesystem& vfs, bool overwrite) {
+ if (overwrite) {
+ bis_factory = nullptr;
+ save_data_factory = nullptr;
+ sdmc_factory = nullptr;
+ }
auto nand_directory = vfs->OpenDirectory(FileUtil::GetUserPath(FileUtil::UserPath::NANDDir),
FileSys::Mode::ReadWrite);
@@ -324,16 +345,15 @@ void RegisterFileSystems(const FileSys::VirtualFilesystem& vfs) {
if (bis_factory == nullptr)
bis_factory = std::make_unique<FileSys::BISFactory>(nand_directory);
-
- auto savedata = std::make_unique<FileSys::SaveDataFactory>(std::move(nand_directory));
- save_data_factory = std::move(savedata);
-
- auto sdcard = std::make_unique<FileSys::SDMCFactory>(std::move(sd_directory));
- sdmc_factory = std::move(sdcard);
+ if (save_data_factory == nullptr)
+ save_data_factory = std::make_unique<FileSys::SaveDataFactory>(std::move(nand_directory));
+ if (sdmc_factory == nullptr)
+ sdmc_factory = std::make_unique<FileSys::SDMCFactory>(std::move(sd_directory));
}
void InstallInterfaces(SM::ServiceManager& service_manager, const FileSys::VirtualFilesystem& vfs) {
- RegisterFileSystems(vfs);
+ romfs_factory = nullptr;
+ CreateFactories(vfs, false);
std::make_shared<FSP_LDR>()->InstallAsService(service_manager);
std::make_shared<FSP_PR>()->InstallAsService(service_manager);
std::make_shared<FSP_SRV>()->InstallAsService(service_manager);
diff --git a/src/core/hle/service/filesystem/filesystem.h b/src/core/hle/service/filesystem/filesystem.h
index df78be44a..d88a66825 100644
--- a/src/core/hle/service/filesystem/filesystem.h
+++ b/src/core/hle/service/filesystem/filesystem.h
@@ -46,8 +46,12 @@ ResultVal<FileSys::VirtualDir> OpenSDMC();
std::shared_ptr<FileSys::RegisteredCache> GetSystemNANDContents();
std::shared_ptr<FileSys::RegisteredCache> GetUserNANDContents();
+std::shared_ptr<FileSys::RegisteredCache> GetSDMCContents();
+
+// Creates the SaveData, SDMC, and BIS Factories. Should be called once and before any function
+// above is called.
+void CreateFactories(const FileSys::VirtualFilesystem& vfs, bool overwrite = true);
-/// Registers all Filesystem services with the specified service manager.
void InstallInterfaces(SM::ServiceManager& service_manager, const FileSys::VirtualFilesystem& vfs);
// A class that wraps a VfsDirectory with methods that return ResultVal and ResultCode instead of