| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -24,6 +24,7 @@ | |||
| 24 | 24 | ||
| 25 | 25 | import java.awt.Desktop; | |
| 26 | 26 | import java.io.File; | |
| 27 | + import java.io.IOException; | ||
| 27 | 28 | import java.net.URI; | |
| 28 | 29 | ||
| 29 | 30 | import javax.swing.UIManager; | |
@@ -142,6 +143,23 @@ public void openFolder(File file) throws Exception { | |||
| 142 | 143 | } | |
| 143 | 144 | */ | |
| 144 | 145 | } | |
| 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 | + } | ||
| 145 | 163 | ||
| 146 | 164 | ||
| 147 | 165 | // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -24,6 +24,7 @@ | |||
| 24 | 24 | ||
| 25 | 25 | import java.io.File; | |
| 26 | 26 | import java.io.FileNotFoundException; | |
| 27 | + import java.io.IOException; | ||
| 27 | 28 | ||
| 28 | 29 | import com.apple.eio.FileManager; | |
| 29 | 30 | ||
@@ -79,8 +80,8 @@ public void init(Base base) { | |||
| 79 | 80 | } | |
| 80 | 81 | */ | |
| 81 | 82 | } | |
| 82 | - | ||
| 83 | - | ||
| 83 | + | ||
| 84 | + | ||
| 84 | 85 | public File getSettingsFolder() throws Exception { | |
| 85 | 86 | return new File(getLibraryFolder(), "Processing"); | |
| 86 | 87 | } | |
@@ -101,6 +102,15 @@ public File getDefaultSketchbookFolder() throws Exception { | |||
| 101 | 102 | } | |
| 102 | 103 | */ | |
| 103 | 104 | } | |
| 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 | + } | ||
| 104 | 114 | ||
| 105 | 115 | ||
| 106 | 116 | /* | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -21,15 +21,6 @@ public static enum REGISTRY_ROOT_KEY{CLASSES_ROOT, CURRENT_USER, LOCAL_MACHINE, | |||
| 21 | 21 | rootKeyMap.put(REGISTRY_ROOT_KEY.USERS, WINREG.HKEY_USERS); | |
| 22 | 22 | } | |
| 23 | 23 | ||
| 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 | - | ||
| 33 | 24 | /** | |
| 34 | 25 | * Gets one of the root keys. | |
| 35 | 26 | * | |
| Back | FazBrowse Home | New Git URL |
0 commit comments