| | |
| | | result.put("parent", cur.getParent() == null ? "" : cur.getParent()); |
| | | List<Map<String, Object>> dirs = new ArrayList<>(); |
| | | File[] subs = cur.listFiles(File::isDirectory); |
| | | int dirTotal = 0; |
| | | if (subs != null) { |
| | | Arrays.sort(subs, Comparator.comparing(File::getName)); |
| | | for (File d : subs) { |
| | | if (d.isHidden()) continue; |
| | | dirTotal++; |
| | | if (dirs.size() >= 300) continue; |
| | | Map<String, Object> m = new LinkedHashMap<>(); |
| | | m.put("name", d.getName()); |
| | | m.put("path", d.getAbsolutePath()); |
| | |
| | | } |
| | | } |
| | | result.put("dirs", dirs); |
| | | result.put("dirsTruncated", dirTotal > dirs.size()); |
| | | List<String> excelFiles = new ArrayList<>(); |
| | | File[] files = cur.listFiles((d, n) -> { |
| | | String lower = n.toLowerCase(); |
| | | return lower.endsWith(".xlsx") || lower.endsWith(".xls"); |
| | | }); |
| | | int excelTotal = files == null ? 0 : files.length; |
| | | if (files != null) { |
| | | Arrays.sort(files, Comparator.comparing(File::getName)); |
| | | for (File f : files) excelFiles.add(f.getName()); |
| | | int take = Math.min(files.length, 300); |
| | | for (int i = 0; i < take; i++) excelFiles.add(files[i].getName()); |
| | | } |
| | | result.put("excelCount", excelFiles.size()); |
| | | result.put("excelCount", excelTotal); |
| | | result.put("files", excelFiles); |
| | | result.put("filesTruncated", excelTotal > excelFiles.size()); |
| | | return result; |
| | | } |
| | | |