66 lines
3.5 KiB
Diff
66 lines
3.5 KiB
Diff
|
diff --git a/src/main/java/moviescraper/doctord/controller/amalgamation/AllAmalgamationOrderingPreferences.java b/src/main/java/moviescraper/doctord/controller/amalgamation/AllAmalgamationOrderingPreferences.java
|
||
|
index ac9cf4e..ce57ee3 100644
|
||
|
--- a/src/main/java/moviescraper/doctord/controller/amalgamation/AllAmalgamationOrderingPreferences.java
|
||
|
+++ b/src/main/java/moviescraper/doctord/controller/amalgamation/AllAmalgamationOrderingPreferences.java
|
||
|
@@ -29,7 +29,8 @@ import moviescraper.doctord.controller.siteparsingprofile.specific.TheMovieDatab
|
||
|
public class AllAmalgamationOrderingPreferences {
|
||
|
|
||
|
Map<ScraperGroupName, ScraperGroupAmalgamationPreference> allAmalgamationOrderingPreferences;
|
||
|
- private static final String settingsFileName = "AmalgamationSettings.json";
|
||
|
+ private final static String folderNameOfSettings = (System.getenv("XDG_CONFIG_HOME") != null ? System.getenv("XDG_CONFIG_HOME") : System.getenv("HOME")) + "/.config/JAVMovieSraper";
|
||
|
+ private static final String settingsFileName = folderNameOfSettings + "/AmalgamationSettings.json";
|
||
|
|
||
|
public AllAmalgamationOrderingPreferences() {
|
||
|
allAmalgamationOrderingPreferences = new Hashtable<>();
|
||
|
@@ -89,7 +90,9 @@ public class AllAmalgamationOrderingPreferences {
|
||
|
}
|
||
|
|
||
|
public void saveToPreferencesFile() {
|
||
|
- try (FileOutputStream outputStream = new FileOutputStream(settingsFileName); JsonWriter jw = new JsonWriter(outputStream);) {
|
||
|
+ File f = new File(settingsFileName);
|
||
|
+ f.getParentFile().mkdirs();
|
||
|
+ try (FileOutputStream outputStream = new FileOutputStream(f); JsonWriter jw = new JsonWriter(outputStream);) {
|
||
|
jw.write(this);
|
||
|
System.out.println("Saved amalgamation preferences to " + settingsFileName);
|
||
|
} catch (IOException e1) {
|
||
|
diff --git a/src/main/java/moviescraper/doctord/model/preferences/Settings.java b/src/main/java/moviescraper/doctord/model/preferences/Settings.java
|
||
|
index 5810bf3..84fdde2 100644
|
||
|
--- a/src/main/java/moviescraper/doctord/model/preferences/Settings.java
|
||
|
+++ b/src/main/java/moviescraper/doctord/model/preferences/Settings.java
|
||
|
@@ -3,6 +3,7 @@ package moviescraper.doctord.model.preferences;
|
||
|
import java.io.FileInputStream;
|
||
|
import java.io.FileNotFoundException;
|
||
|
import java.io.FileOutputStream;
|
||
|
+import java.io.File;
|
||
|
import java.io.IOException;
|
||
|
import java.util.InvalidPropertiesFormatException;
|
||
|
import java.util.Properties;
|
||
|
@@ -10,7 +11,8 @@ import java.util.Properties;
|
||
|
public class Settings {
|
||
|
|
||
|
private final static Properties programPreferences = new Properties();
|
||
|
- private static final String fileNameOfPreferences = "settings.xml";
|
||
|
+ private final static String folderNameOfPreferences = (System.getenv("XDG_CONFIG_HOME") != null ? System.getenv("XDG_CONFIG_HOME") : System.getenv("HOME")) + "/.config/JAVMovieSraper";
|
||
|
+ private static final String fileNameOfPreferences = folderNameOfPreferences + "/settings.xml";
|
||
|
|
||
|
protected interface Key {
|
||
|
String getKey();
|
||
|
@@ -39,7 +41,9 @@ public class Settings {
|
||
|
}
|
||
|
|
||
|
public static void savePreferences() {
|
||
|
- try (FileOutputStream settingsOutputStream = new FileOutputStream(fileNameOfPreferences);) {
|
||
|
+ File f = new File(fileNameOfPreferences);
|
||
|
+ f.getParentFile().mkdirs();
|
||
|
+ try (FileOutputStream settingsOutputStream = new FileOutputStream(f);) {
|
||
|
programPreferences.storeToXML(settingsOutputStream, "");
|
||
|
} catch (FileNotFoundException e) {
|
||
|
// TODO Auto-generated catch block
|
||
|
@@ -115,4 +119,4 @@ public class Settings {
|
||
|
public String toString() {
|
||
|
return programPreferences.toString();
|
||
|
}
|
||
|
-}
|
||
|
\ No newline at end of file
|
||
|
+}
|