Skip to content

Commit 6e0d483

Browse files
committed
working on platform classes, adding move to trash option
1 parent bb3ebda commit 6e0d483

File tree

3 files changed

+30
-11
lines changed

3 files changed

+30
-11
lines changed

app/src/processing/app/Platform.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
import java.awt.Desktop;
2626
import java.io.File;
27+
import java.io.IOException;
2728
import java.net.URI;
2829

2930
import javax.swing.UIManager;
@@ -142,6 +143,23 @@ public void openFolder(File file) throws Exception {
142143
}
143144
*/
144145
}
146+
147+
148+
/**
149+
* Attempts to move to the Trash on OS X, or the Recycle Bin on Windows.
150+
* If not possible, just deletes the file or folder instead.
151+
* @param file the folder or file to be removed/deleted
152+
* @return true if the folder was successfully removed
153+
* @throws IOException
154+
*/
155+
public boolean deleteFile(File file) throws IOException {
156+
if (file.isDirectory()) {
157+
Base.removeDir(file);
158+
} else {
159+
return file.delete();
160+
}
161+
return true;
162+
}
145163

146164

147165
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

app/src/processing/app/macosx/Platform.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
import java.io.File;
2626
import java.io.FileNotFoundException;
27+
import java.io.IOException;
2728

2829
import com.apple.eio.FileManager;
2930

@@ -79,8 +80,8 @@ public void init(Base base) {
7980
}
8081
*/
8182
}
82-
83-
83+
84+
8485
public File getSettingsFolder() throws Exception {
8586
return new File(getLibraryFolder(), "Processing");
8687
}
@@ -101,6 +102,15 @@ public File getDefaultSketchbookFolder() throws Exception {
101102
}
102103
*/
103104
}
105+
106+
107+
/**
108+
* Moves the specified File object (which might be a file or folder)
109+
* to the trash.
110+
*/
111+
public boolean deleteFile(File file) throws IOException {
112+
return FileManager.moveToTrash(file);
113+
}
104114

105115

106116
/*

app/src/processing/app/windows/Registry.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,6 @@ public static enum REGISTRY_ROOT_KEY{CLASSES_ROOT, CURRENT_USER, LOCAL_MACHINE,
2121
rootKeyMap.put(REGISTRY_ROOT_KEY.USERS, WINREG.HKEY_USERS);
2222
}
2323

24-
/**
25-
* Testing.
26-
*
27-
* @param args arguments
28-
* @throws java.lang.Exception on error
29-
*/
30-
public static void main(String[] args) throws Exception {
31-
}
32-
3324
/**
3425
* Gets one of the root keys.
3526
*

0 commit comments

Comments
 (0)