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

Method flatten

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

Flattens a single directory (moves its children to be its peers, then deletes the given directory. ``` before: root/ toFlatten/ child1 child2 flatten("root/toFlatten") after: root/ child1 child2 ```

(File dirToRemove)

Source from the content-addressed store, hash-verified

299 * ```
300 */
301 public static void flatten(File dirToRemove) throws IOException {
302 final File parent = dirToRemove.getParentFile();
303 // move each child directory to the parent
304 for (File child : FileMisc.list(dirToRemove)) {
305 boolean createDestDir = false;
306 if (child.isFile()) {
307 FileUtils.moveFileToDirectory(child, parent, createDestDir);
308 } else if (child.isDirectory()) {
309 FileUtils.moveDirectoryToDirectory(child, parent, createDestDir);
310 } else {
311 throw new IllegalArgumentException("Unknown filetype: " + child);
312 }
313 }
314 // remove the directory which we're flattening away
315 FileMisc.forceDelete(dirToRemove);
316 }
317
318 /** Concats the first files and writes them to the last file. */
319 public static void concat(Iterable<File> toMerge, File dst) throws IOException {

Callers

nothing calls this directly

Calls 2

listMethod · 0.95
forceDeleteMethod · 0.95

Tested by

no test coverage detected