working on platform classes, adding move to trash option

This commit is contained in:
Ben Fry
2013-07-20 18:57:05 -04:00
parent 1dd5151383
commit fdfddd616e
3 changed files with 30 additions and 11 deletions
+18
View File
@@ -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;
}
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
+12 -2
View File
@@ -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);
}
/*
@@ -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.
*