Index: trunk/src/org/openstreetmap/josm/actions/ShowStatusReportAction.java
===================================================================
--- trunk/src/org/openstreetmap/josm/actions/ShowStatusReportAction.java	(revision 12855)
+++ trunk/src/org/openstreetmap/josm/actions/ShowStatusReportAction.java	(revision 12856)
@@ -231,9 +231,9 @@
         final String propJavaHome = System.getProperty("java.home");
         final String propJavaHomeAlt = "<java.home>";
-        final String prefDir = Config.getDirs().getPreferencesDirectory().toString();
+        final String prefDir = Config.getDirs().getPreferencesDirectory(false).toString();
         final String prefDirAlt = "<josm.pref>";
-        final String userDataDir = Config.getDirs().getUserDataDirectory().toString();
+        final String userDataDir = Config.getDirs().getUserDataDirectory(false).toString();
         final String userDataDirAlt = "<josm.userdata>";
-        final String userCacheDir = Config.getDirs().getCacheDirectory().toString();
+        final String userCacheDir = Config.getDirs().getCacheDirectory(false).toString();
         final String userCacheDirAlt = "<josm.cache>";
         final String userHomeDir = System.getProperty("user.home");
Index: trunk/src/org/openstreetmap/josm/data/Preferences.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/Preferences.java	(revision 12855)
+++ trunk/src/org/openstreetmap/josm/data/Preferences.java	(revision 12856)
@@ -331,7 +331,13 @@
      * @return The user defined preferences directory, containing the preferences.xml file
      * @since 7834
-     */
+     * @deprecated use {@link #getPreferencesDirectory(boolean)}
+     */
+    @Deprecated
+    public File getPreferencesDirectory() {
+        return getPreferencesDirectory(false);
+    }
+
     @Override
-    public File getPreferencesDirectory() {
+    public File getPreferencesDirectory(boolean createIfMissing) {
         if (preferencesDir != null)
             return preferencesDir;
@@ -348,4 +354,13 @@
             }
         }
+        if (createIfMissing && !preferencesDir.exists() && !preferencesDir.mkdirs()) {
+            Logging.warn(tr("Failed to create missing preferences directory: {0}", preferencesDir.getAbsoluteFile()));
+            JOptionPane.showMessageDialog(
+                    Main.parent,
+                    tr("<html>Failed to create missing preferences directory: {0}</html>", preferencesDir.getAbsoluteFile()),
+                    tr("Error"),
+                    JOptionPane.ERROR_MESSAGE
+            );
+        }
         return preferencesDir;
     }
@@ -356,7 +371,13 @@
      * @return The user data directory, containing autosave, plugins, etc.
      * @since 7834
-     */
+     * @deprecated use {@link #getUserDataDirectory(boolean)}
+     */
+    @Deprecated
+    public File getUserDataDirectory() {
+        return getUserDataDirectory(false);
+    }
+
     @Override
-    public File getUserDataDirectory() {
+    public File getUserDataDirectory(boolean createIfMissing) {
         if (userdataDir != null)
             return userdataDir;
@@ -373,4 +394,13 @@
             }
         }
+        if (createIfMissing && !userdataDir.exists() && !userdataDir.mkdirs()) {
+            Logging.warn(tr("Failed to create missing user data directory: {0}", userdataDir.getAbsoluteFile()));
+            JOptionPane.showMessageDialog(
+                    Main.parent,
+                    tr("<html>Failed to create missing user data directory: {0}</html>", userdataDir.getAbsoluteFile()),
+                    tr("Error"),
+                    JOptionPane.ERROR_MESSAGE
+            );
+        }
         return userdataDir;
     }
@@ -381,5 +411,5 @@
      */
     public File getPreferenceFile() {
-        return new File(getPreferencesDirectory(), "preferences.xml");
+        return new File(getPreferencesDirectory(false), "preferences.xml");
     }
 
@@ -389,5 +419,5 @@
      */
     public File getDefaultsCacheFile() {
-        return new File(getCacheDirectory(), "default_preferences.xml");
+        return new File(getCacheDirectory(true), "default_preferences.xml");
     }
 
@@ -397,5 +427,5 @@
      */
     public File getPluginsDirectory() {
-        return new File(getUserDataDirectory(), "plugins");
+        return new File(getUserDataDirectory(false), "plugins");
     }
 
@@ -406,7 +436,13 @@
      *
      * @return the cache directory
-     */
+     * @deprecated use {@link #getCacheDirectory(boolean)}
+     */
+    @Deprecated
+    public File getCacheDirectory() {
+        return getCacheDirectory(true);
+    }
+
     @Override
-    public File getCacheDirectory() {
+    public File getCacheDirectory(boolean createIfMissing) {
         if (cacheDir != null)
             return cacheDir;
@@ -427,5 +463,5 @@
             }
         }
-        if (!cacheDir.exists() && !cacheDir.mkdirs()) {
+        if (createIfMissing && !cacheDir.exists() && !cacheDir.mkdirs()) {
             Logging.warn(tr("Failed to create missing cache directory: {0}", cacheDir.getAbsoluteFile()));
             JOptionPane.showMessageDialog(
@@ -454,6 +490,6 @@
     public Collection<String> getAllPossiblePreferenceDirs() {
         Set<String> locations = new HashSet<>();
-        addPossibleResourceDir(locations, getPreferencesDirectory().getPath());
-        addPossibleResourceDir(locations, getUserDataDirectory().getPath());
+        addPossibleResourceDir(locations, getPreferencesDirectory(false).getPath());
+        addPossibleResourceDir(locations, getUserDataDirectory(false).getPath());
         addPossibleResourceDir(locations, System.getenv("JOSM_RESOURCES"));
         addPossibleResourceDir(locations, System.getProperty("josm.resources"));
@@ -718,5 +754,5 @@
         initSuccessful = false;
         // get the preferences.
-        File prefDir = getPreferencesDirectory();
+        File prefDir = getPreferencesDirectory(false);
         if (prefDir.exists()) {
             if (!prefDir.isDirectory()) {
Index: trunk/src/org/openstreetmap/josm/data/cache/JCSCacheManager.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/cache/JCSCacheManager.java	(revision 12855)
+++ trunk/src/org/openstreetmap/josm/data/cache/JCSCacheManager.java	(revision 12856)
@@ -101,5 +101,5 @@
     @SuppressWarnings("resource")
     private static void initialize() throws IOException {
-        File cacheDir = new File(Config.getDirs().getCacheDirectory(), "jcs");
+        File cacheDir = new File(Config.getDirs().getCacheDirectory(true), "jcs");
 
         if (!cacheDir.exists() && !cacheDir.mkdirs())
Index: trunk/src/org/openstreetmap/josm/data/imagery/CachedTileLoaderFactory.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/imagery/CachedTileLoaderFactory.java	(revision 12855)
+++ trunk/src/org/openstreetmap/josm/data/imagery/CachedTileLoaderFactory.java	(revision 12856)
@@ -56,5 +56,5 @@
         String defPath = null;
         try {
-            defPath = new File(Config.getDirs().getCacheDirectory(), "tiles").getAbsolutePath();
+            defPath = new File(Config.getDirs().getCacheDirectory(true), "tiles").getAbsolutePath();
         } catch (SecurityException e) {
             Logging.warn(e);
Index: trunk/src/org/openstreetmap/josm/data/validation/OsmValidator.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/validation/OsmValidator.java	(revision 12855)
+++ trunk/src/org/openstreetmap/josm/data/validation/OsmValidator.java	(revision 12856)
@@ -176,5 +176,5 @@
      */
     public static String getValidatorDir() {
-        return new File(Config.getDirs().getUserDataDirectory(), "validator").getAbsolutePath();
+        return new File(Config.getDirs().getUserDataDirectory(true), "validator").getAbsolutePath();
     }
 
Index: trunk/src/org/openstreetmap/josm/gui/io/CustomConfigurator.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/io/CustomConfigurator.java	(revision 12855)
+++ trunk/src/org/openstreetmap/josm/gui/io/CustomConfigurator.java	(revision 12856)
@@ -425,7 +425,7 @@
         String dir;
         if ("prefs".equals(base) || base.isEmpty()) {
-            dir = Config.getDirs().getPreferencesDirectory().getAbsolutePath();
+            dir = Config.getDirs().getPreferencesDirectory(false).getAbsolutePath();
         } else if ("cache".equals(base)) {
-            dir = Config.getDirs().getCacheDirectory().getAbsolutePath();
+            dir = Config.getDirs().getCacheDirectory(false).getAbsolutePath();
         } else if ("plugins".equals(base)) {
             dir = Main.pref.getPluginsDirectory().getAbsolutePath();
@@ -477,5 +477,5 @@
                 engine.eval("API={}; API.pref={}; API.fragments={};");
 
-                engine.eval("homeDir='"+normalizeDirName(Config.getDirs().getPreferencesDirectory().getAbsolutePath()) +"';");
+                engine.eval("homeDir='"+normalizeDirName(Config.getDirs().getPreferencesDirectory(false).getAbsolutePath()) +"';");
                 engine.eval("josmVersion="+Version.getInstance().getVersion()+';');
                 String className = CustomConfigurator.class.getName();
Index: trunk/src/org/openstreetmap/josm/gui/layer/AutosaveTask.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/layer/AutosaveTask.java	(revision 12855)
+++ trunk/src/org/openstreetmap/josm/gui/layer/AutosaveTask.java	(revision 12856)
@@ -116,6 +116,6 @@
     private final Deque<File> deletedLayers = new LinkedList<>();
 
-    private final File autosaveDir = new File(Config.getDirs().getUserDataDirectory(), AUTOSAVE_DIR);
-    private final File deletedLayersDir = new File(Config.getDirs().getUserDataDirectory(), DELETED_LAYERS_DIR);
+    private final File autosaveDir = new File(Config.getDirs().getUserDataDirectory(true), AUTOSAVE_DIR);
+    private final File deletedLayersDir = new File(Config.getDirs().getUserDataDirectory(true), DELETED_LAYERS_DIR);
 
     /**
Index: trunk/src/org/openstreetmap/josm/gui/layer/geoimage/ThumbsLoader.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/layer/geoimage/ThumbsLoader.java	(revision 12855)
+++ trunk/src/org/openstreetmap/josm/gui/layer/geoimage/ThumbsLoader.java	(revision 12856)
@@ -69,5 +69,5 @@
             try {
                 cache = JCSCacheManager.getCache("geoimage-thumbnails", 0, 120,
-                        Config.getDirs().getCacheDirectory().getPath() + File.separator + "geoimage-thumbnails");
+                        Config.getDirs().getCacheDirectory(true).getPath() + File.separator + "geoimage-thumbnails");
             } catch (IOException e) {
                 Logging.warn("Failed to initialize cache for geoimage-thumbnails");
Index: trunk/src/org/openstreetmap/josm/gui/preferences/advanced/AdvancedPreference.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/preferences/advanced/AdvancedPreference.java	(revision 12855)
+++ trunk/src/org/openstreetmap/josm/gui/preferences/advanced/AdvancedPreference.java	(revision 12856)
@@ -370,5 +370,5 @@
                     }
                 }
-                files = Config.getDirs().getPreferencesDirectory().listFiles();
+                files = Config.getDirs().getPreferencesDirectory(false).listFiles();
                 if (files != null) {
                     for (File f: files) {
Index: trunk/src/org/openstreetmap/josm/io/CacheCustomContent.java
===================================================================
--- trunk/src/org/openstreetmap/josm/io/CacheCustomContent.java	(revision 12855)
+++ trunk/src/org/openstreetmap/josm/io/CacheCustomContent.java	(revision 12856)
@@ -76,5 +76,5 @@
         this.ident = ident;
         this.updateInterval = updateInterval;
-        this.path = new File(Config.getDirs().getCacheDirectory(), ident);
+        this.path = new File(Config.getDirs().getCacheDirectory(true), ident);
     }
 
Index: trunk/src/org/openstreetmap/josm/io/CachedFile.java
===================================================================
--- trunk/src/org/openstreetmap/josm/io/CachedFile.java	(revision 12855)
+++ trunk/src/org/openstreetmap/josm/io/CachedFile.java	(revision 12856)
@@ -277,5 +277,5 @@
                 return null;
             } else if (name.startsWith("josmdir://")) {
-                cacheFile = new File(Config.getDirs().getUserDataDirectory(), name.substring("josmdir://".length()));
+                cacheFile = new File(Config.getDirs().getUserDataDirectory(false), name.substring("josmdir://".length()));
             } else if (name.startsWith("josmplugindir://")) {
                 cacheFile = new File(Main.pref.getPluginsDirectory(), name.substring("josmplugindir://".length()));
@@ -448,5 +448,5 @@
         }
         if (destDir == null) {
-            destDir = Config.getDirs().getCacheDirectory().getPath();
+            destDir = Config.getDirs().getCacheDirectory(true).getPath();
         }
 
Index: trunk/src/org/openstreetmap/josm/io/remotecontrol/RemoteControl.java
===================================================================
--- trunk/src/org/openstreetmap/josm/io/remotecontrol/RemoteControl.java	(revision 12855)
+++ trunk/src/org/openstreetmap/josm/io/remotecontrol/RemoteControl.java	(revision 12856)
@@ -95,5 +95,5 @@
      */
     public static String getRemoteControlDir() {
-        return new File(Config.getDirs().getUserDataDirectory(), "remotecontrol").getAbsolutePath();
+        return new File(Config.getDirs().getUserDataDirectory(true), "remotecontrol").getAbsolutePath();
     }
 
Index: trunk/src/org/openstreetmap/josm/spi/preferences/IBaseDirectories.java
===================================================================
--- trunk/src/org/openstreetmap/josm/spi/preferences/IBaseDirectories.java	(revision 12855)
+++ trunk/src/org/openstreetmap/josm/spi/preferences/IBaseDirectories.java	(revision 12856)
@@ -15,19 +15,28 @@
      * Get the directory where user-specific configuration and preferences
      * should be stored.
+     * @param createIfMissing if true, automatically creates this directory,
+     * in case it is missing
      * @return the preferences directory
+     * @since 12856
      */
-    File getPreferencesDirectory();
+    File getPreferencesDirectory(boolean createIfMissing);
 
     /**
      * Get the directory where user-specific data files should be stored.
+     * @param createIfMissing if true, automatically creates this directory,
+     * in case it is missing
      * @return the user data directory
+     * @since 12856
      */
-    File getUserDataDirectory();
+    File getUserDataDirectory(boolean createIfMissing);
 
     /**
      * Get the directory where user-specific cached content (non-essential data)
      * should be stored.
+     * @param createIfMissing if true, automatically creates this directory,
+     * in case it is missing
      * @return the cache directory
+     * @since 12856
      */
-    File getCacheDirectory();
+    File getCacheDirectory(boolean createIfMissing);
 }
Index: trunk/src/org/openstreetmap/josm/tools/ImageProvider.java
===================================================================
--- trunk/src/org/openstreetmap/josm/tools/ImageProvider.java	(revision 12855)
+++ trunk/src/org/openstreetmap/josm/tools/ImageProvider.java	(revision 12856)
@@ -928,5 +928,5 @@
     private static ImageResource getIfAvailableHttp(String url, ImageType type) {
         try (CachedFile cf = new CachedFile(url).setDestDir(
-                new File(Config.getDirs().getCacheDirectory(), "images").getPath());
+                new File(Config.getDirs().getCacheDirectory(true), "images").getPath());
              InputStream is = cf.getInputStream()) {
             switch (type) {
@@ -1174,5 +1174,5 @@
         // Try user-data directory
         if (Config.getDirs() != null) {
-            String dir = new File(Config.getDirs().getUserDataDirectory(), "images").getAbsolutePath();
+            String dir = new File(Config.getDirs().getUserDataDirectory(false), "images").getAbsolutePath();
             try {
                 u = getImageUrl(dir, imageName, additionalClassLoaders);
@@ -1248,5 +1248,5 @@
 
             try (CachedFile cf = new CachedFile(base + fn).setDestDir(
-                        new File(Config.getDirs().getUserDataDirectory(), "images").getPath());
+                        new File(Config.getDirs().getUserDataDirectory(true), "images").getPath());
                  InputStream is = cf.getInputStream()) {
                 parser.parse(new InputSource(is));
Index: trunk/src/org/openstreetmap/josm/tools/PlatformHookWindows.java
===================================================================
--- trunk/src/org/openstreetmap/josm/tools/PlatformHookWindows.java	(revision 12855)
+++ trunk/src/org/openstreetmap/josm/tools/PlatformHookWindows.java	(revision 12856)
@@ -477,5 +477,5 @@
     public File getDefaultUserDataDirectory() {
         // Use preferences directory by default
-        return Config.getDirs().getPreferencesDirectory();
+        return Config.getDirs().getPreferencesDirectory(false);
     }
 
@@ -522,5 +522,5 @@
             props.load(fis);
             byte[] content = Files.readAllBytes(templateFile);
-            File cachePath = Config.getDirs().getCacheDirectory();
+            File cachePath = Config.getDirs().getCacheDirectory(true);
             Path fontconfigFile = cachePath.toPath().resolve("fontconfig.properties");
             OutputStream os = Files.newOutputStream(fontconfigFile);
Index: trunk/src/org/openstreetmap/josm/tools/RightAndLefthandTraffic.java
===================================================================
--- trunk/src/org/openstreetmap/josm/tools/RightAndLefthandTraffic.java	(revision 12855)
+++ trunk/src/org/openstreetmap/josm/tools/RightAndLefthandTraffic.java	(revision 12856)
@@ -153,5 +153,5 @@
     private static void saveOptimizedBoundaries(Collection<Way> optimizedWays) {
         DataSet ds = optimizedWays.iterator().next().getDataSet();
-        File file = new File(Config.getDirs().getCacheDirectory(), "left-right-hand-traffic.osm");
+        File file = new File(Config.getDirs().getCacheDirectory(true), "left-right-hand-traffic.osm");
         try (Writer writer = new OutputStreamWriter(new FileOutputStream(file), StandardCharsets.UTF_8);
              OsmWriter w = OsmWriterFactory.createOsmWriter(new PrintWriter(writer), false, ds.getVersion())
@@ -166,5 +166,6 @@
 
     private static Collection<Way> loadOptimizedBoundaries() {
-        try (InputStream is = new FileInputStream(new File(Config.getDirs().getCacheDirectory(), "left-right-hand-traffic.osm"))) {
+        try (InputStream is = new FileInputStream(new File(
+                Config.getDirs().getCacheDirectory(false), "left-right-hand-traffic.osm"))) {
            return OsmReader.parseDataSet(is, null).getWays();
         } catch (IllegalDataException | IOException ex) {
