summaryrefslogtreecommitdiffstats
path: root/libraries/launcher/org/multimc/Utils.java
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/launcher/org/multimc/Utils.java')
-rw-r--r--libraries/launcher/org/multimc/Utils.java90
1 files changed, 0 insertions, 90 deletions
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();
- }
- }
}