From 2a039350e4666c387b41b7e608004cc8bdb7770d Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Tue, 5 Apr 2016 18:05:44 +0000 Subject: [PATCH] Added SystemFilesFilter --- source/net/filebot/media/MediaDetection.java | 4 ++++ source/net/filebot/media/ReleaseInfo.java | 9 +++++++++ source/net/filebot/media/ReleaseInfo.properties | 3 +++ source/net/filebot/util/FileUtilities.java | 2 +- 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/source/net/filebot/media/MediaDetection.java b/source/net/filebot/media/MediaDetection.java index 71e32812..4fbdd903 100644 --- a/source/net/filebot/media/MediaDetection.java +++ b/source/net/filebot/media/MediaDetection.java @@ -72,6 +72,10 @@ public class MediaDetection { public static final ReleaseInfo releaseInfo = new ReleaseInfo(); + public static FileFilter getSystemFilesFilter() { + return releaseInfo.getSystemFilesFilter(); + } + public static FileFilter getDiskFolderFilter() { return releaseInfo.getDiskFolderFilter(); } diff --git a/source/net/filebot/media/ReleaseInfo.java b/source/net/filebot/media/ReleaseInfo.java index a7c2b38b..c04bd8c4 100644 --- a/source/net/filebot/media/ReleaseInfo.java +++ b/source/net/filebot/media/ReleaseInfo.java @@ -400,6 +400,15 @@ public class ReleaseInfo { return clutterFileFilter; } + private static RegexFileFilter systemFilesFilter; + + public FileFilter getSystemFilesFilter() { + if (systemFilesFilter == null) { + systemFilesFilter = new RegexFileFilter(compile(getProperty("pattern.system.files"), CASE_INSENSITIVE)); + } + return systemFilesFilter; + } + public List getMediaRoots() { String roots = getProperty("folder.media.roots"); return COMMA.splitAsStream(roots).map(File::new).collect(toList()); diff --git a/source/net/filebot/media/ReleaseInfo.properties b/source/net/filebot/media/ReleaseInfo.properties index bb8658e8..83dd8caf 100644 --- a/source/net/filebot/media/ReleaseInfo.properties +++ b/source/net/filebot/media/ReleaseInfo.properties @@ -45,3 +45,6 @@ pattern.diskfolder.entry: BDMV|HVDVD_TS|VIDEO_TS|AUDIO_TS|VCD|MovieObject.bdmv|V # media root folders folder.media.roots: /Volumes:/Users:/home:/mnt:/media + +# system file pattern +pattern.system.files: [.@].+|bin|initrd|opt|sbin|var|dev|lib|proc|sys|var.defaults|etc|lost.found|root|tmp|etc.defaults|mnt|run|usr|System.Volume.Information diff --git a/source/net/filebot/util/FileUtilities.java b/source/net/filebot/util/FileUtilities.java index e10f6519..8edf551a 100644 --- a/source/net/filebot/util/FileUtilities.java +++ b/source/net/filebot/util/FileUtilities.java @@ -764,7 +764,7 @@ public final class FileUtilities { @Override public boolean accept(File dir, String name) { - return pattern.matcher(name).find(); + return pattern.matcher(name).matches(); } @Override