summaryrefslogtreecommitdiffstats
path: root/logic/BaseInstaller.cpp
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2014-02-01 19:37:16 +0100
committerPetr Mrázek <peterix@gmail.com>2014-02-01 19:37:16 +0100
commit1936bd181f57a554ce0dd757ffe9419100eb47f4 (patch)
treea22660979335746b930c88f353b4e29f1bbe9a2a /logic/BaseInstaller.cpp
parentb4b6091372310f4a811180cffde3ea5611881e6c (diff)
parent8637cce4333aaf56a231d5fab866b0e770436783 (diff)
downloadMultiMC-1936bd181f57a554ce0dd757ffe9419100eb47f4.tar
MultiMC-1936bd181f57a554ce0dd757ffe9419100eb47f4.tar.gz
MultiMC-1936bd181f57a554ce0dd757ffe9419100eb47f4.tar.lz
MultiMC-1936bd181f57a554ce0dd757ffe9419100eb47f4.tar.xz
MultiMC-1936bd181f57a554ce0dd757ffe9419100eb47f4.zip
Merge branch 'feature_derpstances' of https://github.com/02JanDal/MultiMC5 into feature_derpstances
Conflicts: gui/dialogs/OneSixModEditDialog.cpp logic/OneSixUpdate.cpp
Diffstat (limited to 'logic/BaseInstaller.cpp')
-rw-r--r--logic/BaseInstaller.cpp66
1 files changed, 66 insertions, 0 deletions
diff --git a/logic/BaseInstaller.cpp b/logic/BaseInstaller.cpp
new file mode 100644
index 00000000..92aa0c92
--- /dev/null
+++ b/logic/BaseInstaller.cpp
@@ -0,0 +1,66 @@
+/* Copyright 2013 MultiMC Contributors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "BaseInstaller.h"
+
+#include <QFile>
+
+#include "OneSixVersion.h"
+#include "OneSixLibrary.h"
+#include "OneSixInstance.h"
+
+#include "cmdutils.h"
+
+BaseInstaller::BaseInstaller()
+{
+
+}
+
+bool BaseInstaller::isApplied(OneSixInstance *on)
+{
+ return QFile::exists(filename(on->instanceRoot()));
+}
+
+bool BaseInstaller::add(OneSixInstance *to)
+{
+ if (!patchesDir(to->instanceRoot()).exists())
+ {
+ QDir(to->instanceRoot()).mkdir("patches");
+ }
+
+ if (isApplied(to))
+ {
+ if (!remove(to))
+ {
+ return false;
+ }
+ }
+
+ return true;
+}
+
+bool BaseInstaller::remove(OneSixInstance *from)
+{
+ return QFile::remove(filename(from->instanceRoot()));
+}
+
+QString BaseInstaller::filename(const QString &root) const
+{
+ return patchesDir(root).absoluteFilePath(id() + ".json");
+}
+QDir BaseInstaller::patchesDir(const QString &root) const
+{
+ return QDir(root + "/patches/");
+}