Replaced Old Disk-Lib Library

This commit is contained in:
Konloch 2024-10-05 00:09:19 -06:00
parent 17d97368f3
commit 1494eca99e

AI 샘플 코드 생성 중입니다

Loading...
21 changed files with 144 additions and 98 deletions

View File

@ -20,8 +20,8 @@ package the.bytecode.club.bytecodeviewer;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.konloch.disklib.DiskReader;
import com.konloch.taskmanager.TaskManager;
import me.konloch.kontainer.io.DiskReader;
import org.apache.commons.io.FileUtils;
import org.objectweb.asm.tree.ClassNode;
import the.bytecode.club.bytecodeviewer.api.BCV;
@ -588,7 +588,7 @@ public class BytecodeViewer
try
{
PluginWriter writer = new PluginWriter(DiskReader.loadAsString(file.getAbsolutePath()), file.getName());
PluginWriter writer = new PluginWriter(DiskReader.readString(file.getAbsolutePath()), file.getName());
writer.setSourceFile(file);
writer.setVisible(true);
}

View File

@ -19,13 +19,15 @@
package the.bytecode.club.bytecodeviewer;
import com.google.gson.reflect.TypeToken;
import me.konloch.kontainer.io.DiskReader;
import me.konloch.kontainer.io.DiskWriter;
import com.konloch.disklib.DiskReader;
import com.konloch.disklib.DiskWriter;
import the.bytecode.club.bytecodeviewer.util.MiscUtils;
import javax.swing.*;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import static the.bytecode.club.bytecodeviewer.BytecodeViewer.gson;
@ -52,14 +54,14 @@ public class Settings
try
{
if (new File(FILES_NAME).exists())
recentFiles = gson.fromJson(DiskReader.loadAsString(FILES_NAME), new TypeToken<ArrayList<String>>() {}.getType());
recentFiles = gson.fromJson(DiskReader.readString(FILES_NAME), new TypeToken<ArrayList<String>>() {}.getType());
else
recentFiles = DiskReader.loadArrayList(getBCVDirectory() + FS + "recentfiles.bcv", false);
recentFiles = Arrays.asList(DiskReader.readArray(getBCVDirectory() + FS + "recentfiles.bcv"));
if (new File(PLUGINS_NAME).exists())
recentPlugins = gson.fromJson(DiskReader.loadAsString(PLUGINS_NAME), new TypeToken<ArrayList<String>>() {}.getType());
recentPlugins = gson.fromJson(DiskReader.readString(PLUGINS_NAME), new TypeToken<ArrayList<String>>() {}.getType());
else
recentPlugins = DiskReader.loadArrayList(getBCVDirectory() + FS + "recentplugins.bcv", false);
recentPlugins = Arrays.asList(DiskReader.readArray(getBCVDirectory() + FS + "recentplugins.bcv"));
MiscUtils.deduplicateAndTrim(recentFiles, maxRecentFiles);
MiscUtils.deduplicateAndTrim(recentPlugins, maxRecentFiles);
@ -80,7 +82,7 @@ public class Settings
recentFiles.remove(f.getAbsolutePath()); // already added on the list
recentFiles.add(0, f.getAbsolutePath());
MiscUtils.deduplicateAndTrim(recentFiles, maxRecentFiles);
DiskWriter.replaceFile(FILES_NAME, MiscUtils.listToString(recentFiles), false);
saveRecentFiles();
resetRecentFilesMenu();
}
@ -88,11 +90,23 @@ public class Settings
{
if (recentFiles.remove(f.getAbsolutePath()))
{
DiskWriter.replaceFile(FILES_NAME, MiscUtils.listToString(recentFiles), false);
saveRecentFiles();
resetRecentFilesMenu();
}
}
private static void saveRecentFiles()
{
try
{
DiskWriter.write(FILES_NAME, MiscUtils.listToString(recentFiles));
}
catch (IOException e)
{
e.printStackTrace();
}
}
public static String getRecentFile()
{
if (recentFiles.isEmpty())
@ -111,7 +125,7 @@ public class Settings
recentPlugins.remove(f.getAbsolutePath()); // already added on the list
recentPlugins.add(0, f.getAbsolutePath());
MiscUtils.deduplicateAndTrim(recentPlugins, maxRecentFiles);
DiskWriter.replaceFile(PLUGINS_NAME, MiscUtils.listToString(recentPlugins), false);
saveRecentPlugins();
resetRecentFilesMenu();
}
@ -119,11 +133,23 @@ public class Settings
{
if (recentPlugins.remove(f.getAbsolutePath()))
{
DiskWriter.replaceFile(PLUGINS_NAME, MiscUtils.listToString(recentPlugins), false);
saveRecentPlugins();
resetRecentFilesMenu();
}
}
private static void saveRecentPlugins()
{
try
{
DiskWriter.write(PLUGINS_NAME, MiscUtils.listToString(recentPlugins));
}
catch (IOException e)
{
e.printStackTrace();
}
}
/**
* resets the recent files menu
*/

View File

@ -18,8 +18,8 @@
package the.bytecode.club.bytecodeviewer;
import me.konloch.kontainer.io.DiskReader;
import me.konloch.kontainer.io.DiskWriter;
import com.konloch.disklib.DiskReader;
import com.konloch.disklib.DiskWriter;
import the.bytecode.club.bytecodeviewer.decompilers.Decompiler;
import the.bytecode.club.bytecodeviewer.gui.theme.LAFTheme;
import the.bytecode.club.bytecodeviewer.gui.theme.RSTATheme;
@ -27,6 +27,7 @@ import the.bytecode.club.bytecodeviewer.translation.Language;
import javax.swing.*;
import java.io.File;
import java.io.IOException;
import static the.bytecode.club.bytecodeviewer.Constants.VERSION;
import static the.bytecode.club.bytecodeviewer.Constants.SETTINGS_NAME;
@ -40,6 +41,7 @@ import static the.bytecode.club.bytecodeviewer.Constants.SETTINGS_NAME;
public class SettingsSerializer
{
private static boolean settingsFileExists;
private static String[] settings;
public static void saveSettingsAsync()
{
@ -53,7 +55,7 @@ public class SettingsSerializer
try
{
DiskWriter.replaceFile(SETTINGS_NAME, "BCV: " + VERSION, false);
DiskWriter.write(SETTINGS_NAME, "BCV: " + VERSION, true);
save(BytecodeViewer.viewer.rbr.isSelected());
save(BytecodeViewer.viewer.rsy.isSelected());
save(BytecodeViewer.viewer.din.isSelected());
@ -169,9 +171,9 @@ public class SettingsSerializer
save(Configuration.deleteForeignLibraries);
if (BytecodeViewer.viewer.apkConversionGroup.isSelected(BytecodeViewer.viewer.apkConversionDex.getModel()))
DiskWriter.writeNewLine(SETTINGS_NAME, "0");
DiskWriter.append(SETTINGS_NAME, "0", true);
else if (BytecodeViewer.viewer.apkConversionGroup.isSelected(BytecodeViewer.viewer.apkConversionEnjarify.getModel()))
DiskWriter.writeNewLine(SETTINGS_NAME, "1");
DiskWriter.append(SETTINGS_NAME, "1", true);
save(Configuration.python3);
save(Configuration.javac);
@ -224,7 +226,7 @@ public class SettingsSerializer
return;
//precache the file
DiskReader.loadString(SETTINGS_NAME, 0, true);
settings = DiskReader.readArray(SETTINGS_NAME);
//process the cached file
Configuration.lafTheme = LAFTheme.valueOf(asString(127));
@ -425,21 +427,28 @@ public class SettingsSerializer
public static void save(Object o)
{
DiskWriter.writeNewLine(SETTINGS_NAME, String.valueOf(o), false);
try
{
DiskWriter.append(SETTINGS_NAME, String.valueOf(o), true);
}
catch (IOException e)
{
e.printStackTrace();
}
}
public static String asString(int lineNumber) throws Exception
public static String asString(int lineNumber)
{
return DiskReader.loadString(SETTINGS_NAME, lineNumber, false);
return settings[lineNumber];
}
public static boolean asBoolean(int lineNumber) throws Exception
public static boolean asBoolean(int lineNumber)
{
return Boolean.parseBoolean(DiskReader.loadString(SETTINGS_NAME, lineNumber, false));
return Boolean.parseBoolean(settings[lineNumber]);
}
public static int asInt(int lineNumber) throws Exception
public static int asInt(int lineNumber)
{
return Integer.parseInt(DiskReader.loadString(SETTINGS_NAME, lineNumber, false));
return Integer.parseInt(settings[lineNumber]);
}
}

View File

@ -18,7 +18,7 @@
package the.bytecode.club.bytecodeviewer.cli;
import me.konloch.kontainer.io.DiskWriter;
import com.konloch.disklib.DiskWriter;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.CommandLineParser;
import org.apache.commons.cli.DefaultParser;
@ -250,7 +250,7 @@ public class CommandLineInput
ClassNode cn = BytecodeViewer.blindlySearchForClassNode(target);
final ClassWriter cw = accept(cn);
String contents = Decompiler.PROCYON_DECOMPILER.getDecompiler().decompileClassNode(cn, cw.toByteArray());
DiskWriter.replaceFile(output.getAbsolutePath(), contents, false);
DiskWriter.write(output.getAbsolutePath(), contents);
}
catch (Exception e)
{
@ -276,7 +276,7 @@ public class CommandLineInput
ClassNode cn = BytecodeViewer.blindlySearchForClassNode(target);
final ClassWriter cw = accept(cn);
String contents = Decompiler.CFR_DECOMPILER.getDecompiler().decompileClassNode(cn, cw.toByteArray());
DiskWriter.replaceFile(output.getAbsolutePath(), contents, false);
DiskWriter.write(output.getAbsolutePath(), contents);
}
catch (Exception e)
{
@ -302,7 +302,7 @@ public class CommandLineInput
ClassNode cn = BytecodeViewer.blindlySearchForClassNode(target);
final ClassWriter cw = accept(cn);
String contents = Decompiler.FERNFLOWER_DECOMPILER.getDecompiler().decompileClassNode(cn, cw.toByteArray());
DiskWriter.replaceFile(output.getAbsolutePath(), contents, false);
DiskWriter.write(output.getAbsolutePath(), contents);
}
catch (Exception e)
{
@ -328,7 +328,7 @@ public class CommandLineInput
ClassNode cn = BytecodeViewer.blindlySearchForClassNode(target);
final ClassWriter cw = accept(cn);
String contents = Decompiler.KRAKATAU_DECOMPILER.getDecompiler().decompileClassNode(cn, cw.toByteArray());
DiskWriter.replaceFile(output.getAbsolutePath(), contents, false);
DiskWriter.write(output.getAbsolutePath(), contents);
}
catch (Exception e)
{
@ -355,7 +355,7 @@ public class CommandLineInput
ClassNode cn = BytecodeViewer.blindlySearchForClassNode(target);
final ClassWriter cw = accept(cn);
String contents = Decompiler.KRAKATAU_DISASSEMBLER.getDecompiler().decompileClassNode(cn, cw.toByteArray());
DiskWriter.replaceFile(output.getAbsolutePath(), contents, false);
DiskWriter.write(output.getAbsolutePath(), contents);
}
catch (Exception e)
{
@ -382,7 +382,7 @@ public class CommandLineInput
ClassNode cn = BytecodeViewer.blindlySearchForClassNode(target);
final ClassWriter cw = accept(cn);
String contents = Decompiler.JD_DECOMPILER.getDecompiler().decompileClassNode(cn, cw.toByteArray());
DiskWriter.replaceFile(output.getAbsolutePath(), contents, false);
DiskWriter.write(output.getAbsolutePath(), contents);
}
catch (Exception e)
{
@ -409,7 +409,7 @@ public class CommandLineInput
ClassNode cn = BytecodeViewer.blindlySearchForClassNode(target);
final ClassWriter cw = accept(cn);
String contents = Decompiler.SMALI_DISASSEMBLER.getDecompiler().decompileClassNode(cn, cw.toByteArray());
DiskWriter.replaceFile(output.getAbsolutePath(), contents, false);
DiskWriter.write(output.getAbsolutePath(), contents);
}
catch (Exception e)
{
@ -436,7 +436,7 @@ public class CommandLineInput
ClassNode cn = BytecodeViewer.blindlySearchForClassNode(target);
final ClassWriter cw = accept(cn);
String contents = Decompiler.JADX_DECOMPILER.getDecompiler().decompileClassNode(cn, cw.toByteArray());
DiskWriter.replaceFile(output.getAbsolutePath(), contents, false);
DiskWriter.write(output.getAbsolutePath(), contents);
}
catch (Exception e)
{
@ -463,7 +463,7 @@ public class CommandLineInput
ClassNode cn = BytecodeViewer.blindlySearchForClassNode(target);
final ClassWriter cw = accept(cn);
String contents = Decompiler.ASMIFIER_CODE_GEN.getDecompiler().decompileClassNode(cn, cw.toByteArray());
DiskWriter.replaceFile(output.getAbsolutePath(), contents, false);
DiskWriter.write(output.getAbsolutePath(), contents);
}
catch (Exception e)
{

View File

@ -18,7 +18,7 @@
package the.bytecode.club.bytecodeviewer.compilers.impl;
import me.konloch.kontainer.io.DiskWriter;
import com.konloch.disklib.DiskWriter;
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
import the.bytecode.club.bytecodeviewer.Configuration;
import the.bytecode.club.bytecodeviewer.compilers.AbstractCompiler;
@ -69,15 +69,15 @@ public class JavaCompiler extends AbstractCompiler
return null;
}
//write the file we're assembling to disk
DiskWriter.replaceFile(javaFile.getAbsolutePath(), contents, false);
//write the entire temporary classpath to disk
JarUtils.saveAsJar(BytecodeViewer.getLoadedClasses(), classPath.getAbsolutePath());
boolean cont = true;
try
{
//write the file we're assembling to disk
DiskWriter.write(javaFile.getAbsolutePath(), contents);
//write the entire temporary classpath to disk
JarUtils.saveAsJar(BytecodeViewer.getLoadedClasses(), classPath.getAbsolutePath());
StringBuilder log = new StringBuilder();
ProcessBuilder pb;

View File

@ -18,7 +18,7 @@
package the.bytecode.club.bytecodeviewer.compilers.impl;
import me.konloch.kontainer.io.DiskWriter;
import com.konloch.disklib.DiskWriter;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.ArrayUtils;
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
@ -55,21 +55,20 @@ public class KrakatauAssembler extends AbstractCompiler
final File tempDirectory2 = new File(Constants.TEMP_DIRECTORY + FS + MiscUtils.randomString(32) + FS);
final File javaFile = new File(tempDirectory1.getAbsolutePath() + FS + fullyQualifiedName + ".j");
final File tempJar = new File(Constants.TEMP_DIRECTORY + FS + "temp" + MiscUtils.randomString(32) + ".jar");
final StringBuilder log = new StringBuilder();
//create the temp directories
tempDirectory1.mkdir();
tempDirectory2.mkdir();
//write the file we're assembling to disk
DiskWriter.replaceFile(javaFile.getAbsolutePath(), contents, true);
//write the entire temporary classpath to disk
JarUtils.saveAsJar(BytecodeViewer.getLoadedClasses(), tempJar.getAbsolutePath());
StringBuilder log = new StringBuilder();
try
{
//write the file we're assembling to disk
DiskWriter.write(javaFile.getAbsolutePath(), contents);
//write the entire temporary classpath to disk
JarUtils.saveAsJar(BytecodeViewer.getLoadedClasses(), tempJar.getAbsolutePath());
String[] pythonCommands = new String[]{Configuration.python2};
if (Configuration.python2Extra)
pythonCommands = ArrayUtils.addAll(pythonCommands, "-2");

View File

@ -18,7 +18,7 @@
package the.bytecode.club.bytecodeviewer.compilers.impl;
import me.konloch.kontainer.io.DiskWriter;
import com.konloch.disklib.DiskWriter;
import org.apache.commons.io.FileUtils;
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
import the.bytecode.club.bytecodeviewer.compilers.AbstractCompiler;
@ -59,7 +59,7 @@ public class SmaliAssembler extends AbstractCompiler
try
{
//write the file we're assembling to disk
DiskWriter.replaceFile(tempSmali.getAbsolutePath(), contents, false);
DiskWriter.write(tempSmali.getAbsolutePath(), contents);
}
catch (Exception e)
{

View File

@ -18,7 +18,7 @@
package the.bytecode.club.bytecodeviewer.decompilers.impl;
import me.konloch.kontainer.io.DiskReader;
import com.konloch.disklib.DiskReader;
import org.objectweb.asm.tree.ClassNode;
import the.bytecode.club.bytecodeviewer.Constants;
import the.bytecode.club.bytecodeviewer.api.ExceptionUI;
@ -75,7 +75,7 @@ public class BlankDecompilerBase extends AbstractDecompiler
//if the output file is found, read it
if (tempOutputJavaFile.exists())
return DiskReader.loadAsString(tempOutputJavaFile.getAbsolutePath());
return DiskReader.readString(tempOutputJavaFile.getAbsolutePath());
else
exception = getDecompilerName() + " " + ERROR + "! " + tempOutputJavaFile.getAbsolutePath() + " does not exist.";
}

View File

@ -18,7 +18,7 @@
package the.bytecode.club.bytecodeviewer.decompilers.impl;
import me.konloch.kontainer.io.DiskReader;
import com.konloch.disklib.DiskReader;
import org.apache.commons.lang3.ArrayUtils;
import org.jetbrains.java.decompiler.main.decompiler.ConsoleDecompiler;
import org.objectweb.asm.tree.ClassNode;
@ -99,7 +99,7 @@ public class FernFlowerDecompiler extends AbstractDecompiler
//if the output file is found, read it
if (tempOutputJavaFile.exists() && !Constants.DEV_FLAG_DECOMPILERS_SIMULATED_ERRORS)
return DiskReader.loadAsString(tempOutputJavaFile.getAbsolutePath());
return DiskReader.readString(tempOutputJavaFile.getAbsolutePath());
else
exception = FERNFLOWER + " " + ERROR + "! " + tempOutputJavaFile.getAbsolutePath() + " does not exist.";
}

View File

@ -18,9 +18,9 @@
package the.bytecode.club.bytecodeviewer.decompilers.impl;
import com.konloch.disklib.DiskReader;
import jadx.api.JadxArgs;
import jadx.api.JadxDecompiler;
import me.konloch.kontainer.io.DiskReader;
import org.objectweb.asm.tree.ClassNode;
import the.bytecode.club.bytecodeviewer.Constants;
import the.bytecode.club.bytecodeviewer.Settings;
@ -112,7 +112,7 @@ public class JADXDecompiler extends AbstractDecompiler
return searchForJavaFile(MiscUtils.listFiles(file));
else if(file.getName().toLowerCase().endsWith(".java"))
{
String contents = DiskReader.loadAsString(file.getAbsolutePath());
String contents = DiskReader.readString(file.getAbsolutePath());
//cleanup
if(Settings.DECOMPILERS_AUTOMATICALLY_CLEANUP)

View File

@ -18,7 +18,7 @@
package the.bytecode.club.bytecodeviewer.decompilers.impl;
import me.konloch.kontainer.io.DiskReader;
import com.konloch.disklib.DiskReader;
import org.jd.core.v1.ClassFileToJavaSourceDecompiler;
import org.objectweb.asm.tree.ClassNode;
import the.bytecode.club.bytecodeviewer.Constants;
@ -109,7 +109,7 @@ public class JDGUIDecompiler extends AbstractDecompiler
throw new RuntimeException(DEV_MODE_SIMULATED_ERROR.toString());
//read the java file
return DiskReader.loadAsString(tempJavaFile.getAbsolutePath());
return DiskReader.readString(tempJavaFile.getAbsolutePath());
}
catch (Throwable e)
{

View File

@ -18,7 +18,7 @@
package the.bytecode.club.bytecodeviewer.decompilers.impl;
import me.konloch.kontainer.io.DiskWriter;
import com.konloch.disklib.DiskWriter;
import org.objectweb.asm.tree.ClassNode;
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
import the.bytecode.club.bytecodeviewer.Configuration;
@ -80,7 +80,7 @@ public class JavapDisassembler extends AbstractDecompiler
File tempClassFile = tempFile.getFile();
//write the bytes to the class-file
DiskWriter.replaceFileBytes(tempClassFile.getAbsolutePath(), bytes, false);
DiskWriter.write(tempClassFile.getAbsolutePath(), bytes);
//load java tools into a temporary classloader
URLClassLoader child = new URLClassLoader(new URL[]{new File(Configuration.javaTools).toURI().toURL()}, this.getClass().getClassLoader());

View File

@ -18,7 +18,7 @@
package the.bytecode.club.bytecodeviewer.decompilers.impl;
import me.konloch.kontainer.io.DiskReader;
import com.konloch.disklib.DiskReader;
import org.apache.commons.lang3.ArrayUtils;
import org.objectweb.asm.tree.ClassNode;
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
@ -142,7 +142,7 @@ public class KrakatauDecompiler extends AbstractDecompiler
throw new RuntimeException(DEV_MODE_SIMULATED_ERROR.toString());
// read the java file on a successful disassemble
return DiskReader.loadAsString(tempOutputJavaFile.getAbsolutePath());
return DiskReader.readString(tempOutputJavaFile.getAbsolutePath());
}
catch (Throwable e)
{

View File

@ -18,7 +18,7 @@
package the.bytecode.club.bytecodeviewer.decompilers.impl;
import me.konloch.kontainer.io.DiskReader;
import com.konloch.disklib.DiskReader;
import org.apache.commons.lang3.ArrayUtils;
import org.objectweb.asm.tree.ClassNode;
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
@ -111,7 +111,7 @@ public class KrakatauDisassembler extends AbstractDecompiler
throw new RuntimeException(DEV_MODE_SIMULATED_ERROR.toString());
// update the string on a successful disassemble
returnString = DiskReader.loadAsString(tempDirectory.getAbsolutePath() + FS + cn.name + ".j");
returnString = DiskReader.readString(tempDirectory.getAbsolutePath() + FS + cn.name + ".j");
}
catch (Exception e)
{

View File

@ -19,7 +19,7 @@
package the.bytecode.club.bytecodeviewer.decompilers.impl;
import com.googlecode.d2j.smali.BaksmaliCmd;
import me.konloch.kontainer.io.DiskReader;
import com.konloch.disklib.DiskReader;
import org.apache.commons.io.FileUtils;
import org.objectweb.asm.tree.ClassNode;
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
@ -115,7 +115,7 @@ public class SmaliDisassembler extends AbstractDecompiler
}
try
{
return DiskReader.loadAsString(outputSmali.getAbsolutePath());
return DiskReader.readString(outputSmali.getAbsolutePath());
}
catch (Exception e)
{

View File

@ -18,12 +18,13 @@
package the.bytecode.club.bytecodeviewer.gui.components;
import me.konloch.kontainer.io.DiskWriter;
import com.konloch.disklib.DiskWriter;
import the.bytecode.club.bytecodeviewer.resources.IconResources;
import javax.swing.*;
import java.awt.*;
import java.io.File;
import java.io.IOException;
import static the.bytecode.club.bytecodeviewer.Constants.TEMP_DIRECTORY;
@ -120,9 +121,9 @@ public class JFrameConsole extends JFrame
/**
* Trims the console text to prevent killing the swing thread
*/
public String trimConsoleText(String s)
public String trimConsoleText(String text)
{
int len = s.length();
int len = text.length();
//TODO this should also be a setting eventually
int max = 500_000;
@ -136,12 +137,19 @@ public class JFrameConsole extends JFrame
new Thread(() ->
{
//save to disk
DiskWriter.replaceFile(tempFile.getAbsolutePath(), s, false);
try
{
DiskWriter.write(tempFile.getAbsolutePath(), text);
}
catch (IOException e)
{
e.printStackTrace();
}
}, "Console Log Saving").start();
//trim
int skipped = len - max;
String trimmed = s.substring(0, max);
String trimmed = text.substring(0, max);
if (!trimmed.startsWith("WARNING: Skipping"))
trimmed = ("WARNING: Skipping " + skipped + " chars, allowing " + max + "\n\r")
@ -150,7 +158,7 @@ public class JFrameConsole extends JFrame
return trimmed;
}
return s;
return text;
}
private static final long serialVersionUID = -5056940543411437508L;

View File

@ -18,7 +18,7 @@
package the.bytecode.club.bytecodeviewer.gui.resourcelist;
import me.konloch.kontainer.io.DiskWriter;
import com.konloch.disklib.DiskWriter;
import org.apache.commons.io.FilenameUtils;
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
import the.bytecode.club.bytecodeviewer.Configuration;
@ -382,10 +382,10 @@ public class ResourceListPane extends TranslatedVisibleComponent implements File
File tempFile = new File(TEMP_DIRECTORY + FS + hash + FS + name + "." + extension);
if (!tempFile.exists())
{
DiskWriter.replaceFileBytes(tempFile.getAbsolutePath(), content, false);
try
{
DiskWriter.write(tempFile.getAbsolutePath(), content);
imp.getImporter().open(tempFile);
}
catch (Exception e)

View File

@ -19,10 +19,8 @@
package the.bytecode.club.bytecodeviewer.plugin;
import com.google.common.io.Files;
import com.konloch.taskmanager.Task;
import com.konloch.taskmanager.TaskRunnable;
import me.konloch.kontainer.io.DiskReader;
import me.konloch.kontainer.io.DiskWriter;
import com.konloch.disklib.DiskReader;
import com.konloch.disklib.DiskWriter;
import org.apache.commons.compress.utils.FileNameUtils;
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
import the.bytecode.club.bytecodeviewer.Configuration;
@ -188,7 +186,7 @@ public class PluginWriter extends JFrame
try
{
area.setText(DiskReader.loadAsString(file.getAbsolutePath()));
area.setText(DiskReader.readString(file.getAbsolutePath()));
area.setCaretPosition(0);
}
catch (Exception e)
@ -269,7 +267,15 @@ public class PluginWriter extends JFrame
}
}
DiskWriter.replaceFile(savePath.getAbsolutePath(), area.getText(), false);
try
{
DiskWriter.write(savePath.getAbsolutePath(), area.getText());
}
catch (IOException e)
{
e.printStackTrace();
}
addRecentPlugin(savePath);
}, "Plugin Editor Save");
@ -306,7 +312,7 @@ public class PluginWriter extends JFrame
else
{
//update content from latest disk data
content = DiskReader.loadAsString(savePath.getAbsolutePath());
content = DiskReader.readString(savePath.getAbsolutePath());
//update plugin writer UI on disk update
SwingUtilities.invokeLater(() ->

View File

@ -18,7 +18,7 @@
package the.bytecode.club.bytecodeviewer.resources;
import me.konloch.kontainer.io.DiskWriter;
import com.konloch.disklib.DiskWriter;
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
import the.bytecode.club.bytecodeviewer.Configuration;
import the.bytecode.club.bytecodeviewer.api.BCV;
@ -31,6 +31,7 @@ import the.bytecode.club.bytecodeviewer.util.MiscUtils;
import javax.swing.*;
import java.io.File;
import java.io.IOException;
import static the.bytecode.club.bytecodeviewer.Constants.FS;
import static the.bytecode.club.bytecodeviewer.Constants.TEMP_DIRECTORY;
@ -264,14 +265,14 @@ public class ResourceDecompiling
BytecodeViewer.updateBusyStatus(false);
}
public static void decompileCurrentlyOpenedResource(Decompiler decompiler, File outputFile, boolean saveAll)
public static void decompileCurrentlyOpenedResource(Decompiler decompiler, File outputFile, boolean saveAll) throws IOException
{
//signal to the user that BCV is performing an action in the background
BytecodeViewer.updateBusyStatus(true);
//decompile the currently opened resource and save it to the specified file
DiskWriter.replaceFile(saveAll ? MiscUtils.append(outputFile,
"-" + decompiler.getDecompilerNameProgrammatic() + ".java") : outputFile.getAbsolutePath(), BCV.decompileCurrentlyOpenedClassNode(decompiler), false);
DiskWriter.write(saveAll ? MiscUtils.append(outputFile,
"-" + decompiler.getDecompilerNameProgrammatic() + ".java") : outputFile.getAbsolutePath(), BCV.decompileCurrentlyOpenedClassNode(decompiler));
//signal to the user that BCV is finished performing that action
BytecodeViewer.updateBusyStatus(false);

View File

@ -18,7 +18,7 @@
package the.bytecode.club.bytecodeviewer.resources.importing.impl;
import me.konloch.kontainer.io.DiskWriter;
import com.konloch.disklib.DiskWriter;
import org.apache.commons.io.IOUtils;
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
import the.bytecode.club.bytecodeviewer.Configuration;
@ -27,10 +27,7 @@ import the.bytecode.club.bytecodeviewer.resources.importing.Import;
import the.bytecode.club.bytecodeviewer.resources.importing.Importer;
import the.bytecode.club.bytecodeviewer.util.MiscUtils;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.*;
import java.util.Enumeration;
import java.util.LinkedHashMap;
import java.util.Map;
@ -96,10 +93,10 @@ public class XAPKResourceImporter implements Importer
BytecodeViewer.addResourceContainer(container); //add the resource container to BCV's total loaded files
}
public File exportTo(File original, String extension, byte[] bytes)
public File exportTo(File original, String extension, byte[] bytes) throws IOException
{
File file = new File(original.getAbsolutePath() + extension);
DiskWriter.replaceFileBytes(file.getAbsolutePath(), bytes, false);
DiskWriter.write(file.getAbsolutePath(), bytes);
return file;
}
}

View File

@ -18,7 +18,7 @@
package the.bytecode.club.bytecodeviewer.util;
import me.konloch.kontainer.io.DiskWriter;
import com.konloch.disklib.DiskWriter;
import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
import org.apache.commons.compress.archivers.zip.ZipFile;
import org.apache.commons.io.FilenameUtils;
@ -390,7 +390,7 @@ public class JarUtils
File f = new File(name);
f.mkdirs();
DiskWriter.replaceFileBytes(name, cw.toByteArray(), false);
DiskWriter.write(name, cw.toByteArray());
}
}
catch (Exception e)