mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2024-12-27 10:09:52 +00:00
simplify directory creating using qt
This commit is contained in:
parent
2ef7f6fdc3
commit
44e60f779c
|
@ -1,6 +1,8 @@
|
|||
#include "PKG.h"
|
||||
#include "../../core/FsFile.h"
|
||||
#include <direct.h>
|
||||
#include <QString>
|
||||
#include <QDir>
|
||||
|
||||
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
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue