diff --git a/src/itdelatrisu/opsu/Options.java b/src/itdelatrisu/opsu/Options.java index bea2d900..feea0a56 100644 --- a/src/itdelatrisu/opsu/Options.java +++ b/src/itdelatrisu/opsu/Options.java @@ -169,8 +169,11 @@ public class Options { * @return the XDG base directory, or the working directory if unavailable */ private static File getXDGBaseDir(String env, String fallback) { + File workingDir = Utils.isJarRunning() ? + Utils.getRunningDirectory().getParentFile() : Utils.getWorkingDirectory(); + if (!USE_XDG) - return new File("./"); + return workingDir; String OS = System.getProperty("os.name").toLowerCase(); if (OS.indexOf("nix") >= 0 || OS.indexOf("nux") >= 0 || OS.indexOf("aix") > 0) { @@ -186,7 +189,7 @@ public class Options { ErrorHandler.error(String.format("Failed to create configuration folder at '%s/opsu'.", rootPath), null, false); return dir; } else - return new File("./"); + return workingDir; } /** diff --git a/src/itdelatrisu/opsu/Utils.java b/src/itdelatrisu/opsu/Utils.java index 2c833b92..ad2e3771 100644 --- a/src/itdelatrisu/opsu/Utils.java +++ b/src/itdelatrisu/opsu/Utils.java @@ -41,6 +41,7 @@ import java.net.SocketTimeoutException; import java.net.URISyntaxException; import java.net.URL; import java.nio.ByteBuffer; +import java.nio.file.Paths; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.security.cert.X509Certificate; @@ -541,6 +542,14 @@ public class Utils { } } + /** + * Returns the current working directory. + * @return the directory + */ + public static File getWorkingDirectory() { + return Paths.get(".").toAbsolutePath().normalize().toFile(); + } + /** * Parses the integer string argument as a boolean: * {@code 1} is {@code true}, and all other values are {@code false}.