mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-01-01 12:46:01 +00:00
Save lib fixes III (#1069)
* SaveDataMemory: increase memory if needed * SaveDataDialog: fix intention to hide save details
This commit is contained in:
parent
3d5a6203e1
commit
ddb82a690b
|
@ -79,55 +79,58 @@ SaveDialogState::SaveDialogState(const OrbisSaveDataDialogParam& param) {
|
||||||
this->title_id = item->titleId->data.to_string();
|
this->title_id = item->titleId->data.to_string();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (u32 i = 0; i < item->dirNameNum; i++) {
|
if (item->dirName != nullptr) {
|
||||||
const auto dir_name = item->dirName[i].data.to_view();
|
for (u32 i = 0; i < item->dirNameNum; i++) {
|
||||||
|
const auto dir_name = item->dirName[i].data.to_view();
|
||||||
|
|
||||||
if (dir_name.empty()) {
|
if (dir_name.empty()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto dir_path = SaveInstance::MakeDirSavePath(user_id, title_id, dir_name);
|
auto dir_path = SaveInstance::MakeDirSavePath(user_id, title_id, dir_name);
|
||||||
|
|
||||||
auto param_sfo_path = dir_path / "sce_sys" / "param.sfo";
|
auto param_sfo_path = dir_path / "sce_sys" / "param.sfo";
|
||||||
if (!std::filesystem::exists(param_sfo_path)) {
|
if (!std::filesystem::exists(param_sfo_path)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
PSF param_sfo;
|
PSF param_sfo;
|
||||||
param_sfo.Open(param_sfo_path);
|
param_sfo.Open(param_sfo_path);
|
||||||
|
|
||||||
auto last_write = param_sfo.GetLastWrite();
|
auto last_write = param_sfo.GetLastWrite();
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
auto utc_time = std::chrono::file_clock::to_utc(last_write);
|
auto utc_time = std::chrono::file_clock::to_utc(last_write);
|
||||||
#else
|
#else
|
||||||
auto utc_time = std::chrono::file_clock::to_sys(last_write);
|
auto utc_time = std::chrono::file_clock::to_sys(last_write);
|
||||||
#endif
|
#endif
|
||||||
std::string date_str = fmt::format("{:%d %b, %Y %R}", utc_time);
|
std::string date_str = fmt::format("{:%d %b, %Y %R}", utc_time);
|
||||||
|
|
||||||
size_t size = Common::FS::GetDirectorySize(dir_path);
|
size_t size = Common::FS::GetDirectorySize(dir_path);
|
||||||
std::string size_str = SpaceSizeToString(size);
|
std::string size_str = SpaceSizeToString(size);
|
||||||
|
|
||||||
auto icon_path = dir_path / "sce_sys" / "icon0.png";
|
auto icon_path = dir_path / "sce_sys" / "icon0.png";
|
||||||
RefCountedTexture icon;
|
RefCountedTexture icon;
|
||||||
if (std::filesystem::exists(icon_path)) {
|
if (std::filesystem::exists(icon_path)) {
|
||||||
icon = RefCountedTexture::DecodePngFile(icon_path);
|
icon = RefCountedTexture::DecodePngFile(icon_path);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool is_corrupted = std::filesystem::exists(dir_path / "sce_sys" / "corrupted");
|
||||||
|
|
||||||
|
this->save_list.emplace_back(Item{
|
||||||
|
.dir_name = std::string{dir_name},
|
||||||
|
.icon = icon,
|
||||||
|
|
||||||
|
.title =
|
||||||
|
std::string{param_sfo.GetString(SaveParams::MAINTITLE).value_or("Unknown")},
|
||||||
|
.subtitle = std::string{param_sfo.GetString(SaveParams::SUBTITLE).value_or("")},
|
||||||
|
.details = std::string{param_sfo.GetString(SaveParams::DETAIL).value_or("")},
|
||||||
|
.date = date_str,
|
||||||
|
.size = size_str,
|
||||||
|
.last_write = param_sfo.GetLastWrite(),
|
||||||
|
.pfo = param_sfo,
|
||||||
|
.is_corrupted = is_corrupted,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
bool is_corrupted = std::filesystem::exists(dir_path / "sce_sys" / "corrupted");
|
|
||||||
|
|
||||||
this->save_list.emplace_back(Item{
|
|
||||||
.dir_name = std::string{dir_name},
|
|
||||||
.icon = icon,
|
|
||||||
|
|
||||||
.title = std::string{param_sfo.GetString(SaveParams::MAINTITLE).value_or("Unknown")},
|
|
||||||
.subtitle = std::string{param_sfo.GetString(SaveParams::SUBTITLE).value_or("")},
|
|
||||||
.details = std::string{param_sfo.GetString(SaveParams::DETAIL).value_or("")},
|
|
||||||
.date = date_str,
|
|
||||||
.size = size_str,
|
|
||||||
.last_write = param_sfo.GetLastWrite(),
|
|
||||||
.pfo = param_sfo,
|
|
||||||
.is_corrupted = is_corrupted,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type == DialogType::SAVE && item->newItem != nullptr) {
|
if (type == DialogType::SAVE && item->newItem != nullptr) {
|
||||||
|
@ -299,7 +302,7 @@ SaveDialogState::ProgressBarState::ProgressBarState(const SaveDialogState& state
|
||||||
} else {
|
} else {
|
||||||
switch (bar.sysMsgType) {
|
switch (bar.sysMsgType) {
|
||||||
case ProgressSystemMessageType::INVALID:
|
case ProgressSystemMessageType::INVALID:
|
||||||
this->msg = "INVALID";
|
this->msg = "";
|
||||||
break;
|
break;
|
||||||
case ProgressSystemMessageType::PROGRESS:
|
case ProgressSystemMessageType::PROGRESS:
|
||||||
switch (state.type) {
|
switch (state.type) {
|
||||||
|
|
|
@ -268,9 +268,6 @@ bool TriggerSave() {
|
||||||
|
|
||||||
void ReadMemory(void* buf, size_t buf_size, int64_t offset) {
|
void ReadMemory(void* buf, size_t buf_size, int64_t offset) {
|
||||||
std::scoped_lock lk{g_saving_memory_mutex};
|
std::scoped_lock lk{g_saving_memory_mutex};
|
||||||
if (offset > g_save_memory.size()) {
|
|
||||||
UNREACHABLE_MSG("ReadMemory out of bounds");
|
|
||||||
}
|
|
||||||
if (offset + buf_size > g_save_memory.size()) {
|
if (offset + buf_size > g_save_memory.size()) {
|
||||||
UNREACHABLE_MSG("ReadMemory out of bounds");
|
UNREACHABLE_MSG("ReadMemory out of bounds");
|
||||||
}
|
}
|
||||||
|
@ -279,11 +276,8 @@ void ReadMemory(void* buf, size_t buf_size, int64_t offset) {
|
||||||
|
|
||||||
void WriteMemory(void* buf, size_t buf_size, int64_t offset) {
|
void WriteMemory(void* buf, size_t buf_size, int64_t offset) {
|
||||||
std::scoped_lock lk{g_saving_memory_mutex};
|
std::scoped_lock lk{g_saving_memory_mutex};
|
||||||
if (offset > g_save_memory.size()) {
|
|
||||||
UNREACHABLE_MSG("WriteMemory out of bounds");
|
|
||||||
}
|
|
||||||
if (offset + buf_size > g_save_memory.size()) {
|
if (offset + buf_size > g_save_memory.size()) {
|
||||||
UNREACHABLE_MSG("WriteMemory out of bounds");
|
g_save_memory.resize(offset + buf_size);
|
||||||
}
|
}
|
||||||
std::memcpy(g_save_memory.data() + offset, buf, buf_size);
|
std::memcpy(g_save_memory.data() + offset, buf, buf_size);
|
||||||
g_memory_dirty = true;
|
g_memory_dirty = true;
|
||||||
|
|
Loading…
Reference in a new issue