Use XDG_CONFIG_HOME
This commit is contained in:
parent
837b08c4cb
commit
0704a4a931
@ -118,12 +118,10 @@ public class MainController implements Initializable {
|
|||||||
XmlMapper xmlMapper = new XmlMapper();
|
XmlMapper xmlMapper = new XmlMapper();
|
||||||
xmlMapper.registerModule(new JavaTimeModule());
|
xmlMapper.registerModule(new JavaTimeModule());
|
||||||
String userHome = System.getProperty("user.home");
|
String userHome = System.getProperty("user.home");
|
||||||
// TODO: XDG
|
|
||||||
Path directoryPath = Paths.get(userHome, ".numbers-station");
|
|
||||||
Path filePath = directoryPath.resolve("settings.xml");
|
|
||||||
try {
|
|
||||||
|
|
||||||
// Create the directory if it doesn't exist
|
Path filePath = MainSettings.getSettingsFilePath();
|
||||||
|
Path directoryPath = filePath.getParent();
|
||||||
|
try {
|
||||||
if (!Files.exists(directoryPath)) {
|
if (!Files.exists(directoryPath)) {
|
||||||
Files.createDirectories(directoryPath);
|
Files.createDirectories(directoryPath);
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,21 @@ public class MainSettings {
|
|||||||
stations.add(new StationSettings("Station 1"));
|
stations.add(new StationSettings("Station 1"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Path getSettingsFilePath() {
|
||||||
|
String configHome = System.getenv("XDG_CONFIG_HOME");
|
||||||
|
Path directoryPath;
|
||||||
|
Path filePath;
|
||||||
|
|
||||||
|
if (configHome != null && !configHome.isEmpty()) {
|
||||||
|
directoryPath = Paths.get(configHome, "numbers-station");
|
||||||
|
} else {
|
||||||
|
String userHome = System.getProperty("user.home");
|
||||||
|
directoryPath = Paths.get(userHome, ".config", "numbers-station");
|
||||||
|
}
|
||||||
|
|
||||||
|
return directoryPath.resolve("main-settings.xml");
|
||||||
|
}
|
||||||
|
|
||||||
public ArrayList<StationSettings> getStations() {
|
public ArrayList<StationSettings> getStations() {
|
||||||
return stations;
|
return stations;
|
||||||
}
|
}
|
||||||
@ -58,11 +73,9 @@ public class MainSettings {
|
|||||||
xmlMapper.registerModule(new JavaTimeModule());
|
xmlMapper.registerModule(new JavaTimeModule());
|
||||||
xmlMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
|
xmlMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
|
||||||
try {
|
try {
|
||||||
String userHome = System.getProperty("user.home");
|
Path filePath = getSettingsFilePath();
|
||||||
Path directoryPath = Paths.get(userHome, ".numbers-station");
|
Path directoryPath = filePath.getParent();
|
||||||
Path filePath = directoryPath.resolve("settings.xml");
|
|
||||||
|
|
||||||
// Create the directory if it doesn't exist
|
|
||||||
if (!Files.exists(directoryPath)) {
|
if (!Files.exists(directoryPath)) {
|
||||||
Files.createDirectories(directoryPath);
|
Files.createDirectories(directoryPath);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user