GH-93 add an option to not copy saves on instance copy

This commit is contained in:
Petr Mrázek
2015-10-10 05:55:55 +02:00
parent 4fbcb3efb9
commit 44db72ead5
10 changed files with 138 additions and 60 deletions

View File

@@ -38,6 +38,7 @@
#include "ftb/FTBPlugin.h"
#include "NullInstance.h"
#include "FileSystem.h"
#include "pathmatcher/RegexpMatcher.h"
const static int GROUP_FILE_FORMAT_VERSION = 1;
@@ -486,9 +487,18 @@ InstanceList::InstCreateError
InstanceList::copyInstance(InstancePtr &newInstance, InstancePtr &oldInstance, const QString &instDir, bool copySaves)
{
QDir rootDir(instDir);
std::unique_ptr<IPathMatcher> matcher;
if(!copySaves)
{
auto matcherReal = new RegexpMatcher("[.]?minecraft/saves");
matcherReal->caseSensitive(false);
matcher.reset(matcherReal);
}
qDebug() << instDir.toUtf8();
if (!FS::copyPath(oldInstance->instanceRoot(), instDir, false))
FS::copy folderCopy(oldInstance->instanceRoot(), instDir);
folderCopy.followSymlinks(false).blacklist(matcher.get());
if (!folderCopy())
{
FS::deletePath(instDir);
return InstanceList::CantCreateDir;