Skip to content

Commit

Permalink
Search werender.config for Linux and Windows. #2
Browse files Browse the repository at this point in the history
  • Loading branch information
zhoub committed Nov 4, 2022
1 parent 790dc54 commit 6994abb
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions rest/java/src/main/java/io/werender/examples/Config.java
Expand Up @@ -25,19 +25,23 @@ public class Config {
private String privateKey;

public static Config create() {
/* Create instance. */
// Create instance.
Config config = new Config();

/* Get home folder and configuration folder. */
// Get configuration folder where contains werender.config file.
String homeDirPath = SystemUtils.getUserHome().getAbsolutePath();
String configDirPath = new String(homeDirPath);
if (SystemUtils.IS_OS_MAC_OSX) {
if (SystemUtils.IS_OS_LINUX) {
configDirPath += "/.config/werender";
} else if (SystemUtils.IS_OS_MAC_OSX) {
configDirPath += "/Library/Application Support/werender";
} else if (SystemUtils.IS_OS_WINDOWS) {
configDirPath += "/werender";
} else {
log.fatal(String.format("Unsupported platform"));
}

/* Read werender.config file. */
// Read werender.config file.
try {
String serverAddress = Config.DEFAULT_SERVER_ADDRESS;

Expand All @@ -64,7 +68,7 @@ public static Config create() {
e.printStackTrace();
}

/* Read werender.key file. */
// Read werender.key file.
try {
String keyFilePath = configDirPath + "/werender.key";
String key = Files.readString(Paths.get(keyFilePath));
Expand All @@ -75,7 +79,7 @@ public static Config create() {
e.printStackTrace();
}

/* Return instance. */
// Return instance.
return config;
}

Expand Down

0 comments on commit 6994abb

Please sign in to comment.