From 1f2bed2ef119094bdc156aa3a206b93dea5081d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Thu, 16 Jun 2016 02:20:23 +0200 Subject: NOISSUE implement direct java launch Just running the Java process and giving it params on the command line --- libraries/launcher/org/multimc/Utils.java | 90 ------------------------------- 1 file changed, 90 deletions(-) (limited to 'libraries/launcher/org/multimc/Utils.java') diff --git a/libraries/launcher/org/multimc/Utils.java b/libraries/launcher/org/multimc/Utils.java index 32cf7919..86182831 100644 --- a/libraries/launcher/org/multimc/Utils.java +++ b/libraries/launcher/org/multimc/Utils.java @@ -186,95 +186,5 @@ public class Utils { System.out.println(); } - - /** - * Pushes bytes from in to out. Closes both streams no matter what. - * @param in the input stream - * @param out the output stream - * @throws IOException - */ - private static void copyStream(InputStream in, OutputStream out) throws IOException - { - try - { - byte[] buffer = new byte[4096]; - int len; - - while((len = in.read(buffer)) >= 0) - out.write(buffer, 0, len); - } finally - { - in.close(); - out.close(); - } - } - - /** - * Replace a 'target' string 'suffix' with 'replacement' - */ - public static String replaceSuffix (String target, String suffix, String replacement) - { - if (!target.endsWith(suffix)) - { - return target; - } - String prefix = target.substring(0, target.length() - suffix.length()); - return prefix + replacement; - } - - /** - * Unzip zip file with natives 'source' into the folder 'targetFolder' - * - * Contains a hack for OSX. Yay. - * @param source - * @param targetFolder - * @throws IOException - */ - public static void unzipNatives(File source, File targetFolder) throws IOException - { - ZipFile zip = new ZipFile(source); - - boolean applyHacks = false; - String[] javaVersionElements = System.getProperty("java.version").split("[.\\-+]"); - int major = Integer.parseInt(javaVersionElements[0]); - if(major == 1) - { - major = Integer.parseInt(javaVersionElements[1]); - } - if (major >= 8) - { - applyHacks = true; - } - - try - { - Enumeration entries = zip.entries(); - - while (entries.hasMoreElements()) - { - ZipEntry entry = (ZipEntry) entries.nextElement(); - - String entryName = entry.getName(); - String fileName = entryName; - if(applyHacks) - { - fileName = replaceSuffix(entryName, ".jnilib", ".dylib"); - } - File targetFile = new File(targetFolder, fileName); - if (targetFile.getParentFile() != null) - { - targetFile.getParentFile().mkdirs(); - } - - if (entry.isDirectory()) - continue; - - copyStream(zip.getInputStream(entry), new BufferedOutputStream(new FileOutputStream(targetFile))); - } - } finally - { - zip.close(); - } - } } -- cgit v1.2.3