From 3fe54f005506af37ef2b174ed0bb3f18ca6c1d0e Mon Sep 17 00:00:00 2001 From: Orange-iMac Date: Fri, 25 Aug 2017 17:22:13 +0800 Subject: [PATCH] add auto detect dynamic library by ext name & add os xml tag --- src/main/java/fxlauncher/LibraryFile.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/main/java/fxlauncher/LibraryFile.java b/src/main/java/fxlauncher/LibraryFile.java index 05a6e9d..b114791 100644 --- a/src/main/java/fxlauncher/LibraryFile.java +++ b/src/main/java/fxlauncher/LibraryFile.java @@ -7,7 +7,6 @@ import java.net.URL; import java.nio.file.Files; import java.nio.file.Path; -import java.nio.file.Paths; import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.zip.Adler32; @@ -42,8 +41,17 @@ public LibraryFile(Path basepath, Path file) throws IOException { String filename = file.getFileName().toString().toLowerCase(); Pattern osPattern = Pattern.compile(".+-(linux|win|mac)\\.[^.]+$"); Matcher osMatcher = osPattern.matcher(filename); - if (osMatcher.matches()) - this.os = OS.valueOf(osMatcher.group(1)); + if (osMatcher.matches()) { + this.os = OS.valueOf(osMatcher.group(1)); + } else { + if (filename.endsWith(".dll")) { + this.os = OS.win; + } else if (filename.endsWith(".dylib")) { + this.os = OS.mac; + } else if (filename.endsWith(".so")) { + this.os = OS.linux; + } + } } public boolean loadForCurrentPlatform() {