|
@@ -213,7 +213,6 @@ public class FileExtractUtil {
|
|
|
|
|
|
if (Files.isDirectory(directory)) {
|
|
|
List<Map<String, Object>> children = new ArrayList<>();
|
|
|
-
|
|
|
try (DirectoryStream<Path> stream = Files.newDirectoryStream(directory)) {
|
|
|
for (Path entry : stream) {
|
|
|
if (Files.isDirectory(entry)) {
|
|
@@ -223,7 +222,10 @@ public class FileExtractUtil {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+ if(!children.isEmpty()){
|
|
|
+ // 按名称排序
|
|
|
+ children.sort(Comparator.comparing(m -> m.get("name").toString()));
|
|
|
+ }
|
|
|
structure.put("children", children);
|
|
|
} else {
|
|
|
// 如果是文件,添加文件大小
|
|
@@ -249,7 +251,7 @@ public class FileExtractUtil {
|
|
|
* @return 文件结构Map
|
|
|
*/
|
|
|
public static Map<String, Object> getFileStructure(Path file) {
|
|
|
- Map<String, Object> structure = new HashMap<>();
|
|
|
+ Map<String, Object> structure = new TreeMap<>(Comparator.comparing(String::toString));
|
|
|
structure.put("name", file.getFileName().toString());
|
|
|
structure.put("type", "file");
|
|
|
structure.put("path", file.toString());
|