MCPcopy Create free account
hub / github.com/diffplug/goomph / cleanDir

Method cleanDir

src/main/java/com/diffplug/gradle/FileMisc.java:266–281  ·  view source on GitHub ↗

Deletes the given file or directory if it exists, then creates a fresh directory in its place.

(File dirToRemove)

Source from the content-addressed store, hash-verified

264
265 /** Deletes the given file or directory if it exists, then creates a fresh directory in its place. */
266 public static void cleanDir(File dirToRemove) throws IOException {
267 if (dirToRemove.isFile()) {
268 FileMisc.forceDelete(dirToRemove);
269 } else if (dirToRemove.isDirectory()) {
270 try {
271 FileUtils.deleteDirectory(dirToRemove);
272 } catch (IOException e) {
273 // we couldn't delete the directory,
274 // but deleting everything inside is just as good
275 for (File file : FileMisc.list(dirToRemove)) {
276 FileMisc.forceDelete(file);
277 }
278 }
279 }
280 mkdirs(dirToRemove);
281 }
282
283 /**
284 * Flattens a single directory (moves its children to be its peers, then deletes the given directory.

Callers 12

mainMethod · 0.95
mainMethod · 0.95
mainMethod · 0.95
actionMethod · 0.95
buildMethod · 0.95
createMethod · 0.95
ideSetupP2Method · 0.95
ideSetupWorkspaceMethod · 0.95
copyFilesMethod · 0.95
runMethod · 0.95
installMethod · 0.95

Calls 3

forceDeleteMethod · 0.95
listMethod · 0.95
mkdirsMethod · 0.95

Tested by 3

mainMethod · 0.76
mainMethod · 0.76
mainMethod · 0.76