This commit is contained in:
vjurenka 2016-02-28 14:49:38 +01:00
commit e494ca89aa

View file

@ -74,17 +74,23 @@ public class Mirror {
String path = Mirror.class.getProtectionDomain().getCodeSource().getLocation().getPath(); String path = Mirror.class.getProtectionDomain().getCodeSource().getLocation().getPath();
String decodedPath = java.net.URLDecoder.decode(path, "UTF-8"); String decodedPath = java.net.URLDecoder.decode(path, "UTF-8");
JarResources jar = null;
for (String dllName : dllNames) { for (String dllName : dllNames) {
String dllNameExt = dllName + ".dll"; String dllNameExt = dllName + ".dll";
if (!new File(dllNameExt).exists()) { if (!new File(dllNameExt).exists()) {
JarResources jar = new JarResources(path); if (null == jar) {
jar = new JarResources(decodedPath);
}
byte[] correctDllData = jar.getResource(dllNameExt); byte[] correctDllData = jar.getResource(dllNameExt);
// prevents the creation of zero byte files
if (null != correctDllData) {
FileOutputStream funnyStream = new FileOutputStream(dllNameExt); FileOutputStream funnyStream = new FileOutputStream(dllNameExt);
funnyStream.write(correctDllData); funnyStream.write(correctDllData);
funnyStream.close(); funnyStream.close();
} }
} }
} }
}
} catch (Exception e) { } catch (Exception e) {
System.err.println("Failed to extract native libraries.\n" + e); System.err.println("Failed to extract native libraries.\n" + e);
} }