|
@@ -6,12 +6,14 @@
|
|
|
*/
|
|
*/
|
|
|
package net.ranides.assira.io;
|
|
package net.ranides.assira.io;
|
|
|
|
|
|
|
|
|
|
+import net.ranides.assira.collection.query.CQuery;
|
|
|
|
|
+
|
|
|
import java.io.File;
|
|
import java.io.File;
|
|
|
|
|
+import java.io.IOException;
|
|
|
import java.net.URISyntaxException;
|
|
import java.net.URISyntaxException;
|
|
|
import java.net.URL;
|
|
import java.net.URL;
|
|
|
-import java.nio.file.Path;
|
|
|
|
|
-import java.nio.file.Paths;
|
|
|
|
|
-import java.util.Locale;
|
|
|
|
|
|
|
+import java.nio.file.*;
|
|
|
|
|
+import java.util.*;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
*
|
|
*
|
|
@@ -100,4 +102,20 @@ public final class PathUtils {
|
|
|
public static String normalize(String path) {
|
|
public static String normalize(String path) {
|
|
|
return Paths.get(Paths.get(path).toUri().normalize()).toString();
|
|
return Paths.get(Paths.get(path).toUri().normalize()).toString();
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ public static CQuery<Path> list(Path dir) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ return CQuery.from().stream(() -> Files.list(dir));
|
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
|
+ return CQuery.empty();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public static CQuery<Path> walk(Path dir) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ return CQuery.from().stream(() -> Files.walk(dir, FileVisitOption.FOLLOW_LINKS));
|
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
|
+ return CQuery.empty();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|