aboutsummaryrefslogtreecommitdiff
path: root/src/core/file_sys/savedata_factory.cpp
diff options
context:
space:
mode:
authorxbzk <xbzk@eden-emu.dev>2026-09-18 23:48:35 +0200
committercrueter <crueter@eden-emu.dev>2026-09-18 23:48:35 +0200
commit3c38afad74c751a949de0bcca9a51cfc11797f68 (patch)
tree06123478186079f92d9c362e51e2345e3ac47516 /src/core/file_sys/savedata_factory.cpp
parent0ce29be60874b24890ab9239cecf1bd67b924428 (diff)
[fs] share parent resources with bundled programs (#4319)
- [x] I have read and followed the [Contribution Guidelines](https://git.eden-emu.dev/eden-emu/eden/src/branch/master/CONTRIBUTING.md#code-contributions). - [x] I have read and followed the [AI Policy](https://git.eden-emu.dev/eden-emu/eden/src/branch/master/docs/policies/AI.md) - [x] I have read and followed the [Coding Guidelines](https://git.eden-emu.dev/eden-emu/eden/src/branch/master/docs/policies/Coding.md) to the best of my ability. ------------------- Normal games are Applications; Bundled games are Application + Programs; We've been treating both as the same thing, calling both programs, and making programs unable to see settings and saves from application. References: https://switchbrew.org/wiki/Filesystem_services https://switchbrew.org/wiki/NCM_services#ApplicationId https://switchbrew.org/wiki/Super_Mario_3D_All-Stars Ryujinx.HLE/HOS/ApplicationLoader.cs:GetMultiProgramInfo UPDATE: The first version was a big rework to make AppId/ProgId concepts proper, and it was successful in most tests, but it caused a regression with applets, which are programs that breed straight from no application. In order to simplify things i've reverted all the rework, added a helper to identify whether a program has a parent Application and bounded it to it's proper stores. Although this is no big deal coz it doesn't have impact on emulation, it permeates to several routines, so it needs to be tested broadly. Applets, Normal games, Bundled games, Blobbed NSPs/XCIs, Mods, Updates, Saves, DLCs,. Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/4319 Reviewed-by: MaranBr <maranbr@eden-emu.dev> Reviewed-by: lizzie <lizzie@eden-emu.dev>
Diffstat (limited to 'src/core/file_sys/savedata_factory.cpp')
-rw-r--r--src/core/file_sys/savedata_factory.cpp22
1 files changed, 14 insertions, 8 deletions
diff --git a/src/core/file_sys/savedata_factory.cpp b/src/core/file_sys/savedata_factory.cpp
index c756734a43..72f022cb41 100644
--- a/src/core/file_sys/savedata_factory.cpp
+++ b/src/core/file_sys/savedata_factory.cpp
@@ -9,6 +9,7 @@
#include "common/logging.h"
#include "common/uuid.h"
#include "core/core.h"
+#include "core/file_sys/registered_cache.h"
#include "core/file_sys/savedata_factory.h"
#include "core/file_sys/vfs/vfs.h"
@@ -61,17 +62,24 @@ SaveDataFactory::SaveDataFactory(Core::System& system_, ProgramId program_id_,
SaveDataFactory::~SaveDataFactory() = default;
+std::string SaveDataFactory::GetSaveDataPath(SaveDataSpaceId space, SaveDataType type, u64 title_id, u128 user_id, u64 save_id) const {
+ if (type == SaveDataType::Account || type == SaveDataType::Device) {
+ const auto requested_id = title_id != 0 ? title_id : program_id;
+ const auto parent_id = system.GetContentProvider().GetParentApplicationId(requested_id);
+ title_id = parent_id.value_or(requested_id);
+ }
+ return GetFullPath(program_id, dir, space, type, title_id, user_id, save_id);
+}
+
VirtualDir SaveDataFactory::Create(SaveDataSpaceId space, const SaveDataAttribute& meta) const {
- const auto save_directory = GetFullPath(program_id, dir, space, meta.type, meta.program_id,
- meta.user_id, meta.system_save_data_id);
+ const auto save_directory = GetSaveDataPath(space, meta.type, meta.program_id, meta.user_id, meta.system_save_data_id);
return dir->CreateDirectoryRelative(save_directory);
}
VirtualDir SaveDataFactory::Open(SaveDataSpaceId space, const SaveDataAttribute& meta) const {
- const auto save_directory = GetFullPath(program_id, dir, space, meta.type, meta.program_id,
- meta.user_id, meta.system_save_data_id);
+ const auto save_directory = GetSaveDataPath(space, meta.type, meta.program_id, meta.user_id, meta.system_save_data_id);
auto out = dir->GetDirectoryRelative(save_directory);
@@ -154,8 +162,7 @@ std::string SaveDataFactory::GetUserGameSaveDataRoot(u128 user_id, bool future)
SaveDataSize SaveDataFactory::ReadSaveDataSize(SaveDataType type, u64 title_id,
u128 user_id) const {
- const auto path =
- GetFullPath(program_id, dir, SaveDataSpaceId::User, type, title_id, user_id, 0);
+ const auto path = GetSaveDataPath(SaveDataSpaceId::User, type, title_id, user_id, 0);
const auto relative_dir = GetOrCreateDirectoryRelative(dir, path);
const auto size_file = relative_dir->GetFile(GetSaveDataSizeFileName());
@@ -173,8 +180,7 @@ SaveDataSize SaveDataFactory::ReadSaveDataSize(SaveDataType type, u64 title_id,
void SaveDataFactory::WriteSaveDataSize(SaveDataType type, u64 title_id, u128 user_id,
SaveDataSize new_value) const {
- const auto path =
- GetFullPath(program_id, dir, SaveDataSpaceId::User, type, title_id, user_id, 0);
+ const auto path = GetSaveDataPath(SaveDataSpaceId::User, type, title_id, user_id, 0);
const auto relative_dir = GetOrCreateDirectoryRelative(dir, path);
const auto size_file = relative_dir->CreateFile(GetSaveDataSizeFileName());