using System.Linq; using DotNet.Globbing; namespace Emby.Server.Implementations.Library { /// /// Glob patterns for files to ignore. /// public static class IgnorePatterns { /// /// Files matching these glob patterns will be ignored. /// private static readonly string[] _patterns = { "**/small.jpg", "**/albumart.jpg", "**/*sample*", // Directories "**/metadata/**", "**/metadata", "**/ps3_update/**", "**/ps3_update", "**/ps3_vprm/**", "**/ps3_vprm", "**/extrafanart/**", "**/extrafanart", "**/extrathumbs/**", "**/extrathumbs", "**/.actors/**", "**/.actors", "**/.wd_tv/**", "**/.wd_tv", "**/lost+found/**", "**/lost+found", // WMC temp recording directories that will constantly be written to "**/TempRec/**", "**/TempRec", "**/TempSBE/**", "**/TempSBE", // Synology "**/eaDir/**", "**/eaDir", "**/@eaDir/**", "**/@eaDir", "**/#recycle/**", "**/#recycle", // Qnap "**/@Recycle/**", "**/@Recycle", "**/.@__thumb/**", "**/.@__thumb", "**/$RECYCLE.BIN/**", "**/$RECYCLE.BIN", "**/System Volume Information/**", "**/System Volume Information", "**/.grab/**", "**/.grab", // Unix hidden files and directories "**/.*/**", "**/.*", // thumbs.db "**/thumbs.db", // bts sync files "**/*.bts", "**/*.sync", }; private static readonly GlobOptions _globOptions = new GlobOptions { Evaluation = { CaseInsensitive = true } }; private static readonly Glob[] _globs = _patterns.Select(p => Glob.Parse(p, _globOptions)).ToArray(); /// /// Returns true if the supplied path should be ignored. /// /// The path to test. /// Whether to ignore the path. public static bool ShouldIgnore(string path) { return _globs.Any(g => g.IsMatch(path)); } } }