Added FolderChildrenTests and FolderTests

* implemented some testcases
* fixed some issues
This commit is contained in:
Markus Kreusch
2016-01-15 19:13:46 +01:00
parent 18cf25738e
commit 20e7f4a548
16 changed files with 386 additions and 64 deletions
@@ -0,0 +1,15 @@
package org.cryptomator.filesystem;
public class Deleter {
/**
* Deletes all and only the content of a given {@link Folder} but <b>not</b> the folder itself.
*/
public static void deleteContent(Folder folder) {
if (folder.exists()) {
folder.folders().forEach(Folder::delete);
folder.files().forEach(File::delete);
}
}
}
@@ -75,4 +75,10 @@ public interface File extends Node, Comparable<File> {
Mover.move(this, destination);
}
default void delete() {
try (WritableFile writableFile = openWritable()) {
writableFile.delete();
}
}
}
@@ -31,7 +31,7 @@ public interface Folder extends Node {
* @return the created {@code Stream}
* @throws UncheckedIOException
* if an {@link IOException} occurs while initializing the
* stream
* stream or the {@code Folder} does not exist
*/
Stream<? extends Node> children() throws UncheckedIOException;