feat: delete native on exit

This commit is contained in:
Johannes Frohnmeyer 2024-07-22 17:37:29 +02:00
parent 23eb6dc880
commit 26efd9270f
Signed by: Johannes
GPG Key ID: E76429612C2929F4

View File

@ -29,7 +29,14 @@ public class Native {
} else {
String _problem = null;
try (InputStream is = Native.class.getResourceAsStream("/libnative.so")) {
Path path = Files.createTempFile("libnative", ".so");
Path path = Files.createTempFile("globalmenu-natives", ".so");
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
try {
Files.deleteIfExists(path);
} catch (Throwable e) {
// Ignore
}
}));
Files.copy(is, path, java.nio.file.StandardCopyOption.REPLACE_EXISTING);
System.load(path.toString());
} catch (Throwable e) {