-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4b6f683
commit a1f1861
Showing
4 changed files
with
97 additions
and
1 deletion.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
app/carnival-core/src/main/groovy/carnival/core/util/FilesUtil.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package carnival.core.util | ||
|
||
|
||
|
||
import java.nio.file.Path | ||
import java.nio.file.Files | ||
import java.nio.file.SimpleFileVisitor | ||
import java.nio.file.FileVisitResult | ||
import java.nio.file.attribute.BasicFileAttributes | ||
|
||
|
||
|
||
class FilesUtil { | ||
|
||
static Path delete(Path start) { | ||
|
||
Files.walkFileTree(start, new SimpleFileVisitor<Path>() { | ||
@Override | ||
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) | ||
throws IOException | ||
{ | ||
Files.delete(file); | ||
return FileVisitResult.CONTINUE; | ||
} | ||
@Override | ||
public FileVisitResult postVisitDirectory(Path dir, IOException e) | ||
throws IOException | ||
{ | ||
if (e == null) { | ||
Files.delete(dir); | ||
return FileVisitResult.CONTINUE; | ||
} else { | ||
// directory iteration failed | ||
throw e; | ||
} | ||
} | ||
}); | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters