diff --git a/app/src/processing/app/Platform.java b/app/src/processing/app/Platform.java index 2cf380e66..8c71b3416 100644 --- a/app/src/processing/app/Platform.java +++ b/app/src/processing/app/Platform.java @@ -24,6 +24,7 @@ package processing.app; import java.awt.Desktop; import java.io.File; +import java.io.IOException; import java.net.URI; import javax.swing.UIManager; @@ -142,6 +143,23 @@ public class Platform { } */ } + + + /** + * Attempts to move to the Trash on OS X, or the Recycle Bin on Windows. + * If not possible, just deletes the file or folder instead. + * @param file the folder or file to be removed/deleted + * @return true if the folder was successfully removed + * @throws IOException + */ + public boolean deleteFile(File file) throws IOException { + if (file.isDirectory()) { + Base.removeDir(file); + } else { + return file.delete(); + } + return true; + } // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . diff --git a/app/src/processing/app/macosx/Platform.java b/app/src/processing/app/macosx/Platform.java index 406e65987..8cc71a38d 100644 --- a/app/src/processing/app/macosx/Platform.java +++ b/app/src/processing/app/macosx/Platform.java @@ -24,6 +24,7 @@ package processing.app.macosx; import java.io.File; import java.io.FileNotFoundException; +import java.io.IOException; import com.apple.eio.FileManager; @@ -79,8 +80,8 @@ public class Platform extends processing.app.Platform { } */ } - - + + public File getSettingsFolder() throws Exception { return new File(getLibraryFolder(), "Processing"); } @@ -101,6 +102,15 @@ public class Platform extends processing.app.Platform { } */ } + + + /** + * Moves the specified File object (which might be a file or folder) + * to the trash. + */ + public boolean deleteFile(File file) throws IOException { + return FileManager.moveToTrash(file); + } /* diff --git a/app/src/processing/app/windows/Registry.java b/app/src/processing/app/windows/Registry.java index 06d0e0ed5..dcb719ef8 100644 --- a/app/src/processing/app/windows/Registry.java +++ b/app/src/processing/app/windows/Registry.java @@ -21,15 +21,6 @@ public class Registry { rootKeyMap.put(REGISTRY_ROOT_KEY.USERS, WINREG.HKEY_USERS); } - /** - * Testing. - * - * @param args arguments - * @throws java.lang.Exception on error - */ - public static void main(String[] args) throws Exception { - } - /** * Gets one of the root keys. *