From 7778c8412105a19b07ebfe30c32d2f8dcaf06196 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Fri, 28 Nov 2014 23:59:51 +0100 Subject: NOISSUE No more symlinks for LWJGL. --- depends/launcher/org/multimc/Utils.java | 65 ++++++++------------------------- 1 file changed, 16 insertions(+), 49 deletions(-) (limited to 'depends') diff --git a/depends/launcher/org/multimc/Utils.java b/depends/launcher/org/multimc/Utils.java index addeb3cb..e6be25aa 100644 --- a/depends/launcher/org/multimc/Utils.java +++ b/depends/launcher/org/multimc/Utils.java @@ -210,7 +210,7 @@ public class Utils } /** - * Replace a 'target' string 'suffix' with 'replacement' + * Replace a 'target' string 'suffix' with 'replacement' */ public static String replaceSuffix (String target, String suffix, String replacement) { @@ -233,7 +233,15 @@ public class Utils public static void unzipNatives(File source, File targetFolder) throws IOException { ZipFile zip = new ZipFile(source); - Set toProcess = new HashSet(); + + boolean applyHacks = false; + String[] javaVersionElements = System.getProperty("java.version").split("\\."); + int major = Integer.parseInt(javaVersionElements[1]); + if (major >= 8) + { + applyHacks = true; + } + try { Enumeration entries = zip.entries(); @@ -243,7 +251,12 @@ public class Utils ZipEntry entry = (ZipEntry) entries.nextElement(); String entryName = entry.getName(); - File targetFile = new File(targetFolder, entryName); + String fileName = entryName; + if(applyHacks) + { + fileName = replaceSuffix(entryName, ".jnilib", ".dylib"); + } + File targetFile = new File(targetFolder, fileName); if (targetFile.getParentFile() != null) { targetFile.getParentFile().mkdirs(); @@ -253,57 +266,11 @@ public class Utils continue; copyStream(zip.getInputStream(entry), new BufferedOutputStream(new FileOutputStream(targetFile))); - toProcess.add(entryName); } } finally { zip.close(); } - - // For java <= 7, do not do symlink hackery below. - String[] javaVersionElements = System.getProperty("java.version").split("\\."); - int major = Integer.parseInt(javaVersionElements[1]); - if (major <= 7) - { - return; - } - - // for >= 8, do hackery - for (String entryName : toProcess) - { - // check if we need a symlink - String suffixFrom = null; - String suffixTo = null; - if(entryName.endsWith(".dylib")) - { - suffixFrom = ".dylib"; - suffixTo = ".jnilib"; - } - else if(entryName.endsWith(".jnilib")) - { - suffixFrom = ".jnilib"; - suffixTo = ".dylib"; - } - else - { - continue; - } - - String linkName = replaceSuffix(entryName, suffixFrom, suffixTo); - File targetFile = new File(targetFolder, entryName); - File symlinkFile = new File(targetFolder, linkName); - - // if the link file exists already for whatever reason, do not create symlinks - if(symlinkFile.exists()) - { - continue; - } - - // create a symlink. This means we always have .jnilib and .dylib variants of the same libs. - Path linkLink = symlinkFile.toPath(); - Path linkTarget = targetFile.toPath(); - Files.createSymbolicLink(linkLink, linkTarget); - } } } -- cgit v1.2.3