X-Git-Url: http://git.nikiroo.be/?p=fanfix.git;a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Ffanfix%2FInstance.java;h=ea66aec0d1b3c7fcedc65dfc31366e29a9b67708;hp=4e4705b352a5aa569cd958b4fc1244b004c1a227;hb=948637bc8cc1dcf76f783870cf46f71794a9805d;hpb=d011400048cae6884f0d94c320498429b45fb48a diff --git a/src/be/nikiroo/fanfix/Instance.java b/src/be/nikiroo/fanfix/Instance.java index 4e4705b..ea66aec 100644 --- a/src/be/nikiroo/fanfix/Instance.java +++ b/src/be/nikiroo/fanfix/Instance.java @@ -23,7 +23,7 @@ public class Instance { private static File readerTmp; static { - // Most of the rest is dependant upon this: + // Most of the rest is dependent upon this: config = new ConfigBundle(); trans = new StringIdBundle(getLang()); @@ -48,7 +48,7 @@ public class Instance { tmp = new File(tmpDir, "fanfic-tmp"); } if (readerTmp == null) { - tmp = new File(tmpDir, "fanfic-reader"); + readerTmp = new File(tmpDir, "fanfic-reader"); } } else { syserr(new IOException( @@ -64,25 +64,31 @@ public class Instance { } String configDir = System.getenv("CONFIG_DIR"); + if (configDir == null) { + configDir = new File(System.getProperty("user.home"), ".fanfix") + .getPath(); + } if (configDir != null) { - if (new File(configDir).isDirectory()) { - Bundles.setDirectory(configDir); - try { - config = new ConfigBundle(); - config.updateFile(configDir); - } catch (IOException e) { - syserr(e); - } - try { - trans = new StringIdBundle(getLang()); - trans.updateFile(configDir); - } catch (IOException e) { - syserr(e); - } + if (!new File(configDir).exists()) { + new File(configDir).mkdirs(); } else { - syserr(new IOException("Configuration directory not found: " - + configDir)); + Bundles.setDirectory(configDir); } + + try { + config = new ConfigBundle(); + config.updateFile(configDir); + } catch (IOException e) { + syserr(e); + } + try { + trans = new StringIdBundle(getLang()); + trans.updateFile(configDir); + } catch (IOException e) { + syserr(e); + } + + Bundles.setDirectory(configDir); } try {