Skip to content

Commit 14e95e2

Browse files
committed
Fix windows build
1 parent 4d2f48d commit 14e95e2

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

tdlight-java/src/main/java/it/tdlight/util/NativeLibraryLoader.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616
package it.tdlight.util;
1717

18+
import java.nio.file.AccessDeniedException;
1819
import org.slf4j.Logger;
1920
import org.slf4j.LoggerFactory;
2021

@@ -263,7 +264,7 @@ public static void load(String originalName, ClassLoader loader) {
263264
// We delete the file immediately to free up resources as soon as possible,
264265
// and if this fails fallback to deleting on JVM exit.
265266
try {
266-
if (tmpFile != null && (!DELETE_NATIVE_LIB_AFTER_LOADING || !Files.deleteIfExists(tmpFile))) {
267+
if (tmpFile != null && (!DELETE_NATIVE_LIB_AFTER_LOADING || !deleteIfExists(tmpFile))) {
267268
tmpFile.toFile().deleteOnExit();
268269
}
269270
} catch (IOException e) {
@@ -272,6 +273,14 @@ public static void load(String originalName, ClassLoader loader) {
272273
}
273274
}
274275

276+
private static boolean deleteIfExists(Path tmpFile) throws IOException {
277+
try {
278+
return Files.deleteIfExists(tmpFile);
279+
} catch (AccessDeniedException ex) {
280+
return false;
281+
}
282+
}
283+
275284
private static boolean isOsx() {
276285
return Native.getOs().equals("osx");
277286
}

0 commit comments

Comments
 (0)