summaryrefslogtreecommitdiffstats
path: root/depends
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2013-08-24 03:09:46 +0200
committerPetr Mrázek <peterix@gmail.com>2013-08-24 03:09:46 +0200
commite3b55067eb51ee82e72b41a1919406d768e00b89 (patch)
treea22158bc63242191463d450d1a3f37eeb37bba5b /depends
parentb78123166627139777fbd206866ee0d1c8bcd040 (diff)
downloadMultiMC-e3b55067eb51ee82e72b41a1919406d768e00b89.tar
MultiMC-e3b55067eb51ee82e72b41a1919406d768e00b89.tar.gz
MultiMC-e3b55067eb51ee82e72b41a1919406d768e00b89.tar.lz
MultiMC-e3b55067eb51ee82e72b41a1919406d768e00b89.tar.xz
MultiMC-e3b55067eb51ee82e72b41a1919406d768e00b89.zip
Legacy jar reassembly, base of proper custom jar support
Diffstat (limited to 'depends')
-rw-r--r--depends/quazip/JlCompress.cpp2
-rw-r--r--depends/quazip/JlCompress.h2
-rw-r--r--depends/util/include/pathutils.h12
-rw-r--r--depends/util/src/pathutils.cpp23
4 files changed, 33 insertions, 6 deletions
diff --git a/depends/quazip/JlCompress.cpp b/depends/quazip/JlCompress.cpp
index 69832140..19bf6246 100644
--- a/depends/quazip/JlCompress.cpp
+++ b/depends/quazip/JlCompress.cpp
@@ -1,7 +1,7 @@
#include "JlCompress.h"
#include <QDebug>
-static bool copyData(QIODevice &inFile, QIODevice &outFile)
+bool JlCompress::copyData(QIODevice &inFile, QIODevice &outFile)
{
while (!inFile.atEnd()) {
char buf[4096];
diff --git a/depends/quazip/JlCompress.h b/depends/quazip/JlCompress.h
index 29d6191f..9679de7c 100644
--- a/depends/quazip/JlCompress.h
+++ b/depends/quazip/JlCompress.h
@@ -51,6 +51,8 @@ private:
static bool removeFile(QStringList listFile);
public:
+ /// copy data from inFile to outFile
+ static bool copyData(QIODevice &inFile, QIODevice &outFile);
/// Compress a single file.
/**
\param fileCompressed The name of the archive.
diff --git a/depends/util/include/pathutils.h b/depends/util/include/pathutils.h
index 40bb9e74..cea3a39a 100644
--- a/depends/util/include/pathutils.h
+++ b/depends/util/include/pathutils.h
@@ -29,7 +29,17 @@ LIBUTIL_EXPORT QString RemoveInvalidFilenameChars(QString string, QChar replaceW
LIBUTIL_EXPORT QString DirNameFromString(QString string, QString inDir = ".");
-LIBUTIL_EXPORT bool ensurePathExists(QString filenamepath);
+/**
+ * Creates all the folders in a path for the specified path
+ * last segment of the path is treated as a file name and is ignored!
+ */
+LIBUTIL_EXPORT bool ensureFilePathExists(QString filenamepath);
+
+/**
+ * Creates all the folders in a path for the specified path
+ * last segment of the path is treated as a folder name and is created!
+ */
+LIBUTIL_EXPORT bool ensureFolderPathExists(QString filenamepath);
LIBUTIL_EXPORT bool copyPath(QString src, QString dst);
diff --git a/depends/util/src/pathutils.cpp b/depends/util/src/pathutils.cpp
index 5bafdf0f..0836567d 100644
--- a/depends/util/src/pathutils.cpp
+++ b/depends/util/src/pathutils.cpp
@@ -19,6 +19,7 @@
#include <QDir>
#include <QDesktopServices>
#include <QUrl>
+#include <QDebug>
QString PathCombine(QString path1, QString path2)
{
@@ -68,24 +69,38 @@ QString DirNameFromString(QString string, QString inDir)
return dirName;
}
-bool ensurePathExists(QString filenamepath)
+bool ensureFilePathExists(QString filenamepath)
{
QFileInfo a ( filenamepath );
QDir dir;
- return (dir.mkpath ( a.filePath() ));
+ QString ensuredPath = a.path();
+ bool success = dir.mkpath ( ensuredPath );
+ qDebug() << "ensureFilePathExists:" << success << ensuredPath << filenamepath;
+ return success;
}
+bool ensureFolderPathExists(QString foldernamepath)
+{
+ QFileInfo a ( foldernamepath );
+ QDir dir;
+ QString ensuredPath = a.filePath();
+ bool success = dir.mkpath ( ensuredPath );
+ qDebug() << "ensureFolderPathExists:" << success << ensuredPath << foldernamepath;
+ return success;
+}
+
+
bool copyPath(QString src, QString dst)
{
QDir dir(src);
if (!dir.exists())
return false;
- if(!ensurePathExists(dst))
+ if(!ensureFolderPathExists(dst))
return false;
foreach (QString d, dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot))
{
- QString inner_src = src+ QDir::separator() + d;
+ QString inner_src = src + QDir::separator() + d;
QString inner_dst = dst + QDir::separator() + d;
copyPath(inner_src, inner_dst);
}