From 5bac732ea97281712d8f9f33d8afd34919eaa7f6 Mon Sep 17 00:00:00 2001 From: Konloch Date: Wed, 2 Oct 2024 18:42:21 -0600 Subject: [PATCH] Temp File API Update Refactoring & implemented automatic decompiler cleanup flag --- .../decompilers/impl/FernFlowerDecompiler.java | 2 +- .../the/bytecode/club/bytecodeviewer/util/TempFile.java | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/impl/FernFlowerDecompiler.java b/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/impl/FernFlowerDecompiler.java index d72a1d90..2b8b6315 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/impl/FernFlowerDecompiler.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/impl/FernFlowerDecompiler.java @@ -111,7 +111,7 @@ public class FernFlowerDecompiler extends AbstractDecompiler { //cleanup temp files if(tempFile != null) - tempFile.delete(); + tempFile.cleanup(); } return FERNFLOWER + " " + ERROR + "! " + ExceptionUI.SEND_STACKTRACE_TO + NL + NL diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/util/TempFile.java b/src/main/java/the/bytecode/club/bytecodeviewer/util/TempFile.java index 208036a5..d2d78683 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/util/TempFile.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/util/TempFile.java @@ -1,5 +1,7 @@ package the.bytecode.club.bytecodeviewer.util; +import the.bytecode.club.bytecodeviewer.Constants; + import java.io.File; import java.util.HashSet; @@ -59,8 +61,11 @@ public class TempFile createdFilePaths.add(file.getAbsolutePath()); } - public void delete() + public void cleanup() { + if(!Constants.DECOMPILERS_AUTOMATICALLY_CLEANUP) + return; + //delete all the items for(String path : createdFilePaths) {