From af6071ae95ca3bdd50d0ba0d1db1c896cf4c1a82 Mon Sep 17 00:00:00 2001 From: georgemoralis Date: Thu, 17 Nov 2022 16:01:52 +0200 Subject: [PATCH] extracting of pkg files (no pfs_image) is working okay . Some id->name conversions probably missing --- shadPS4/emulator/fileFormat/PKG.cpp | 15 +++++++++++++++ shadPS4/emulator/fileFormat/PKG.h | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/shadPS4/emulator/fileFormat/PKG.cpp b/shadPS4/emulator/fileFormat/PKG.cpp index 9fbe3d67..17b3c8c1 100644 --- a/shadPS4/emulator/fileFormat/PKG.cpp +++ b/shadPS4/emulator/fileFormat/PKG.cpp @@ -1,5 +1,6 @@ #include "PKG.h" #include "../../core/FsFile.h" +#include PKG::PKG() { @@ -57,6 +58,20 @@ bool PKG::extract(const std::string& filepath, const std::string& extractPath, s std::string name = getEntryNameByType(entry.id); if (!name.empty()) { + std::size_t pos = name.find("/");//check if we have a directory (assuming we only have 1 level of subdirectories) + if (pos != std::string::npos) + { + //directory found + std::string dir = name.substr(0, pos+1);//include '/' as well + std::string path = extractPath + dir; + _mkdir(path.c_str());//make dir + std::string file = name.substr(pos + 1);//read filename + FsFile out; + out.Open(path + file, fsWrite); + out.Write(pkg + entry.offset, entry.size); + out.Close(); + + } //found an name use it FsFile out; out.Open(extractPath + name, fsWrite); diff --git a/shadPS4/emulator/fileFormat/PKG.h b/shadPS4/emulator/fileFormat/PKG.h index 33b26ede..a2d0afa1 100644 --- a/shadPS4/emulator/fileFormat/PKG.h +++ b/shadPS4/emulator/fileFormat/PKG.h @@ -174,7 +174,7 @@ public: { 0x1280, "icon0.dds" }, { 0x12A0, "pic0.dds" }, { 0x12C0, "pic1.dds" }, - //{ 0x1400, "trophy/trophy00.trp" } + { 0x1400, "trophy/trophy00.trp" } }; std::string entry_name="";