mirror of
https://github.com/mitb-archive/filebot
synced 2025-01-11 05:48:01 -05:00
Fix listFiles and formatSize issues
This commit is contained in:
parent
cb4eea27fd
commit
823feacae0
@ -457,7 +457,11 @@ public abstract class ScriptShellBaseClass extends Script {
|
||||
|
||||
Object folder = parameters.get("folder");
|
||||
if (folder != null) {
|
||||
return listFiles(asFileList(folder), 0, FILES, HUMAN_NAME_ORDER);
|
||||
List<File> files = new ArrayList<File>();
|
||||
for (File f : asFileList(folder)) {
|
||||
files.addAll(getChildren(f, FILES, HUMAN_NAME_ORDER));
|
||||
}
|
||||
return files;
|
||||
}
|
||||
|
||||
return emptyList();
|
||||
|
@ -131,7 +131,7 @@ public class ScriptShellMethods {
|
||||
}
|
||||
|
||||
public static List<File> listTree(File self, int maxDepth) {
|
||||
return FileUtilities.listFiles(singleton(self), maxDepth, FILES, HUMAN_NAME_ORDER);
|
||||
return FileUtilities.listFiles(new File[] { self }, maxDepth, FILES, HUMAN_NAME_ORDER);
|
||||
}
|
||||
|
||||
public static List<File> getFiles(File self) {
|
||||
@ -172,7 +172,7 @@ public class ScriptShellMethods {
|
||||
public static List<File> getFolders(Collection<?> self, Closure<?> closure) {
|
||||
List<File> roots = FileUtilities.asFileList(self.toArray());
|
||||
|
||||
List<File> folders = FileUtilities.listFolders(roots, HUMAN_NAME_ORDER);
|
||||
List<File> folders = FileUtilities.listFiles(roots, FOLDERS, HUMAN_NAME_ORDER);
|
||||
if (closure != null) {
|
||||
folders = DefaultGroovyMethods.findAll(folders, closure);
|
||||
}
|
||||
|
@ -459,33 +459,25 @@ public final class FileUtilities {
|
||||
public static final int FILE_WALK_MAX_DEPTH = 32;
|
||||
|
||||
public static List<File> listFiles(File folder, FileFilter filter) {
|
||||
return listFiles(singleton(folder), FILE_WALK_MAX_DEPTH, filter, null);
|
||||
return listFiles(new File[] { folder }, FILE_WALK_MAX_DEPTH, filter, null);
|
||||
}
|
||||
|
||||
public static List<File> listFiles(File folder, FileFilter filter, Comparator<File> order) {
|
||||
return listFiles(singleton(folder), FILE_WALK_MAX_DEPTH, filter, order);
|
||||
return listFiles(new File[] { folder }, FILE_WALK_MAX_DEPTH, filter, order);
|
||||
}
|
||||
|
||||
public static List<File> listFiles(Iterable<File> folders, FileFilter filter, Comparator<File> order) {
|
||||
return listFiles(folders, FILE_WALK_MAX_DEPTH, filter, order);
|
||||
public static List<File> listFiles(Collection<File> folders, FileFilter filter, Comparator<File> order) {
|
||||
return listFiles(folders.toArray(new File[0]), FILE_WALK_MAX_DEPTH, filter, order);
|
||||
}
|
||||
|
||||
public static List<File> listFolders(Iterable<File> folders, Comparator<File> order) {
|
||||
return listFiles(folders, FILE_WALK_MAX_DEPTH, FOLDERS, order);
|
||||
}
|
||||
|
||||
public static List<File> listFiles(Iterable<File> folders, int depth, FileFilter filter, Comparator<File> order) {
|
||||
public static List<File> listFiles(File[] files, int depth, FileFilter filter, Comparator<File> order) {
|
||||
List<File> sink = new ArrayList<File>();
|
||||
|
||||
for (File f : folders) {
|
||||
if (f.isDirectory()) {
|
||||
listFiles(f, sink, depth, filter, order);
|
||||
}
|
||||
// traverse file tree recursively
|
||||
streamFiles(files, FOLDERS, order).forEach(f -> listFiles(f, sink, depth, filter, order));
|
||||
|
||||
if (filter.accept(f)) {
|
||||
sink.add(f);
|
||||
}
|
||||
}
|
||||
// add selected files in preferred order
|
||||
streamFiles(files, filter, order).forEach(sink::add);
|
||||
|
||||
return sink;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user