|
|
@ -40,6 +40,7 @@ import java.io.InputStream; |
|
|
|
import java.io.OutputStream; |
|
|
|
import java.io.OutputStream; |
|
|
|
import java.net.MalformedURLException; |
|
|
|
import java.net.MalformedURLException; |
|
|
|
import java.net.URL; |
|
|
|
import java.net.URL; |
|
|
|
|
|
|
|
import java.net.URLConnection; |
|
|
|
import java.util.logging.Level; |
|
|
|
import java.util.logging.Level; |
|
|
|
import java.util.logging.Logger; |
|
|
|
import java.util.logging.Logger; |
|
|
|
|
|
|
|
|
|
|
@ -69,16 +70,31 @@ public class Natives { |
|
|
|
String fullname = System.mapLibraryName(name); |
|
|
|
String fullname = System.mapLibraryName(name); |
|
|
|
|
|
|
|
|
|
|
|
String path = "native/" + sysName + "/" + fullname; |
|
|
|
String path = "native/" + sysName + "/" + fullname; |
|
|
|
InputStream in = Thread.currentThread().getContextClassLoader().getResourceAsStream(path); |
|
|
|
URL url = Thread.currentThread().getContextClassLoader().getResource(path); |
|
|
|
//InputStream in = Natives.class.getResourceAsStream();
|
|
|
|
|
|
|
|
if (in == null) { |
|
|
|
if (url == null) { |
|
|
|
if (!warning) { |
|
|
|
if (!warning) { |
|
|
|
logger.log(Level.WARNING, "Cannot locate native library: {0}/{1}", |
|
|
|
logger.log(Level.WARNING, "Cannot locate native library: {0}/{1}", |
|
|
|
new String[]{sysName, fullname}); |
|
|
|
new String[]{sysName, fullname}); |
|
|
|
} |
|
|
|
} |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
URLConnection conn = url.openConnection(); |
|
|
|
|
|
|
|
InputStream in = conn.getInputStream(); |
|
|
|
File targetFile = new File(workingDir, fullname); |
|
|
|
File targetFile = new File(workingDir, fullname); |
|
|
|
|
|
|
|
if (targetFile.exists()){ |
|
|
|
|
|
|
|
// OK, compare last modified date of this file to
|
|
|
|
|
|
|
|
// file in jar
|
|
|
|
|
|
|
|
long targetLastModified = targetFile.lastModified(); |
|
|
|
|
|
|
|
long sourceLastModified = conn.getLastModified(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Allow ~1 second range for OSes that only support low precision
|
|
|
|
|
|
|
|
if (targetLastModified + 1000 > sourceLastModified){ |
|
|
|
|
|
|
|
logger.log(Level.FINE, "Not copying library {0}. Latest already extracted.", fullname); |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
try { |
|
|
|
try { |
|
|
|
OutputStream out = new FileOutputStream(targetFile); |
|
|
|
OutputStream out = new FileOutputStream(targetFile); |
|
|
|
int len; |
|
|
|
int len; |
|
|
@ -87,6 +103,11 @@ public class Natives { |
|
|
|
} |
|
|
|
} |
|
|
|
in.close(); |
|
|
|
in.close(); |
|
|
|
out.close(); |
|
|
|
out.close(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// NOTE: On OSes that support "Date Created" property,
|
|
|
|
|
|
|
|
// this will cause the last modified date to be lower than
|
|
|
|
|
|
|
|
// date created which makes no sense
|
|
|
|
|
|
|
|
targetFile.setLastModified(conn.getLastModified()); |
|
|
|
} catch (FileNotFoundException ex) { |
|
|
|
} catch (FileNotFoundException ex) { |
|
|
|
if (ex.getMessage().contains("used by another process")) { |
|
|
|
if (ex.getMessage().contains("used by another process")) { |
|
|
|
return; |
|
|
|
return; |
|
|
|