SaveData: implement sceSaveDataTransferringMount ()

* SaveData: fix icon overriding

* SaveData: implement sceSaveDataTransferringMount
This commit is contained in:
Vinicius Rangel 2024-10-02 00:38:18 -03:00 committed by GitHub
parent 61f750bdd9
commit ee1e55d5e1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 41 additions and 10 deletions

View file

@ -157,7 +157,11 @@ void SaveInstance::SetupAndMount(bool read_only, bool copy_icon, bool ignore_cor
if (copy_icon) { if (copy_icon) {
const auto& src_icon = g_mnt->GetHostPath("/app0/sce_sys/save_data.png"); const auto& src_icon = g_mnt->GetHostPath("/app0/sce_sys/save_data.png");
if (fs::exists(src_icon)) { if (fs::exists(src_icon)) {
fs::copy_file(src_icon, GetIconPath()); auto output_icon = GetIconPath();
if (fs::exists(output_icon)) {
fs::remove(output_icon);
}
fs::copy_file(src_icon, output_icon);
} }
} }
exists = true; exists = true;

View file

@ -207,7 +207,7 @@ void SetIcon(void* buf, size_t buf_size) {
} else { } else {
g_icon_memory.resize(buf_size); g_icon_memory.resize(buf_size);
std::memcpy(g_icon_memory.data(), buf, buf_size); std::memcpy(g_icon_memory.data(), buf, buf_size);
IOFile file(g_icon_path, Common::FS::FileAccessMode::Append); IOFile file(g_icon_path, Common::FS::FileAccessMode::Write);
file.Seek(0); file.Seek(0);
file.WriteRaw<u8>(g_icon_memory.data(), buf_size); file.WriteRaw<u8>(g_icon_memory.data(), buf_size);
file.Close(); file.Close();

View file

@ -262,6 +262,14 @@ struct OrbisSaveDataRestoreBackupData {
s32 : 32; s32 : 32;
}; };
struct OrbisSaveDataTransferringMount {
OrbisUserServiceUserId userId;
const OrbisSaveDataTitleId* titleId;
const OrbisSaveDataDirName* dirName;
const OrbisSaveDataFingerprint* fingerprint;
std::array<u8, 32> _reserved;
};
struct OrbisSaveDataDirNameSearchCond { struct OrbisSaveDataDirNameSearchCond {
OrbisUserServiceUserId userId; OrbisUserServiceUserId userId;
int : 32; int : 32;
@ -357,7 +365,8 @@ static Error setNotInitializedError() {
} }
static Error saveDataMount(const OrbisSaveDataMount2* mount_info, static Error saveDataMount(const OrbisSaveDataMount2* mount_info,
OrbisSaveDataMountResult* mount_result) { OrbisSaveDataMountResult* mount_result,
std::string_view title_id = g_game_serial) {
if (mount_info->userId < 0) { if (mount_info->userId < 0) {
return Error::INVALID_LOGIN_USER; return Error::INVALID_LOGIN_USER;
@ -369,8 +378,8 @@ static Error saveDataMount(const OrbisSaveDataMount2* mount_info,
// check backup status // check backup status
{ {
const auto save_path = SaveInstance::MakeDirSavePath(mount_info->userId, g_game_serial, const auto save_path =
mount_info->dirName->data); SaveInstance::MakeDirSavePath(mount_info->userId, title_id, mount_info->dirName->data);
if (Backup::IsBackupExecutingFor(save_path) && g_fw_ver) { if (Backup::IsBackupExecutingFor(save_path) && g_fw_ver) {
return Error::BACKUP_BUSY; return Error::BACKUP_BUSY;
} }
@ -409,7 +418,7 @@ static Error saveDataMount(const OrbisSaveDataMount2* mount_info,
return Error::MOUNT_FULL; return Error::MOUNT_FULL;
} }
SaveInstance save_instance{slot_num, mount_info->userId, g_game_serial, dir_name, SaveInstance save_instance{slot_num, mount_info->userId, std::string{title_id}, dir_name,
(int)mount_info->blocks}; (int)mount_info->blocks};
if (save_instance.Mounted()) { if (save_instance.Mounted()) {
@ -1573,6 +1582,7 @@ Error PS4_SYSV_ABI sceSaveDataSetupSaveDataMemory2(const OrbisSaveDataMemorySetu
SaveMemory::SetIcon(nullptr, 0); SaveMemory::SetIcon(nullptr, 0);
} }
} }
SaveMemory::TriggerSaveWithoutEvent();
if (g_fw_ver >= ElfInfo::FW_45 && result != nullptr) { if (g_fw_ver >= ElfInfo::FW_45 && result != nullptr) {
result->existedMemorySize = existed_size; result->existedMemorySize = existed_size;
} }
@ -1646,9 +1656,24 @@ Error PS4_SYSV_ABI sceSaveDataTerminate() {
return Error::OK; return Error::OK;
} }
int PS4_SYSV_ABI sceSaveDataTransferringMount() { Error PS4_SYSV_ABI sceSaveDataTransferringMount(const OrbisSaveDataTransferringMount* mount,
LOG_ERROR(Lib_SaveData, "(STUBBED) called"); OrbisSaveDataMountResult* mountResult) {
return ORBIS_OK; LOG_DEBUG(Lib_SaveData, "called");
if (!g_initialized) {
LOG_INFO(Lib_SaveData, "called without initialize");
return setNotInitializedError();
}
if (mount == nullptr || mount->titleId == nullptr || mount->dirName == nullptr) {
LOG_INFO(Lib_SaveData, "called with invalid parameter");
return Error::PARAMETER;
}
LOG_DEBUG(Lib_SaveData, "called titleId: {}, dirName: {}", mount->titleId->data.to_view(),
mount->dirName->data.to_view());
OrbisSaveDataMount2 mount_info{};
mount_info.userId = mount->userId;
mount_info.dirName = mount->dirName;
mount_info.mountMode = OrbisSaveDataMountMode::RDONLY;
return saveDataMount(&mount_info, mountResult, mount->titleId->data.to_string());
} }
Error PS4_SYSV_ABI sceSaveDataUmount(const OrbisSaveDataMountPoint* mountPoint) { Error PS4_SYSV_ABI sceSaveDataUmount(const OrbisSaveDataMountPoint* mountPoint) {

View file

@ -70,6 +70,7 @@ struct OrbisSaveDataMountInfo;
struct OrbisSaveDataMountPoint; struct OrbisSaveDataMountPoint;
struct OrbisSaveDataMountResult; struct OrbisSaveDataMountResult;
struct OrbisSaveDataRestoreBackupData; struct OrbisSaveDataRestoreBackupData;
struct OrbisSaveDataTransferringMount;
int PS4_SYSV_ABI sceSaveDataAbort(); int PS4_SYSV_ABI sceSaveDataAbort();
Error PS4_SYSV_ABI sceSaveDataBackup(const OrbisSaveDataBackup* backup); Error PS4_SYSV_ABI sceSaveDataBackup(const OrbisSaveDataBackup* backup);
@ -174,7 +175,8 @@ int PS4_SYSV_ABI sceSaveDataSupportedFakeBrokenStatus();
int PS4_SYSV_ABI sceSaveDataSyncCloudList(); int PS4_SYSV_ABI sceSaveDataSyncCloudList();
Error PS4_SYSV_ABI sceSaveDataSyncSaveDataMemory(OrbisSaveDataMemorySync* syncParam); Error PS4_SYSV_ABI sceSaveDataSyncSaveDataMemory(OrbisSaveDataMemorySync* syncParam);
Error PS4_SYSV_ABI sceSaveDataTerminate(); Error PS4_SYSV_ABI sceSaveDataTerminate();
int PS4_SYSV_ABI sceSaveDataTransferringMount(); Error PS4_SYSV_ABI sceSaveDataTransferringMount(const OrbisSaveDataTransferringMount* mount,
OrbisSaveDataMountResult* mountResult);
Error PS4_SYSV_ABI sceSaveDataUmount(const OrbisSaveDataMountPoint* mountPoint); Error PS4_SYSV_ABI sceSaveDataUmount(const OrbisSaveDataMountPoint* mountPoint);
int PS4_SYSV_ABI sceSaveDataUmountSys(); int PS4_SYSV_ABI sceSaveDataUmountSys();
Error PS4_SYSV_ABI sceSaveDataUmountWithBackup(const OrbisSaveDataMountPoint* mountPoint); Error PS4_SYSV_ABI sceSaveDataUmountWithBackup(const OrbisSaveDataMountPoint* mountPoint);