Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions src/main/java/io/xdag/crypto/randomx/RandomXLibraryLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,22 @@ private static File extractAndLoadNativeLibrary() throws IOException, IllegalSta
}

String mappedLibName = System.mapLibraryName(libraryLogicalName);
String tempFilePrefix = mappedLibName.substring(0, mappedLibName.lastIndexOf('.'));
String tempFileSuffix = mappedLibName.substring(mappedLibName.lastIndexOf('.'));
File tempFile;

if (os.contains("win")) {
// Use a fixed file name under Windows: randomx.dll
Path tempDir = Files.createTempDirectory("randomx-");
tempDir.toFile().deleteOnExit();
tempFilePath = tempDir.resolve("randomx.dll"); // Fixed name
} else {
// Linux and macOS uses the default temporary files policy
String tempFilePrefix = mappedLibName.substring(0, mappedLibName.lastIndexOf('.'));
String tempFileSuffix = mappedLibName.substring(mappedLibName.lastIndexOf('.'));
tempFilePath = Files.createTempFile(tempFilePrefix + "-", tempFileSuffix);
}

tempFile = tempFilePath.toFile();

tempFilePath = Files.createTempFile(tempFilePrefix + "-", tempFileSuffix);
File tempFile = tempFilePath.toFile();
tempFile.deleteOnExit();

Files.copy(libStream, tempFilePath, StandardCopyOption.REPLACE_EXISTING);
Expand Down
Binary file modified src/main/resources/native/librandomx_windows_x86_64.dll
Binary file not shown.
Loading