|
|
@ -93,10 +93,10 @@ public class NativeUtil { |
|
|
|
try (InputStream is = NativeUtil.class.getResourceAsStream(path)) { |
|
|
|
try (InputStream is = NativeUtil.class.getResourceAsStream(path)) { |
|
|
|
Files.copy(is, temp, StandardCopyOption.REPLACE_EXISTING); |
|
|
|
Files.copy(is, temp, StandardCopyOption.REPLACE_EXISTING); |
|
|
|
} catch (IOException e) { |
|
|
|
} catch (IOException e) { |
|
|
|
Files.deleteIfExists(temp); |
|
|
|
delete(temp); |
|
|
|
throw e; |
|
|
|
throw e; |
|
|
|
} catch (NullPointerException e) { |
|
|
|
} catch (NullPointerException e) { |
|
|
|
Files.deleteIfExists(temp); |
|
|
|
delete(temp); |
|
|
|
throw new FileNotFoundException("File " + path + " was not found inside JAR."); |
|
|
|
throw new FileNotFoundException("File " + path + " was not found inside JAR."); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -105,7 +105,7 @@ public class NativeUtil { |
|
|
|
} finally { |
|
|
|
} finally { |
|
|
|
if (isPosixCompliant()) { |
|
|
|
if (isPosixCompliant()) { |
|
|
|
// Assume POSIX compliant file system, can be deleted after loading
|
|
|
|
// Assume POSIX compliant file system, can be deleted after loading
|
|
|
|
Files.deleteIfExists(temp); |
|
|
|
delete(temp); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
// Assume non-POSIX, and don't delete until last file descriptor closed
|
|
|
|
// Assume non-POSIX, and don't delete until last file descriptor closed
|
|
|
|
temp.toFile().deleteOnExit(); |
|
|
|
temp.toFile().deleteOnExit(); |
|
|
@ -113,6 +113,12 @@ public class NativeUtil { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static void delete(final Path path) { |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
Files.deleteIfExists(path); |
|
|
|
|
|
|
|
} catch (IOException ignored) {} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private static Path createTempDirectory(final String prefix) throws IOException { |
|
|
|
private static Path createTempDirectory(final String prefix) throws IOException { |
|
|
|
return Files.createTempDirectory(prefix + System.nanoTime()); |
|
|
|
return Files.createTempDirectory(prefix + System.nanoTime()); |
|
|
|
} |
|
|
|
} |
|
|
|