Skip to content
This repository has been archived by the owner on Apr 9, 2023. It is now read-only.

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
Vatuu committed Aug 30, 2022
2 parents b3924c1 + d967f9d commit 1fd4d69
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<dependency>
<groupId>net.java.dev.jna</groupId>
<artifactId>jna</artifactId>
<version>4.5.1</version>
<version>5.4.0</version>
<scope>compile</scope>
</dependency>
<dependency>
Expand Down
21 changes: 16 additions & 5 deletions src/main/java/net/arikia/dev/drpc/DiscordRPC.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@
import com.sun.jna.Native;

import java.io.*;
import java.nio.file.Files;
import java.nio.file.Path;

/**
* @author Nicolas "Vatuu" Adamoglou
* @version 1.5.1
* <p>
* Java Wrapper of the Discord-RPC Library for Discord Rich Presence.
*/

public final class DiscordRPC {

//DLL-Version for Update Check (soon).
Expand Down Expand Up @@ -159,12 +162,20 @@ private static void loadDLL() {

finalPath = "/" + dir + "/" + name;

File f = new File(tempPath);
try {
Path tempDirectoryPath = Files.createTempDirectory("drpc");
File f = new File(tempDirectoryPath + File.separator + name);

try (InputStream in = DiscordRPC.class.getResourceAsStream(finalPath); OutputStream out = openOutputStream(f)) {
copyFile(in, out);
tempDirectoryPath.toFile().deleteOnExit();
f.deleteOnExit();
} catch (IOException e) {
e.printStackTrace();
}

try (InputStream in = DiscordRPC.class.getResourceAsStream(finalPath); OutputStream out = openOutputStream(f)) {
copyFile(in, out);
f.deleteOnExit();
} catch (IOException e) {
System.load(f.getAbsolutePath());
} catch(Exception e) {
e.printStackTrace();
}

Expand Down

0 comments on commit 1fd4d69

Please sign in to comment.