From a4346a90701f3041d264edd428de000e3c8ff95a Mon Sep 17 00:00:00 2001 From: Runemoro Date: Tue, 25 Jun 2019 08:37:35 -0400 Subject: Add compose, convert, and invert commands (#152) * Add compose and invert commands and add support for conversion to tiny mappings * Improvements suggested by liach * Use Translator to get right entries --- src/main/java/cuchaz/enigma/utils/Utils.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'src/main/java/cuchaz/enigma/utils/Utils.java') diff --git a/src/main/java/cuchaz/enigma/utils/Utils.java b/src/main/java/cuchaz/enigma/utils/Utils.java index bd09c64..6788042 100644 --- a/src/main/java/cuchaz/enigma/utils/Utils.java +++ b/src/main/java/cuchaz/enigma/utils/Utils.java @@ -21,8 +21,11 @@ import java.io.InputStream; import java.io.InputStreamReader; import java.net.URI; import java.net.URISyntaxException; -import java.util.Arrays; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.Comparator; import java.util.List; +import java.util.stream.Collectors; public class Utils { @@ -94,4 +97,12 @@ public class Utils { String value = System.getProperty(property); return value == null ? defValue : Boolean.parseBoolean(value); } + + public static void delete(Path path) throws IOException { + if (path.toFile().exists()) { + for (Path p : Files.walk(path).sorted(Comparator.reverseOrder()).collect(Collectors.toList())) { + Files.delete(p); + } + } + } } -- cgit v1.2.3