summaryrefslogtreecommitdiff
path: root/src/core/hle
diff options
context:
space:
mode:
authorGravatar bunnei2018-08-09 19:22:06 -0400
committerGravatar GitHub2018-08-09 19:22:06 -0400
commit96ef22d3d0f7e75d1ad5d1351cd26db8c835f6ca (patch)
tree4f18d020eb3de30a55053c3367cd0cc6049b31d6 /src/core/hle
parentMerge pull request #991 from bunnei/ignore-mac (diff)
parentvfs: Fix documentation (diff)
downloadyuzu-96ef22d3d0f7e75d1ad5d1351cd26db8c835f6ca.tar.gz
yuzu-96ef22d3d0f7e75d1ad5d1351cd26db8c835f6ca.tar.xz
yuzu-96ef22d3d0f7e75d1ad5d1351cd26db8c835f6ca.zip
Merge pull request #897 from DarkLordZach/vfs-accuracy-2
vfs: Add VfsFilesystem and fix RealVfs* implementations
Diffstat (limited to 'src/core/hle')
-rw-r--r--src/core/hle/service/filesystem/filesystem.cpp16
-rw-r--r--src/core/hle/service/filesystem/filesystem.h2
-rw-r--r--src/core/hle/service/service.cpp4
-rw-r--r--src/core/hle/service/service.h7
4 files changed, 17 insertions, 12 deletions
diff --git a/src/core/hle/service/filesystem/filesystem.cpp b/src/core/hle/service/filesystem/filesystem.cpp
index e17d637e4..5e416cde2 100644
--- a/src/core/hle/service/filesystem/filesystem.cpp
+++ b/src/core/hle/service/filesystem/filesystem.cpp
@@ -59,7 +59,7 @@ ResultCode VfsDirectoryServiceWrapper::CreateFile(const std::string& path_, u64
59ResultCode VfsDirectoryServiceWrapper::DeleteFile(const std::string& path_) const { 59ResultCode VfsDirectoryServiceWrapper::DeleteFile(const std::string& path_) const {
60 std::string path(FileUtil::SanitizePath(path_)); 60 std::string path(FileUtil::SanitizePath(path_));
61 auto dir = GetDirectoryRelativeWrapped(backing, FileUtil::GetParentPath(path)); 61 auto dir = GetDirectoryRelativeWrapped(backing, FileUtil::GetParentPath(path));
62 if (path == "/" || path == "\\") { 62 if (path.empty()) {
63 // TODO(DarkLordZach): Why do games call this and what should it do? Works as is but... 63 // TODO(DarkLordZach): Why do games call this and what should it do? Works as is but...
64 return RESULT_SUCCESS; 64 return RESULT_SUCCESS;
65 } 65 }
@@ -281,15 +281,15 @@ ResultVal<FileSys::VirtualDir> OpenSDMC() {
281 return sdmc_factory->Open(); 281 return sdmc_factory->Open();
282} 282}
283 283
284void RegisterFileSystems() { 284void RegisterFileSystems(const FileSys::VirtualFilesystem& vfs) {
285 romfs_factory = nullptr; 285 romfs_factory = nullptr;
286 save_data_factory = nullptr; 286 save_data_factory = nullptr;
287 sdmc_factory = nullptr; 287 sdmc_factory = nullptr;
288 288
289 auto nand_directory = std::make_shared<FileSys::RealVfsDirectory>( 289 auto nand_directory = vfs->OpenDirectory(FileUtil::GetUserPath(FileUtil::UserPath::NANDDir),
290 FileUtil::GetUserPath(FileUtil::UserPath::NANDDir), FileSys::Mode::ReadWrite); 290 FileSys::Mode::ReadWrite);
291 auto sd_directory = std::make_shared<FileSys::RealVfsDirectory>( 291 auto sd_directory = vfs->OpenDirectory(FileUtil::GetUserPath(FileUtil::UserPath::SDMCDir),
292 FileUtil::GetUserPath(FileUtil::UserPath::SDMCDir), FileSys::Mode::ReadWrite); 292 FileSys::Mode::ReadWrite);
293 293
294 auto savedata = std::make_unique<FileSys::SaveDataFactory>(std::move(nand_directory)); 294 auto savedata = std::make_unique<FileSys::SaveDataFactory>(std::move(nand_directory));
295 save_data_factory = std::move(savedata); 295 save_data_factory = std::move(savedata);
@@ -298,8 +298,8 @@ void RegisterFileSystems() {
298 sdmc_factory = std::move(sdcard); 298 sdmc_factory = std::move(sdcard);
299} 299}
300 300
301void InstallInterfaces(SM::ServiceManager& service_manager) { 301void InstallInterfaces(SM::ServiceManager& service_manager, const FileSys::VirtualFilesystem& vfs) {
302 RegisterFileSystems(); 302 RegisterFileSystems(vfs);
303 std::make_shared<FSP_LDR>()->InstallAsService(service_manager); 303 std::make_shared<FSP_LDR>()->InstallAsService(service_manager);
304 std::make_shared<FSP_PR>()->InstallAsService(service_manager); 304 std::make_shared<FSP_PR>()->InstallAsService(service_manager);
305 std::make_shared<FSP_SRV>()->InstallAsService(service_manager); 305 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 d4483daa5..462c13f20 100644
--- a/src/core/hle/service/filesystem/filesystem.h
+++ b/src/core/hle/service/filesystem/filesystem.h
@@ -36,7 +36,7 @@ ResultVal<FileSys::VirtualDir> OpenSDMC();
36// ResultVal<std::unique_ptr<FileSys::FileSystemBackend>> OpenBIS(); 36// ResultVal<std::unique_ptr<FileSys::FileSystemBackend>> OpenBIS();
37 37
38/// Registers all Filesystem services with the specified service manager. 38/// Registers all Filesystem services with the specified service manager.
39void InstallInterfaces(SM::ServiceManager& service_manager); 39void InstallInterfaces(SM::ServiceManager& service_manager, const FileSys::VirtualFilesystem& vfs);
40 40
41// A class that wraps a VfsDirectory with methods that return ResultVal and ResultCode instead of 41// A class that wraps a VfsDirectory with methods that return ResultVal and ResultCode instead of
42// pointers and booleans. This makes using a VfsDirectory with switch services much easier and 42// pointers and booleans. This makes using a VfsDirectory with switch services much easier and
diff --git a/src/core/hle/service/service.cpp b/src/core/hle/service/service.cpp
index 6f286ea74..11951adaf 100644
--- a/src/core/hle/service/service.cpp
+++ b/src/core/hle/service/service.cpp
@@ -198,7 +198,7 @@ void AddNamedPort(std::string name, SharedPtr<ClientPort> port) {
198} 198}
199 199
200/// Initialize ServiceManager 200/// Initialize ServiceManager
201void Init(std::shared_ptr<SM::ServiceManager>& sm) { 201void Init(std::shared_ptr<SM::ServiceManager>& sm, const FileSys::VirtualFilesystem& rfs) {
202 // NVFlinger needs to be accessed by several services like Vi and AppletOE so we instantiate it 202 // NVFlinger needs to be accessed by several services like Vi and AppletOE so we instantiate it
203 // here and pass it into the respective InstallInterfaces functions. 203 // here and pass it into the respective InstallInterfaces functions.
204 auto nv_flinger = std::make_shared<NVFlinger::NVFlinger>(); 204 auto nv_flinger = std::make_shared<NVFlinger::NVFlinger>();
@@ -221,7 +221,7 @@ void Init(std::shared_ptr<SM::ServiceManager>& sm) {
221 EUPLD::InstallInterfaces(*sm); 221 EUPLD::InstallInterfaces(*sm);
222 Fatal::InstallInterfaces(*sm); 222 Fatal::InstallInterfaces(*sm);
223 FGM::InstallInterfaces(*sm); 223 FGM::InstallInterfaces(*sm);
224 FileSystem::InstallInterfaces(*sm); 224 FileSystem::InstallInterfaces(*sm, rfs);
225 Friend::InstallInterfaces(*sm); 225 Friend::InstallInterfaces(*sm);
226 GRC::InstallInterfaces(*sm); 226 GRC::InstallInterfaces(*sm);
227 HID::InstallInterfaces(*sm); 227 HID::InstallInterfaces(*sm);
diff --git a/src/core/hle/service/service.h b/src/core/hle/service/service.h
index 046c5e18d..8a294c0f2 100644
--- a/src/core/hle/service/service.h
+++ b/src/core/hle/service/service.h
@@ -22,6 +22,10 @@ class ServerSession;
22class HLERequestContext; 22class HLERequestContext;
23} // namespace Kernel 23} // namespace Kernel
24 24
25namespace FileSys {
26struct VfsFilesystem;
27}
28
25namespace Service { 29namespace Service {
26 30
27namespace SM { 31namespace SM {
@@ -177,7 +181,8 @@ private:
177}; 181};
178 182
179/// Initialize ServiceManager 183/// Initialize ServiceManager
180void Init(std::shared_ptr<SM::ServiceManager>& sm); 184void Init(std::shared_ptr<SM::ServiceManager>& sm,
185 const std::shared_ptr<FileSys::VfsFilesystem>& vfs);
181 186
182/// Shutdown ServiceManager 187/// Shutdown ServiceManager
183void Shutdown(); 188void Shutdown();