summaryrefslogtreecommitdiffstats
path: root/api/logic
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2018-01-08 00:59:47 +0100
committerPetr Mrázek <peterix@gmail.com>2018-01-08 00:59:47 +0100
commit1dbc4e16f7dfa990de3f03af71d576b8e50b4bca (patch)
tree3a735fa62566ac860c93b012a3bda1797e43808a /api/logic
parent0636c03d7c08a90de5180e20dd6106c4cac34a23 (diff)
downloadMultiMC-1dbc4e16f7dfa990de3f03af71d576b8e50b4bca.tar
MultiMC-1dbc4e16f7dfa990de3f03af71d576b8e50b4bca.tar.gz
MultiMC-1dbc4e16f7dfa990de3f03af71d576b8e50b4bca.tar.lz
MultiMC-1dbc4e16f7dfa990de3f03af71d576b8e50b4bca.tar.xz
MultiMC-1dbc4e16f7dfa990de3f03af71d576b8e50b4bca.zip
NOISSUE remove the jar-modded jar after the instance finishes
Diffstat (limited to 'api/logic')
-rw-r--r--api/logic/minecraft/launch/ModMinecraftJar.cpp30
-rw-r--r--api/logic/minecraft/launch/ModMinecraftJar.h3
2 files changed, 26 insertions, 7 deletions
diff --git a/api/logic/minecraft/launch/ModMinecraftJar.cpp b/api/logic/minecraft/launch/ModMinecraftJar.cpp
index 9b5d3b20..15bb7bb3 100644
--- a/api/logic/minecraft/launch/ModMinecraftJar.cpp
+++ b/api/logic/minecraft/launch/ModMinecraftJar.cpp
@@ -35,15 +35,11 @@ void ModMinecraftJar::executeTask()
{
emitFailed(tr("Couldn't create the bin folder for Minecraft.jar"));
}
+
auto finalJarPath = QDir(m_inst->binRoot()).absoluteFilePath("minecraft.jar");
- QFile finalJar(finalJarPath);
- if(finalJar.exists())
+ if(!removeJar())
{
- if(!finalJar.remove())
- {
- emitFailed(tr("Couldn't remove stale jar file: %1").arg(finalJarPath));
- return;
- }
+ emitFailed(tr("Couldn't remove stale jar file: %1").arg(finalJarPath));
}
// create temporary modded jar, if needed
@@ -64,3 +60,23 @@ void ModMinecraftJar::executeTask()
}
emitSucceeded();
}
+
+void ModMinecraftJar::finalize()
+{
+ removeJar();
+}
+
+bool ModMinecraftJar::removeJar()
+{
+ auto m_inst = std::dynamic_pointer_cast<MinecraftInstance>(m_parent->instance());
+ auto finalJarPath = QDir(m_inst->binRoot()).absoluteFilePath("minecraft.jar");
+ QFile finalJar(finalJarPath);
+ if(finalJar.exists())
+ {
+ if(!finalJar.remove())
+ {
+ return false;
+ }
+ }
+ return true;
+}
diff --git a/api/logic/minecraft/launch/ModMinecraftJar.h b/api/logic/minecraft/launch/ModMinecraftJar.h
index ab8d7dca..1f038600 100644
--- a/api/logic/minecraft/launch/ModMinecraftJar.h
+++ b/api/logic/minecraft/launch/ModMinecraftJar.h
@@ -30,4 +30,7 @@ public:
{
return false;
}
+ void finalize() override;
+private:
+ bool removeJar();
};