MCPcopy Index your code
hub / github.com/benfry/processing4 / deleteFile

Method deleteFile

app/src/processing/app/Platform.java:535–556  ·  view source on GitHub ↗

Delete a file or directory in a platform-specific manner. Removes a File object (a file or directory) from the system by placing it in the Trash or Recycle Bin (if available) or simply deleting it (if not). Also tries to find a suitable Trash location on Linux. When the file/folder is on another

(File file)

Source from the content-addressed store, hash-verified

533 * @throws IOException what went wrong
534 */
535 static public boolean deleteFile(File file) throws IOException {
536 try {
537 FileUtils fu = FileUtils.getInstance();
538 if (fu.hasTrash()) {
539 fu.moveToTrash(file);
540 return true;
541 }
542 } catch (Throwable t) {
543 // On macOS getting NoClassDefFoundError inside JNA on Big Sur.
544 // (Can't find com.sun.jna.platform.mac.MacFileUtils$FileManager)
545 // Just adding a catch-all here so that it does the fall-through below.
546 System.err.println(t.getMessage());
547 }
548
549 if (file.isDirectory()) {
550 Util.removeDir(file);
551 return true;
552
553 } else {
554 return file.delete();
555 }
556 }
557
558
559 // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Callers 11

prepareExportFolderMethod · 0.95
cleanTempFoldersMethod · 0.95
handleDeleteCodeMethod · 0.95
saveAsMethod · 0.95
cleanTempFilesMethod · 0.95
deleteTempMethod · 0.95
deleteFlaggedMethod · 0.95
updateFlaggedMethod · 0.95
installMethod · 0.95
copyAndLoadMethod · 0.95
removeContributionMethod · 0.95

Calls 5

removeDirMethod · 0.95
getMessageMethod · 0.65
getInstanceMethod · 0.45
printlnMethod · 0.45
deleteMethod · 0.45

Tested by

no test coverage detected