diff --git a/app/src/processing/app/Sketch.java b/app/src/processing/app/Sketch.java index c4fa9b024..a35c78dfa 100644 --- a/app/src/processing/app/Sketch.java +++ b/app/src/processing/app/Sketch.java @@ -946,7 +946,12 @@ public class Sketch { // if the new folder already exists, then first remove its contents before // copying everything over (user will have already been warned). if (newFolder.exists()) { - Util.removeDir(newFolder); + //Util.removeDir(newFolder); + try { + Platform.deleteFile(newFolder); + } catch (IOException e) { + e.printStackTrace(); + } } // in fact, you can't do this on Windows because the file dialog // will instead put you inside the folder, but it happens on OS X a lot. diff --git a/app/src/processing/app/Util.java b/app/src/processing/app/Util.java index 98402e946..245c65ae9 100644 --- a/app/src/processing/app/Util.java +++ b/app/src/processing/app/Util.java @@ -305,11 +305,14 @@ public class Util { /** * Remove all files in a directory and the directory itself. * Prints error messages with failed filenames. Does not follow symlinks. + * Use Platform.deleteFile() instead, which first attempts to use + * the Trash or Recycle Bin, out of an abundance of caution. */ static public boolean removeDir(File dir) { return removeDir(dir, true); } + /** * Remove all files in a directory and the directory itself. * Optionally, prints error messages with failed filenames. diff --git a/app/src/processing/app/contrib/AvailableContribution.java b/app/src/processing/app/contrib/AvailableContribution.java index aab080404..db59fb251 100644 --- a/app/src/processing/app/contrib/AvailableContribution.java +++ b/app/src/processing/app/contrib/AvailableContribution.java @@ -217,8 +217,12 @@ public class AvailableContribution extends Contribution { } // delete the contrib folder inside the libraryXXXXXXtmp folder - Util.removeDir(newContribFolder, false); - + //Util.removeDir(newContribFolder, false); + try { + Platform.deleteFile(newContribFolder); + } catch (IOException e) { + e.printStackTrace(); + } } else { if (status != null) { status.setErrorMessage(Language.text("contrib.errors.overwriting_properties")); @@ -229,7 +233,12 @@ public class AvailableContribution extends Contribution { // Remove any remaining boogers if (tempFolder.exists()) { - Util.removeDir(tempFolder, false); + //Util.removeDir(tempFolder, false); + try { + Platform.deleteFile(tempFolder); + } catch (IOException e) { + e.printStackTrace(); + } } return installedContrib; } diff --git a/app/src/processing/app/contrib/ContributionManager.java b/app/src/processing/app/contrib/ContributionManager.java index d9e1da5ca..bea61b217 100644 --- a/app/src/processing/app/contrib/ContributionManager.java +++ b/app/src/processing/app/contrib/ContributionManager.java @@ -32,6 +32,7 @@ import javax.swing.SwingWorker; import processing.app.Base; import processing.app.Language; import processing.app.Messages; +import processing.app.Platform; import processing.app.Util; import processing.app.ui.Editor; import processing.core.PApplet; @@ -546,7 +547,12 @@ public class ContributionManager { if (possible != null) { for (File f : possible) { if (f.getName().matches(pattern)) { - Util.removeDir(f); + //Util.removeDir(f); + try { + Platform.deleteFile(f); + } catch (IOException e) { + e.printStackTrace(); + } } } } @@ -562,7 +568,12 @@ public class ContributionManager { ); if (markedForDeletion != null) { for (File folder : markedForDeletion) { - Util.removeDir(folder); + //Util.removeDir(folder); + try { + Platform.deleteFile(folder); + } catch (IOException e) { + e.printStackTrace(); + } } } } @@ -629,7 +640,12 @@ public class ContributionManager { if (name != null) { // should not happen, but... updateContribsNames.add(name); } - Util.removeDir(folder); + //Util.removeDir(folder); + try { + Platform.deleteFile(folder); + } catch (IOException e) { + e.printStackTrace(); + } } } diff --git a/app/src/processing/app/contrib/LocalContribution.java b/app/src/processing/app/contrib/LocalContribution.java index 0f8d5cda4..ccf5714f1 100644 --- a/app/src/processing/app/contrib/LocalContribution.java +++ b/app/src/processing/app/contrib/LocalContribution.java @@ -308,14 +308,24 @@ public abstract class LocalContribution extends Contribution { // At this point it should be safe to replace this fella if (contribFolder.exists()) { - Util.removeDir(contribFolder); + //Util.removeDir(contribFolder); + try { + Platform.deleteFile(contribFolder); + } catch (IOException e) { + e.printStackTrace(); + } } } else { // This if should ideally never happen, since this function // is to be called only when restarting on update if (contribFolder.exists() && contribFolder.isDirectory()) { - Util.removeDir(contribFolder); + //Util.removeDir(contribFolder); + try { + Platform.deleteFile(contribFolder); + } catch (IOException e) { + e.printStackTrace(); + } } else if (contribFolder.exists()) { contribFolder.delete(); @@ -447,7 +457,12 @@ public abstract class LocalContribution extends Contribution { if (doBackup) { success = backup(true, status); } else { - success = Util.removeDir(getFolder(), false); + try { + success = Platform.deleteFile(getFolder()); + } catch (IOException e) { + e.printStackTrace(); + success = false; + } } if (success) { diff --git a/todo.txt b/todo.txt index b7ecd4c42..fba0c6317 100755 --- a/todo.txt +++ b/todo.txt @@ -3,6 +3,8 @@ X Bring back getMainProgram() for Python Mode X https://github.com/processing/processing4/issues/409 X You must first install tweak Mode to use this sketch X https://github.com/processing/processing4/issues/415 +X Change straight quotes to smart quotes in the PDE.properties file +X look for other uses of Util.deleteFile() and replace with Platform calls _ test with Python Mode before release sketchbook/open/deletions