mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-05-30 23:33:17 +00:00
SaveLib PR related fixes (#1011)
* Safety checks in all SFO readings * SaveData: log backup error and continue & fix possible concurrent file editing * SaveData: Fix issue with old firmwares
This commit is contained in:
parent
edde0a3e7e
commit
581ddfec4d
11 changed files with 163 additions and 74 deletions
|
@ -32,16 +32,31 @@ public:
|
|||
QString iconpath = QString::fromStdString(game.icon_path);
|
||||
game.icon = QImage(iconpath);
|
||||
game.pic_path = game.path + "/sce_sys/pic1.png";
|
||||
game.name = *psf.GetString("TITLE");
|
||||
game.serial = *psf.GetString("TITLE_ID");
|
||||
game.region =
|
||||
GameListUtils::GetRegion(psf.GetString("CONTENT_ID")->at(0)).toStdString();
|
||||
u32 fw_int = *psf.GetInteger("SYSTEM_VER");
|
||||
QString fw = QString::number(fw_int, 16);
|
||||
QString fw_ = fw.length() > 7 ? QString::number(fw_int, 16).left(3).insert(2, '.')
|
||||
: fw.left(3).insert(1, '.');
|
||||
game.fw = (fw_int == 0) ? "0.00" : fw_.toStdString();
|
||||
game.version = *psf.GetString("APP_VER");
|
||||
if (const auto title = psf.GetString("TITLE"); title.has_value()) {
|
||||
game.name = *title;
|
||||
}
|
||||
if (const auto title_id = psf.GetString("TITLE_ID"); title_id.has_value()) {
|
||||
game.serial = *title_id;
|
||||
}
|
||||
if (const auto content_id = psf.GetString("CONTENT_ID");
|
||||
content_id.has_value() && !content_id->empty()) {
|
||||
game.region = GameListUtils::GetRegion(content_id->at(0)).toStdString();
|
||||
}
|
||||
if (const auto fw_int_opt = psf.GetInteger("SYSTEM_VER"); fw_int_opt.has_value()) {
|
||||
auto fw_int = *fw_int_opt;
|
||||
if (fw_int == 0) {
|
||||
game.fw = "0.00";
|
||||
} else {
|
||||
QString fw = QString::number(fw_int, 16);
|
||||
QString fw_ = fw.length() > 7
|
||||
? QString::number(fw_int, 16).left(3).insert(2, '.')
|
||||
: fw.left(3).insert(1, '.');
|
||||
game.fw = fw_.toStdString();
|
||||
}
|
||||
}
|
||||
if (auto app_ver = psf.GetString("APP_VER"); app_ver.has_value()) {
|
||||
game.version = *app_ver;
|
||||
}
|
||||
}
|
||||
return game;
|
||||
}
|
||||
|
|
|
@ -96,25 +96,37 @@ public:
|
|||
QTableWidgetItem* valueItem;
|
||||
switch (entry.param_fmt) {
|
||||
case PSFEntryFmt::Binary: {
|
||||
|
||||
const auto bin = *psf.GetBinary(entry.key);
|
||||
std::string text;
|
||||
text.reserve(bin.size() * 2);
|
||||
for (const auto& c : bin) {
|
||||
static constexpr char hex[] = "0123456789ABCDEF";
|
||||
text.push_back(hex[c >> 4 & 0xF]);
|
||||
text.push_back(hex[c & 0xF]);
|
||||
const auto bin = psf.GetBinary(entry.key);
|
||||
if (!bin.has_value()) {
|
||||
valueItem = new QTableWidgetItem(QString("Unknown"));
|
||||
} else {
|
||||
std::string text;
|
||||
text.reserve(bin->size() * 2);
|
||||
for (const auto& c : *bin) {
|
||||
static constexpr char hex[] = "0123456789ABCDEF";
|
||||
text.push_back(hex[c >> 4 & 0xF]);
|
||||
text.push_back(hex[c & 0xF]);
|
||||
}
|
||||
valueItem = new QTableWidgetItem(QString::fromStdString(text));
|
||||
}
|
||||
valueItem = new QTableWidgetItem(QString::fromStdString(text));
|
||||
} break;
|
||||
case PSFEntryFmt::Text: {
|
||||
auto text = *psf.GetString(entry.key);
|
||||
valueItem = new QTableWidgetItem(QString::fromStdString(std::string{text}));
|
||||
auto text = psf.GetString(entry.key);
|
||||
if (!text.has_value()) {
|
||||
valueItem = new QTableWidgetItem(QString("Unknown"));
|
||||
} else {
|
||||
valueItem =
|
||||
new QTableWidgetItem(QString::fromStdString(std::string{*text}));
|
||||
}
|
||||
} break;
|
||||
case PSFEntryFmt::Integer: {
|
||||
auto integer = *psf.GetInteger(entry.key);
|
||||
valueItem =
|
||||
new QTableWidgetItem(QString("0x") + QString::number(integer, 16));
|
||||
auto integer = psf.GetInteger(entry.key);
|
||||
if (!integer.has_value()) {
|
||||
valueItem = new QTableWidgetItem(QString("Unknown"));
|
||||
} else {
|
||||
valueItem =
|
||||
new QTableWidgetItem(QString("0x") + QString::number(*integer, 16));
|
||||
}
|
||||
} break;
|
||||
}
|
||||
|
||||
|
|
|
@ -636,9 +636,19 @@ void MainWindow::InstallDragDropPkg(std::filesystem::path file, int pkgNum, int
|
|||
QMessageBox msgBox;
|
||||
msgBox.setWindowTitle(tr("PKG Extraction"));
|
||||
|
||||
psf.Open(pkg.sfo);
|
||||
if (!psf.Open(pkg.sfo)) {
|
||||
QMessageBox::critical(this, tr("PKG ERROR"),
|
||||
"Could not read SFO. Check log for details");
|
||||
return;
|
||||
}
|
||||
|
||||
std::string content_id{*psf.GetString("CONTENT_ID")};
|
||||
std::string content_id;
|
||||
if (auto value = psf.GetString("CONTENT_ID"); value.has_value()) {
|
||||
content_id = std::string{*value};
|
||||
} else {
|
||||
QMessageBox::critical(this, tr("PKG ERROR"), "PSF file there is no CONTENT_ID");
|
||||
return;
|
||||
}
|
||||
std::string entitlement_label = Common::SplitString(content_id, '-')[2];
|
||||
|
||||
auto addon_extract_path = Common::FS::GetUserPath(Common::FS::PathType::AddonsDir) /
|
||||
|
@ -647,11 +657,21 @@ void MainWindow::InstallDragDropPkg(std::filesystem::path file, int pkgNum, int
|
|||
auto category = psf.GetString("CATEGORY");
|
||||
|
||||
if (pkgType.contains("PATCH")) {
|
||||
QString pkg_app_version =
|
||||
QString::fromStdString(std::string{*psf.GetString("APP_VER")});
|
||||
QString pkg_app_version;
|
||||
if (auto app_ver = psf.GetString("APP_VER"); app_ver.has_value()) {
|
||||
pkg_app_version = QString::fromStdString(std::string{*app_ver});
|
||||
} else {
|
||||
QMessageBox::critical(this, tr("PKG ERROR"), "PSF file there is no APP_VER");
|
||||
return;
|
||||
}
|
||||
psf.Open(extract_path / "sce_sys" / "param.sfo");
|
||||
QString game_app_version =
|
||||
QString::fromStdString(std::string{*psf.GetString("APP_VER")});
|
||||
QString game_app_version;
|
||||
if (auto app_ver = psf.GetString("APP_VER"); app_ver.has_value()) {
|
||||
game_app_version = QString::fromStdString(std::string{*app_ver});
|
||||
} else {
|
||||
QMessageBox::critical(this, tr("PKG ERROR"), "PSF file there is no APP_VER");
|
||||
return;
|
||||
}
|
||||
double appD = game_app_version.toDouble();
|
||||
double pkgD = pkg_app_version.toDouble();
|
||||
if (pkgD == appD) {
|
||||
|
|
|
@ -110,12 +110,16 @@ void PKGViewer::ProcessPKGInfo() {
|
|||
#endif
|
||||
package.Open(path);
|
||||
psf.Open(package.sfo);
|
||||
QString title_name = QString::fromStdString(std::string{*psf.GetString("TITLE")});
|
||||
QString title_id = QString::fromStdString(std::string{*psf.GetString("TITLE_ID")});
|
||||
QString app_type = game_list_util.GetAppType(*psf.GetInteger("APP_TYPE"));
|
||||
QString app_version = QString::fromStdString(std::string{*psf.GetString("APP_VER")});
|
||||
QString title_category = QString::fromStdString(std::string{*psf.GetString("CATEGORY")});
|
||||
QString pkg_size = game_list_util.FormatSize(package.GetPkgHeader().pkg_size);
|
||||
QString title_name =
|
||||
QString::fromStdString(std::string{psf.GetString("TITLE").value_or("Unknown")});
|
||||
QString title_id =
|
||||
QString::fromStdString(std::string{psf.GetString("TITLE_ID").value_or("Unknown")});
|
||||
QString app_type = GameListUtils::GetAppType(psf.GetInteger("APP_TYPE").value_or(0));
|
||||
QString app_version =
|
||||
QString::fromStdString(std::string{psf.GetString("APP_VER").value_or("Unknown")});
|
||||
QString title_category =
|
||||
QString::fromStdString(std::string{psf.GetString("CATEGORY").value_or("Unknown")});
|
||||
QString pkg_size = GameListUtils::FormatSize(package.GetPkgHeader().pkg_size);
|
||||
pkg_content_flag = package.GetPkgHeader().pkg_content_flags;
|
||||
QString flagss = "";
|
||||
for (const auto& flag : package.flagNames) {
|
||||
|
@ -126,11 +130,17 @@ void PKGViewer::ProcessPKGInfo() {
|
|||
}
|
||||
}
|
||||
|
||||
u32 fw_int = *psf.GetInteger("SYSTEM_VER");
|
||||
QString fw = QString::number(fw_int, 16);
|
||||
QString fw_ = fw.length() > 7 ? QString::number(fw_int, 16).left(3).insert(2, '.')
|
||||
QString fw_ = "Unknown";
|
||||
if (const auto fw_int_opt = psf.GetInteger("SYSTEM_VER"); fw_int_opt.has_value()) {
|
||||
const u32 fw_int = *fw_int_opt;
|
||||
if (fw_int == 0) {
|
||||
fw_ = "0.00";
|
||||
} else {
|
||||
QString fw = QString::number(fw_int, 16);
|
||||
fw_ = fw.length() > 7 ? QString::number(fw_int, 16).left(3).insert(2, '.')
|
||||
: fw.left(3).insert(1, '.');
|
||||
fw_ = (fw_int == 0) ? "0.00" : fw_;
|
||||
}
|
||||
}
|
||||
char region = package.GetPkgHeader().pkg_content_id[0];
|
||||
QString pkg_info = "";
|
||||
if (title_category == "gd" && !flagss.contains("PATCH")) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue