From 44e60f779caf3196ec33c80e7c994c3ce7eb2715 Mon Sep 17 00:00:00 2001 From: georgemoralis Date: Tue, 28 Feb 2023 18:44:11 +0200 Subject: [PATCH] simplify directory creating using qt --- shadPS4/emulator/fileFormat/PKG.cpp | 30 ++++++++++------------------- 1 file changed, 10 insertions(+), 20 deletions(-) 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 {