extracting of pkg files (no pfs_image) is working okay . Some id->name conversions probably missing

This commit is contained in:
georgemoralis 2022-11-17 16:01:52 +02:00
parent 5bbfa83b36
commit af6071ae95
2 changed files with 16 additions and 1 deletions

View File

@ -1,5 +1,6 @@
#include "PKG.h"
#include "../../core/FsFile.h"
#include <direct.h>
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);

View File

@ -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="";