Add: support for user-global configuration.
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
package dev.photosync.platform;
|
||||
|
||||
import java.nio.file.Path;
|
||||
|
||||
/**
|
||||
* The OS-user-level directory PhotoSync offers for its settings file.
|
||||
*
|
||||
* <p>One rule, written once: Windows keeps per-user application data under
|
||||
* {@code %APPDATA%}, everything else under {@code ~/.config} (the convention
|
||||
* the Linux desktops and macOS share). Nine buckets compile this class, so a
|
||||
* fix to the rule needs one edit instead of nine.
|
||||
*/
|
||||
public final class UserDataDirectory {
|
||||
|
||||
private UserDataDirectory() {
|
||||
}
|
||||
|
||||
public static Path resolve() {
|
||||
String appData = System.getenv("APPDATA");
|
||||
Path base = appData == null || appData.isBlank()
|
||||
? Path.of(System.getProperty("user.home"), ".config")
|
||||
: Path.of(appData);
|
||||
return base.resolve("photosyncmod");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user