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)
| 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 { |
nothing calls this directly
no test coverage detected