Fix windows build

This commit is contained in:
Andrea Cavalli 2023-05-21 14:53:03 +02:00
parent 4d2f48d533
commit 14e95e29f3

View File

@ -15,6 +15,7 @@
*/
package it.tdlight.util;
import java.nio.file.AccessDeniedException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -263,7 +264,7 @@ public final class NativeLibraryLoader {
// We delete the file immediately to free up resources as soon as possible,
// and if this fails fallback to deleting on JVM exit.
try {
if (tmpFile != null && (!DELETE_NATIVE_LIB_AFTER_LOADING || !Files.deleteIfExists(tmpFile))) {
if (tmpFile != null && (!DELETE_NATIVE_LIB_AFTER_LOADING || !deleteIfExists(tmpFile))) {
tmpFile.toFile().deleteOnExit();
}
} catch (IOException e) {
@ -272,6 +273,14 @@ public final class NativeLibraryLoader {
}
}
private static boolean deleteIfExists(Path tmpFile) throws IOException {
try {
return Files.deleteIfExists(tmpFile);
} catch (AccessDeniedException ex) {
return false;
}
}
private static boolean isOsx() {
return Native.getOs().equals("osx");
}