2021-06-21 09:45:31 +00:00
|
|
|
package the.bytecode.club.bytecodeviewer;
|
|
|
|
|
2021-07-16 18:26:41 +00:00
|
|
|
import org.objectweb.asm.Opcodes;
|
2021-07-14 09:59:36 +00:00
|
|
|
import the.bytecode.club.bytecodeviewer.resources.ResourceType;
|
|
|
|
|
2021-06-21 09:45:31 +00:00
|
|
|
import java.io.File;
|
2021-07-07 04:21:06 +00:00
|
|
|
import java.io.PrintStream;
|
2021-06-21 09:45:31 +00:00
|
|
|
|
|
|
|
/**
|
2021-06-26 01:13:46 +00:00
|
|
|
* General program constants, to use this class include everything as a wildcard static import:
|
|
|
|
* import static the.bytecode.club.bytecodeviewer.Constants.*;
|
|
|
|
*
|
2021-06-21 09:45:31 +00:00
|
|
|
* @author Konloch
|
|
|
|
* @since 6/21/2021
|
|
|
|
*/
|
|
|
|
public class Constants
|
|
|
|
{
|
|
|
|
/*per version*/
|
2021-07-09 02:31:59 +00:00
|
|
|
public static final String VERSION = "2.10.14"; //could be loaded from the pom
|
2021-06-21 09:45:31 +00:00
|
|
|
public static String krakatauVersion = "12";
|
|
|
|
public static String enjarifyVersion = "4";
|
|
|
|
public static final boolean BLOCK_TAB_MENU = true;
|
2021-07-11 12:33:18 +00:00
|
|
|
public static final boolean LAUNCH_DECOMPILERS_IN_NEW_PROCESS = false; //TODO
|
2021-06-21 09:45:31 +00:00
|
|
|
public static final boolean FAT_JAR = true; //could be automatic by checking if it's loaded a class named whatever for a library
|
|
|
|
public static final boolean OFFLINE_MODE = true; //disables the automatic updater
|
|
|
|
|
|
|
|
public static final String fs = System.getProperty("file.separator");
|
|
|
|
public static final String nl = System.getProperty("line.separator");
|
2021-07-11 12:33:18 +00:00
|
|
|
|
|
|
|
//TODO check if $HOME/.local/share exists, if so reference from there instead - #250
|
2021-06-21 09:45:31 +00:00
|
|
|
public static final File BCVDir = new File(System.getProperty("user.home") + fs + ".Bytecode-Viewer");
|
|
|
|
public static final File RT_JAR = new File(System.getProperty("java.home") + fs + "lib" + fs + "rt.jar");
|
|
|
|
public static final File RT_JAR_DUMPED = new File(getBCVDirectory() + fs + "rt.jar");
|
|
|
|
public static final String filesName = getBCVDirectory() + fs + "recentfiles.json";
|
|
|
|
public static final String pluginsName = getBCVDirectory() + fs + "recentplugins.json";
|
|
|
|
public static final String settingsName = getBCVDirectory() + fs + "settings.bcv";
|
|
|
|
public static final String tempDirectory = getBCVDirectory() + fs + "bcv_temp" + fs;
|
|
|
|
public static final String libsDirectory = getBCVDirectory() + fs + "libs" + fs;
|
|
|
|
public static String krakatauWorkingDirectory = getBCVDirectory() + fs + "krakatau_" + krakatauVersion;
|
|
|
|
public static String enjarifyWorkingDirectory = getBCVDirectory() + fs + "enjarify_" + enjarifyVersion;
|
2021-07-14 09:59:36 +00:00
|
|
|
public static final String[] SUPPORTED_FILE_EXTENSIONS = ResourceType.supportedBCVExtensionMap.keySet().toArray(new String[0]);
|
2021-07-16 18:26:41 +00:00
|
|
|
public static final int ASM_VERSION = Opcodes.ASM9;
|
2021-06-21 09:45:31 +00:00
|
|
|
|
2021-07-07 04:21:06 +00:00
|
|
|
public static final PrintStream ERR = System.err;
|
|
|
|
public static final PrintStream OUT = System.out;
|
|
|
|
|
2021-06-21 09:45:31 +00:00
|
|
|
/**
|
|
|
|
* Returns the BCV directory
|
|
|
|
*
|
|
|
|
* @return the static BCV directory
|
|
|
|
*/
|
2021-06-26 05:25:50 +00:00
|
|
|
public static String getBCVDirectory()
|
|
|
|
{
|
2021-06-21 09:45:31 +00:00
|
|
|
while (!BCVDir.exists())
|
|
|
|
BCVDir.mkdirs();
|
|
|
|
|
|
|
|
if (!BCVDir.isHidden() && isWindows())
|
|
|
|
hideFile(BCVDir);
|
|
|
|
|
|
|
|
return BCVDir.getAbsolutePath();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Checks if the OS contains 'win'
|
|
|
|
*
|
|
|
|
* @return true if the os.name property contains 'win'
|
|
|
|
*/
|
2021-06-26 05:25:50 +00:00
|
|
|
private static boolean isWindows()
|
|
|
|
{
|
2021-06-21 09:45:31 +00:00
|
|
|
return System.getProperty("os.name").toLowerCase().contains("win");
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Runs the windows command to hide files
|
|
|
|
*
|
|
|
|
* @param f file you want hidden
|
|
|
|
*/
|
2021-06-26 05:25:50 +00:00
|
|
|
private static void hideFile(File f)
|
|
|
|
{
|
2021-06-21 09:45:31 +00:00
|
|
|
try {
|
2021-07-12 12:13:35 +00:00
|
|
|
BytecodeViewer.sm.pauseBlocking();
|
2021-06-21 09:45:31 +00:00
|
|
|
// Hide file by running attrib system command (on Windows)
|
|
|
|
Runtime.getRuntime().exec("attrib +H " + f.getAbsolutePath());
|
|
|
|
} catch (Exception e) {
|
2021-07-07 02:51:10 +00:00
|
|
|
BytecodeViewer.handleException(e);
|
2021-07-12 12:13:35 +00:00
|
|
|
} finally {
|
|
|
|
BytecodeViewer.sm.resumeBlocking();
|
2021-06-21 09:45:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|