diff --git a/source/net/filebot/media/ReleaseInfo.java b/source/net/filebot/media/ReleaseInfo.java index e6f25e28..3ada9d1a 100644 --- a/source/net/filebot/media/ReleaseInfo.java +++ b/source/net/filebot/media/ReleaseInfo.java @@ -513,14 +513,7 @@ public class ReleaseInfo { @Override public boolean accept(File dir) { - if (dir.isDirectory()) { - for (File f : getChildren(dir)) { - if (entryPattern.matcher(f.getName()).matches()) { - return true; - } - } - } - return false; + return getChildren(dir, f -> entryPattern.matcher(f.getName()).matches()).size() > 0; } } diff --git a/source/net/filebot/util/FastFile.java b/source/net/filebot/util/FastFile.java index c5839ed3..e3fc51b5 100644 --- a/source/net/filebot/util/FastFile.java +++ b/source/net/filebot/util/FastFile.java @@ -1,6 +1,9 @@ package net.filebot.util; +import static java.util.Arrays.*; + import java.io.File; +import java.io.FileFilter; import java.io.IOException; public class FastFile extends File { @@ -12,6 +15,9 @@ public class FastFile extends File { private Boolean isFile; private Boolean isHidden; + private Long totalSpace; + private Long freeSpace; + private String[] list; private File[] listFiles; @@ -86,13 +92,12 @@ public class FastFile extends File { return listFiles; } - String[] names = list(); - File[] files = new File[names.length]; - for (int i = 0; i < names.length; i++) { - files[i] = new FastFile(this, names[i]); - } + return (listFiles = stream(list()).map(s -> new FastFile(this, s)).toArray(File[]::new)); + } - return (listFiles = files); + @Override + public File[] listFiles(FileFilter filter) { + return stream(listFiles()).filter(filter::accept).toArray(File[]::new); } @Override @@ -115,6 +120,21 @@ public class FastFile extends File { return false; } + @Override + public long getTotalSpace() { + return totalSpace != null ? totalSpace : (totalSpace = super.getTotalSpace()); + } + + @Override + public long getFreeSpace() { + return freeSpace != null ? freeSpace : (freeSpace = super.getFreeSpace()); + } + + @Override + public long getUsableSpace() { + return freeSpace != null ? freeSpace : (freeSpace = super.getFreeSpace()); + } + @Override public boolean createNewFile() throws IOException { throw new UnsupportedOperationException(); @@ -192,23 +212,6 @@ public class FastFile extends File { } - @Override - public long getTotalSpace() { - throw new UnsupportedOperationException(); - - } - - @Override - public long getFreeSpace() { - throw new UnsupportedOperationException(); - - } - - @Override - public long getUsableSpace() { - throw new UnsupportedOperationException(); - } - public static FastFile get(File f) { return f == null ? null : new FastFile(f); }