added sceSaveDataMount needed for Cursed Castilla

This commit is contained in:
georgemoralis 2024-05-30 13:37:29 +03:00
parent 4749782a68
commit 3d749bc904
2 changed files with 52 additions and 13 deletions

View File

@ -331,22 +331,14 @@ int PS4_SYSV_ABI sceSaveDataLoadIcon() {
return ORBIS_OK; return ORBIS_OK;
} }
int PS4_SYSV_ABI sceSaveDataMount() { s32 saveDataMount(u32 user_id, std::string dir_name, u32 mount_mode,
LOG_ERROR(Lib_SaveData, "(STUBBED) called"); OrbisSaveDataMountResult* mount_result) {
return ORBIS_OK;
}
s32 PS4_SYSV_ABI sceSaveDataMount2(const OrbisSaveDataMount2* mount,
OrbisSaveDataMountResult* mount_result) {
LOG_INFO(Lib_SaveData, "called user_id = {} dir_name = {} blocks = {} mount_mode = {}",
mount->user_id, mount->dir_name->data, mount->blocks, mount->mount_mode);
auto* param_sfo = Common::Singleton<PSF>::Instance(); auto* param_sfo = Common::Singleton<PSF>::Instance();
std::string id(param_sfo->GetString("CONTENT_ID"), 7, 9); std::string id(param_sfo->GetString("CONTENT_ID"), 7, 9);
const auto& mount_dir = Common::FS::GetUserPath(Common::FS::PathType::SaveDataDir) / const auto& mount_dir = Common::FS::GetUserPath(Common::FS::PathType::SaveDataDir) /
std::to_string(mount->user_id) / "savedata" / id / std::to_string(user_id) / "savedata" / id / dir_name;
std::string(mount->dir_name->data); switch (mount_mode) {
switch (mount->mount_mode) {
case ORBIS_SAVE_DATA_MOUNT_MODE_RDONLY: case ORBIS_SAVE_DATA_MOUNT_MODE_RDONLY:
case ORBIS_SAVE_DATA_MOUNT_MODE_RDWR: { case ORBIS_SAVE_DATA_MOUNT_MODE_RDWR: {
if (!std::filesystem::exists(mount_dir)) { if (!std::filesystem::exists(mount_dir)) {
@ -392,6 +384,28 @@ s32 PS4_SYSV_ABI sceSaveDataMount2(const OrbisSaveDataMount2* mount,
return ORBIS_OK; return ORBIS_OK;
} }
s32 PS4_SYSV_ABI sceSaveDataMount(const OrbisSaveDataMount* mount,
OrbisSaveDataMountResult* mount_result) {
if (mount == nullptr) {
return ORBIS_SAVE_DATA_ERROR_PARAMETER;
}
LOG_INFO(Lib_SaveData, "called: mount = {}, mode = {}, blocks = {}", mount->dir_name->data,
mount->mount_mode, mount->blocks);
return saveDataMount(mount->user_id, std::string(mount->dir_name->data), mount->mount_mode,
mount_result);
}
s32 PS4_SYSV_ABI sceSaveDataMount2(const OrbisSaveDataMount2* mount,
OrbisSaveDataMountResult* mount_result) {
if (mount == nullptr) {
return ORBIS_SAVE_DATA_ERROR_PARAMETER;
}
LOG_INFO(Lib_SaveData, "called: mount = {}, mode = {}, blocks = {}", mount->dir_name->data,
mount->mount_mode, mount->blocks);
return saveDataMount(mount->user_id, std::string(mount->dir_name->data), mount->mount_mode,
mount_result);
}
int PS4_SYSV_ABI sceSaveDataMount5() { int PS4_SYSV_ABI sceSaveDataMount5() {
LOG_ERROR(Lib_SaveData, "(STUBBED) called"); LOG_ERROR(Lib_SaveData, "(STUBBED) called");
return ORBIS_OK; return ORBIS_OK;

View File

@ -42,6 +42,30 @@ struct OrbisSaveDataMountResult {
s32 unk1; s32 unk1;
}; };
constexpr int ORBIS_SAVE_DATA_TITLE_ID_DATA_SIZE = 10;
typedef struct OrbisSaveDataTitleId {
char data[ORBIS_SAVE_DATA_TITLE_ID_DATA_SIZE];
char padding[6];
} OrbisSaveDataTitleId;
constexpr int ORBIS_SAVE_DATA_FINGERPRINT_DATA_SIZE = 65;
typedef struct OrbisSaveDataFingerprint {
char data[ORBIS_SAVE_DATA_FINGERPRINT_DATA_SIZE];
char padding[15];
} OrbisSaveDataFingerprint;
typedef struct OrbisSaveDataMount {
s32 user_id;
s32 pad;
const OrbisSaveDataTitleId* titleId;
const OrbisSaveDataDirName* dir_name;
const OrbisSaveDataFingerprint* fingerprint;
u64 blocks;
u32 mount_mode;
u8 reserved[32];
} OrbisSaveDataMount;
// savedataMount2 mountModes (ORed values) // savedataMount2 mountModes (ORed values)
constexpr int ORBIS_SAVE_DATA_MOUNT_MODE_RDONLY = 1; constexpr int ORBIS_SAVE_DATA_MOUNT_MODE_RDONLY = 1;
constexpr int ORBIS_SAVE_DATA_MOUNT_MODE_RDWR = 2; constexpr int ORBIS_SAVE_DATA_MOUNT_MODE_RDWR = 2;
@ -113,7 +137,8 @@ int PS4_SYSV_ABI sceSaveDataInitializeForCdlg();
int PS4_SYSV_ABI sceSaveDataIsDeletingUsbDb(); int PS4_SYSV_ABI sceSaveDataIsDeletingUsbDb();
int PS4_SYSV_ABI sceSaveDataIsMounted(); int PS4_SYSV_ABI sceSaveDataIsMounted();
int PS4_SYSV_ABI sceSaveDataLoadIcon(); int PS4_SYSV_ABI sceSaveDataLoadIcon();
int PS4_SYSV_ABI sceSaveDataMount(); int PS4_SYSV_ABI sceSaveDataMount(const OrbisSaveDataMount* mount,
OrbisSaveDataMountResult* mount_result);
s32 PS4_SYSV_ABI sceSaveDataMount2(const OrbisSaveDataMount2* mount, s32 PS4_SYSV_ABI sceSaveDataMount2(const OrbisSaveDataMount2* mount,
OrbisSaveDataMountResult* mount_result); OrbisSaveDataMountResult* mount_result);
int PS4_SYSV_ABI sceSaveDataMount5(); int PS4_SYSV_ABI sceSaveDataMount5();