diff --git a/shadPS4/emulator/fileFormat/PKG.cpp b/shadPS4/emulator/fileFormat/PKG.cpp index 35010db6..c27f3ab8 100644 --- a/shadPS4/emulator/fileFormat/PKG.cpp +++ b/shadPS4/emulator/fileFormat/PKG.cpp @@ -1,6 +1,8 @@ #include "PKG.h" #include "../../core/FsFile.h" #include +#include +#include PKG::PKG() { @@ -73,27 +75,15 @@ 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(); - - } - else - { - FsFile out; - out.Open(extractPath + name, fsWrite); - out.Write(pkg + entry.offset, entry.size); - out.Close(); + QString filepath= QString::fromStdString(extractPath+name); + QDir dir = QFileInfo(filepath).dir(); + if (!dir.exists()) { + dir.mkpath(dir.path()); } + FsFile out; + out.Open(extractPath + name, fsWrite); + out.Write(pkg + entry.offset, entry.size); + out.Close(); } else {