summaryrefslogtreecommitdiff
path: root/src/core/hle
diff options
context:
space:
mode:
authorGravatar Subv2018-03-04 13:03:58 -0500
committerGravatar Subv2018-03-04 14:30:07 -0500
commit0eefe6e4d15cbc7a5902dfbe5e7742ef4ea71902 (patch)
treed6fbf1e18b6b17fcb089306af26c48331100814c /src/core/hle
parentMerge pull request #226 from Subv/buffer_queue_event (diff)
downloadyuzu-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/hle')
-rw-r--r--src/core/hle/service/am/am.cpp22
-rw-r--r--src/core/hle/service/filesystem/filesystem.cpp13
-rw-r--r--src/core/hle/service/filesystem/filesystem.h7
3 files changed, 40 insertions, 2 deletions
diff --git a/src/core/hle/service/am/am.cpp b/src/core/hle/service/am/am.cpp
index d3a674cf6..d9f003ed4 100644
--- a/src/core/hle/service/am/am.cpp
+++ b/src/core/hle/service/am/am.cpp
@@ -2,12 +2,15 @@
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include <cinttypes>
6#include "core/file_sys/filesystem.h"
5#include "core/hle/ipc_helpers.h" 7#include "core/hle/ipc_helpers.h"
6#include "core/hle/kernel/event.h" 8#include "core/hle/kernel/event.h"
7#include "core/hle/service/am/am.h" 9#include "core/hle/service/am/am.h"
8#include "core/hle/service/am/applet_ae.h" 10#include "core/hle/service/am/applet_ae.h"
9#include "core/hle/service/am/applet_oe.h" 11#include "core/hle/service/am/applet_oe.h"
10#include "core/hle/service/apm/apm.h" 12#include "core/hle/service/apm/apm.h"
13#include "core/hle/service/filesystem/filesystem.h"
11#include "core/hle/service/nvflinger/nvflinger.h" 14#include "core/hle/service/nvflinger/nvflinger.h"
12 15
13namespace Service { 16namespace Service {
@@ -416,9 +419,24 @@ void IApplicationFunctions::PopLaunchParameter(Kernel::HLERequestContext& ctx) {
416} 419}
417 420
418void IApplicationFunctions::EnsureSaveData(Kernel::HLERequestContext& ctx) { 421void IApplicationFunctions::EnsureSaveData(Kernel::HLERequestContext& ctx) {
419 LOG_WARNING(Service, "(STUBBED) called"); 422 IPC::RequestParser rp{ctx};
423 u128 uid = rp.PopRaw<u128>();
424
425 LOG_WARNING(Service, "(STUBBED) called uid = %016" PRIX64 "%016" PRIX64, uid[1], uid[0]);
426
420 IPC::ResponseBuilder rb{ctx, 4}; 427 IPC::ResponseBuilder rb{ctx, 4};
421 rb.Push(RESULT_SUCCESS); 428
429 FileSys::Path unused;
430 auto savedata = FileSystem::OpenFileSystem(FileSystem::Type::SaveData, unused);
431 if (savedata.Failed()) {
432 // Create the save data and return an error indicating that the operation was performed.
433 FileSystem::FormatFileSystem(FileSystem::Type::SaveData);
434 // TODO(Subv): Find out the correct error code for this.
435 rb.Push(ResultCode(ErrorModule::FS, 40));
436 } else {
437 rb.Push(RESULT_SUCCESS);
438 }
439
422 rb.Push<u64>(0); 440 rb.Push<u64>(0);
423} 441}
424 442
diff --git a/src/core/hle/service/filesystem/filesystem.cpp b/src/core/hle/service/filesystem/filesystem.cpp
index 32752aea5..ef05955b9 100644
--- a/src/core/hle/service/filesystem/filesystem.cpp
+++ b/src/core/hle/service/filesystem/filesystem.cpp
@@ -43,6 +43,19 @@ ResultVal<std::unique_ptr<FileSys::FileSystemBackend>> OpenFileSystem(Type type,
43 return itr->second->Open(path); 43 return itr->second->Open(path);
44} 44}
45 45
46ResultCode FormatFileSystem(Type type) {
47 LOG_TRACE(Service_FS, "Formatting FileSystem with type=%d", type);
48
49 auto itr = filesystem_map.find(type);
50 if (itr == filesystem_map.end()) {
51 // TODO(bunnei): Find a better error code for this
52 return ResultCode(-1);
53 }
54
55 FileSys::Path unused;
56 return itr->second->Format(unused);
57}
58
46void RegisterFileSystems() { 59void RegisterFileSystems() {
47 filesystem_map.clear(); 60 filesystem_map.clear();
48 61
diff --git a/src/core/hle/service/filesystem/filesystem.h b/src/core/hle/service/filesystem/filesystem.h
index 80f318676..8d30e94a1 100644
--- a/src/core/hle/service/filesystem/filesystem.h
+++ b/src/core/hle/service/filesystem/filesystem.h
@@ -44,6 +44,13 @@ ResultCode RegisterFileSystem(std::unique_ptr<FileSys::FileSystemFactory>&& fact
44ResultVal<std::unique_ptr<FileSys::FileSystemBackend>> OpenFileSystem(Type type, 44ResultVal<std::unique_ptr<FileSys::FileSystemBackend>> OpenFileSystem(Type type,
45 FileSys::Path& path); 45 FileSys::Path& path);
46 46
47/**
48 * Formats a file system
49 * @param type Type of the file system to format
50 * @return ResultCode of the operation
51 */
52ResultCode FormatFileSystem(Type type);
53
47/// Registers all Filesystem services with the specified service manager. 54/// Registers all Filesystem services with the specified service manager.
48void InstallInterfaces(SM::ServiceManager& service_manager); 55void InstallInterfaces(SM::ServiceManager& service_manager);
49 56