Index: trunk/src/org/openstreetmap/josm/io/CachedFile.java
===================================================================
--- trunk/src/org/openstreetmap/josm/io/CachedFile.java	(revision 7834)
+++ trunk/src/org/openstreetmap/josm/io/CachedFile.java	(revision 7835)
@@ -80,5 +80,5 @@
      *  <li>{@code resource://SOME/FILE} file from the classpath (usually in the current *.jar)</li>
      *  <li>{@code josmdir://SOME/FILE} file inside josm user data directory (since r7058)</li></ul>
-     *  <li>{@code josmplugindir://SOME/FILE} file inside josm plugin directory (since r7832)</li></ul>
+     *  <li>{@code josmplugindir://SOME/FILE} file inside josm plugin directory (since r7834)</li></ul>
      */
     public CachedFile(String name) {
@@ -94,5 +94,5 @@
      *  <li>{@code resource://SOME/FILE} file from the classpath (usually in the current *.jar)</li>
      *  <li>{@code josmdir://SOME/FILE} file inside josm user data directory (since r7058)</li></ul>
-     *  <li>{@code josmplugindir://SOME/FILE} file inside josm plugin directory (since r7832)</li></ul>
+     *  <li>{@code josmplugindir://SOME/FILE} file inside josm plugin directory (since r7834)</li></ul>
      * @return this object
      */
Index: trunk/src/org/openstreetmap/josm/tools/PlatformHookOsx.java
===================================================================
--- trunk/src/org/openstreetmap/josm/tools/PlatformHookOsx.java	(revision 7834)
+++ trunk/src/org/openstreetmap/josm/tools/PlatformHookOsx.java	(revision 7835)
@@ -38,4 +38,5 @@
         // They just insist on painting themselves...
         Preferences.updateSystemProperty("apple.laf.useScreenMenuBar", "true");
+        migrateOldDirectory();
     }
 
@@ -338,3 +339,55 @@
         return new File(System.getProperty("user.home")+"/Library/Application Support", "JOSM");
     }
+
+    /***
+     * Prior to r7834, JOSM used the same Unix directory ~/.josm for all local files (preferences,
+     * caches, user data). This method migrates the existing preferences and plugins to new directories
+     * if applicable. Old directory, including cache, is deleted.
+     * Method to remove end of 2015.
+     * @since 7835
+     */
+    public static void migrateOldDirectory() {
+        File oldDir = new File(System.getProperty("user.home"), ".josm");
+        if (oldDir.exists()) {
+            boolean error = false;
+
+            File oldPref = new File(oldDir, "preferences.xml");
+            if (oldPref.exists()) {
+                File newPref = Main.pref.getPreferenceFile();
+                if (!newPref.exists()) {
+                    try {
+                        Main.pref.getPreferencesDirectory().mkdirs();
+                        Main.info("Copying old preferences file to new location");
+                        Utils.copyFile(oldPref, newPref);
+                        if (!oldPref.delete()) {
+                            Main.warn("Unable to delete old preferences file: "+oldPref.getPath());
+                        }
+                    } catch (IOException e) {
+                        Main.error(e);
+                        error = true;
+                    }
+                }
+            }
+
+            File oldPlugins = new File(oldDir, "plugins");
+            if (oldPlugins.exists()) {
+                File newPlugins = Main.pref.getPluginsDirectory();
+                if (!newPlugins.exists()) {
+                    try {
+                        Utils.copyDirectory(oldPlugins, newPlugins);
+                    } catch (IOException e) {
+                        Main.error(e);
+                        error = true;
+                    }
+                }
+            }
+
+            if (!error) {
+                Main.info("Deleting old preferences directory");
+                if (!Utils.deleteDirectory(oldDir)) {
+                    Main.warn("Unable to delete old preferences directory");
+                }
+            }
+        }
+    }
 }
Index: trunk/src/org/openstreetmap/josm/tools/Utils.java
===================================================================
--- trunk/src/org/openstreetmap/josm/tools/Utils.java	(revision 7834)
+++ trunk/src/org/openstreetmap/josm/tools/Utils.java	(revision 7835)
@@ -324,5 +324,5 @@
 
     /**
-     * Simple file copy function that will overwrite the target file.<br>
+     * Simple file copy function that will overwrite the target file.
      * @param in The source file
      * @param out The destination file
@@ -332,8 +332,32 @@
      * @since 7003
      */
-    public static Path copyFile(File in, File out) throws IOException, IllegalArgumentException  {
+    public static Path copyFile(File in, File out) throws IOException {
         CheckParameterUtil.ensureParameterNotNull(in, "in");
         CheckParameterUtil.ensureParameterNotNull(out, "out");
         return Files.copy(in.toPath(), out.toPath(), StandardCopyOption.REPLACE_EXISTING);
+    }
+
+    /**
+     * Recursive directory copy function
+     * @param in The source directory
+     * @param out The destination directory
+     * @throws IOException If any I/O error ooccurs
+     * @throws IllegalArgumentException If {@code in} or {@code out} is {@code null}
+     * @since 7835
+     */
+    public static void copyDirectory(File in, File out) throws IOException {
+        CheckParameterUtil.ensureParameterNotNull(in, "in");
+        CheckParameterUtil.ensureParameterNotNull(out, "out");
+        if (!out.exists() && !out.mkdirs()) {
+            Main.warn("Unable to create directory "+out.getPath());
+        }
+        for (File f : in.listFiles()) {
+            File target = new File(out, f.getName());
+            if (f.isDirectory()) {
+                copyDirectory(f, target);
+            } else {
+                copyFile(f, target);
+            }
+        }
     }
 
@@ -349,4 +373,10 @@
     }
 
+    /**
+     * Deletes a directory recursively.
+     * @param path The directory to delete
+     * @return  <code>true</code> if and only if the file or directory is
+     *          successfully deleted; <code>false</code> otherwise
+     */
     public static boolean deleteDirectory(File path) {
         if( path.exists() ) {
@@ -355,10 +385,10 @@
                 if (file.isDirectory()) {
                     deleteDirectory(file);
-                } else {
-                    file.delete();
+                } else if (!file.delete()) {
+                    Main.warn("Unable to delete file: "+file.getPath());
                 }
             }
         }
-        return( path.delete() );
+        return path.delete();
     }
 
