From 17106ea5c72511f5871178c7f1def629c20191ac Mon Sep 17 00:00:00 2001 From: ebr11 Eric Reed spam Date: Mon, 17 Sep 2012 11:12:43 -0400 Subject: Initial commit changing to on-demand child loading and validations --- .../Resolvers/EntityResolutionHelper.cs | 68 ++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 MediaBrowser.Controller/Resolvers/EntityResolutionHelper.cs (limited to 'MediaBrowser.Controller/Resolvers/EntityResolutionHelper.cs') diff --git a/MediaBrowser.Controller/Resolvers/EntityResolutionHelper.cs b/MediaBrowser.Controller/Resolvers/EntityResolutionHelper.cs new file mode 100644 index 000000000..76541e0ef --- /dev/null +++ b/MediaBrowser.Controller/Resolvers/EntityResolutionHelper.cs @@ -0,0 +1,68 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.IO; +using MediaBrowser.Controller.IO; +using MediaBrowser.Controller.Library; +using MediaBrowser.Controller.Entities.TV; + +namespace MediaBrowser.Controller.Resolvers +{ + public static class EntityResolutionHelper + { + /// + /// Any folder named in this list will be ignored - can be added to at runtime for extensibility + /// + public static List IgnoreFolders = new List() + { + "trailers", + "metadata", + "bdmv", + "certificate", + "backup", + "video_ts", + "audio_ts", + "ps3_update", + "ps3_vprm" + }; + /// + /// Determines whether a path should be resolved or ignored entirely - called before we even look at the contents + /// + /// + /// false if the path should be ignored + public static bool ShouldResolvePath(WIN32_FIND_DATA path) + { + bool resolve = true; + // Ignore hidden files and folders + if (path.IsHidden || path.IsSystemFile) + { + resolve = false; + } + + // Ignore any folders in our list + else if (path.IsDirectory && IgnoreFolders.Contains(Path.GetFileName(path.Path), StringComparer.OrdinalIgnoreCase)) + { + resolve = false; + } + + return resolve; + } + + /// + /// Determines whether a path should be ignored based on its contents - called after the contents have been read + /// + public static bool ShouldResolvePathContents(ItemResolveEventArgs args) + { + bool resolve = true; + if (args.ContainsFile(".ignore")) + { + // Ignore any folders containing a file called .ignore + resolve = false; + } + + return resolve; + } + } +} -- cgit v1.2.3