mirror of
https://github.com/boykopovar/AnyPS5.git
synced 2026-10-21 16:12:47 -05:00
Rework the local SaveData implementation into a general-purpose, title-agnostic backend used by both the native library and the standard libSceSaveData path: - Directory aliasing: long save directory names are hashed into short mount point aliases (persisted to disk) so they fit the SDK's fixed-size mount point buffer, with the aliases reversed on directory search. - Wildcard directory-name search (%/_ patterns) with sorting and optional reverse order, matching the DirNameSearch contract. - Save-data "memory" slots: small per-user, per-slot blobs the title can set up, read and write without mounting a directory, backed by files under the save root with a companion parameter blob, size and range validation on every access, and a dirty flag consulted on commit. - Async-flavored operations (backup, commit, memory sync) that queue SaveDataEvent records consumed through GetEventResult and can be bound to kernel event flags, plus transaction-resource and cancel/abort bookkeeping. - Atomic file writes (temp file + rename) so a mid-write crash never leaves a torn save on disk, and corrected/duplicated SDK error code constants. - Local storage app-status get/set/delete and transferring-mount support for PS4-to-PS5 style save transfers. The native library keeps its own lighter-weight mount/memory implementation (short "/_sm/<slot>" mount point aliases via the path-alias table) while gaining the same per-user memory-slot separation, atomic writes and bounds checking; the two implementations were merged by hand where upstream had independently touched the native Export.cpp in the same area (backup/event queue, short mount points) to keep both sets of improvements. None of this is game-specific: it is a general local save-data backend that works for any title and tolerates any user id.
68 lines
1.7 KiB
C++
68 lines
1.7 KiB
C++
#include <cstdint>
|
|
#include <cstdio>
|
|
#include <cstddef>
|
|
#include <cstring>
|
|
#include "SceTypes.hpp"
|
|
#include "prx/libSceSaveDataDialog.native/SaveDataDialog.hpp"
|
|
#include "prx/libc/include/General.hpp"
|
|
|
|
|
|
namespace {
|
|
// Throwing from these reaches std::terminate and aborts the game process.
|
|
int SoftFailNp(const char* func) {
|
|
std::fprintf(stderr, "[SOFT-NP] %s -> 0 (unimplemented SCE API - no-op)\n", func);
|
|
std::fflush(stderr);
|
|
return 0;
|
|
}
|
|
} // namespace
|
|
|
|
extern "C" {
|
|
|
|
int APS5_VABI sceSaveDataDialogClose(const void* close_param) {
|
|
(void)close_param;
|
|
return SoftFailNp(__func__);
|
|
}
|
|
|
|
int APS5_VABI sceSaveDataDialogGetResult(void* result) {
|
|
// Never return 0 with an untouched out-struct: the game would assert on the garbage later.
|
|
if (result == nullptr) {
|
|
return SAVE_DATA_DIALOG_ERROR_ARG_NULL;
|
|
}
|
|
auto* r = static_cast<SaveDataDialogResult*>(result);
|
|
std::memset(r, 0, sizeof(*r));
|
|
r->result = SAVE_DATA_DIALOG_RESULT_OK;
|
|
r->button_id = SAVE_DATA_DIALOG_BUTTON_ID_OK;
|
|
return SoftFailNp(__func__);
|
|
}
|
|
|
|
int APS5_VABI sceSaveDataDialogInitialize(void) {
|
|
return SoftFailNp(__func__);
|
|
}
|
|
|
|
int APS5_VABI sceSaveDataDialogIsReadyToDisplay(void) {
|
|
return SoftFailNp(__func__);
|
|
}
|
|
|
|
int APS5_VABI sceSaveDataDialogOpen(const void* param) {
|
|
(void)param;
|
|
return SoftFailNp(__func__);
|
|
}
|
|
|
|
int APS5_VABI sceSaveDataDialogProgressBarInc(int target, uint32_t delta) {
|
|
(void)target;
|
|
(void)delta;
|
|
return SoftFailNp(__func__);
|
|
}
|
|
|
|
int APS5_VABI sceSaveDataDialogProgressBarSetValue(int target, uint32_t rate) {
|
|
(void)target;
|
|
(void)rate;
|
|
return SoftFailNp(__func__);
|
|
}
|
|
|
|
int APS5_VABI sceSaveDataDialogTerminate(void) {
|
|
return SoftFailNp(__func__);
|
|
}
|
|
|
|
}
|