diff options
author | Petr Mrázek <peterix@gmail.com> | 2013-08-14 08:13:41 +0200 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2013-08-14 08:13:41 +0200 |
commit | 77e80665422c4e97e2286418ab55e20c4030023b (patch) | |
tree | fe8b8d19de00e07f6bb8908a0be1973f9e93dd9a /libutil | |
parent | ff33d4a1a48abf1442cde77c2253f071d0870d50 (diff) | |
download | MultiMC-77e80665422c4e97e2286418ab55e20c4030023b.tar MultiMC-77e80665422c4e97e2286418ab55e20c4030023b.tar.gz MultiMC-77e80665422c4e97e2286418ab55e20c4030023b.tar.lz MultiMC-77e80665422c4e97e2286418ab55e20c4030023b.tar.xz MultiMC-77e80665422c4e97e2286418ab55e20c4030023b.zip |
Working on legacy support, incomplete.
Diffstat (limited to 'libutil')
-rw-r--r-- | libutil/include/pathutils.h | 3 | ||||
-rw-r--r-- | libutil/src/pathutils.cpp | 19 |
2 files changed, 22 insertions, 0 deletions
diff --git a/libutil/include/pathutils.h b/libutil/include/pathutils.h index c9a52ced..d4f41da3 100644 --- a/libutil/include/pathutils.h +++ b/libutil/include/pathutils.h @@ -31,4 +31,7 @@ LIBUTIL_EXPORT QString DirNameFromString(QString string, QString inDir = "."); LIBUTIL_EXPORT bool ensurePathExists(QString filenamepath); +LIBUTIL_EXPORT bool copyPath(QString src, QString dst); + + #endif // PATHUTILS_H diff --git a/libutil/src/pathutils.cpp b/libutil/src/pathutils.cpp index 083fe98d..97287840 100644 --- a/libutil/src/pathutils.cpp +++ b/libutil/src/pathutils.cpp @@ -73,3 +73,22 @@ bool ensurePathExists(QString filenamepath) return (dir.mkpath ( a.path() )); } +bool copyPath(QString src, QString dst) +{ + QDir dir(src); + if (!dir.exists()) + return false; + + foreach (QString d, dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot)) + { + QString dst_path = dst + QDir::separator() + d; + dir.mkpath(dst_path); + copyPath(src+ QDir::separator() + d, dst_path); + } + + foreach (QString f, dir.entryList(QDir::Files)) + { + QFile::copy(src + QDir::separator() + f, dst + QDir::separator() + f); + } + return true; +} |