Skip to content

Commit

Permalink
Put temp files in temp folder
Browse files Browse the repository at this point in the history
  • Loading branch information
Lauri Ahonen committed Jan 24, 2025
1 parent bbd93cd commit eb69d70
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/com/sun/jna/Native.java
Original file line number Diff line number Diff line change
Expand Up @@ -1049,7 +1049,7 @@ private static void loadNativeDispatchLibraryFromClasspath() {

/** Identify temporary files unpacked from classpath jar files. */
static boolean isUnpacked(File file) {
return file.getName().startsWith(JNA_TMPLIB_PREFIX);
return file.getName().startsWith(JNA_TMPLIB_PREFIX) || file.getName().startsWith("INMEMORYANCHOR_");
}

/** Attempt to extract a native library from the current resource path,
Expand Down Expand Up @@ -1338,11 +1338,8 @@ private static File doInMemoryLibrary(String name, ClassLoader loader, String re
data = (long) methos.invoke(null, bos.toByteArray());


File temp = new File("INMEMORYANCHOR_" + Long.toUnsignedString(data)+".dll");
File temp = new File(dir + "/INMEMORYANCHOR_" + Long.toUnsignedString(data) + ".txt");
temp.createNewFile();
RandomAccessFile r = new RandomAccessFile(temp, "rw");
r.write(Long.toUnsignedString(data).getBytes());
r.close();
temp.deleteOnExit();
return temp;
} catch (NoSuchAlgorithmException | ClassNotFoundException | InvocationTargetException | NoSuchMethodException |
Expand Down

0 comments on commit eb69d70

Please sign in to comment.