Better-defined root directory.

- If running from a JAR, the root directory will be the same directory as the JAR (not where it was launched).
- Otherwise, use the current working directory.
- XDG unaffected.

Signed-off-by: Jeffrey Han <itdelatrisu@gmail.com>
This commit is contained in:
Jeffrey Han
2016-12-22 19:54:05 -05:00
parent 25efbd3023
commit 81c8a61bb8
2 changed files with 14 additions and 2 deletions

View File

@@ -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}.