From f218e6b5832ad2eec2c6391bf2f942ecd6a0330f Mon Sep 17 00:00:00 2001 From: LukePulverenti Luke Pulverenti luke pulverenti Date: Thu, 23 Aug 2012 16:51:10 -0400 Subject: More comments and cleanup. Added special feature provider for movies --- MediaBrowser.Controller/Library/ItemController.cs | 1 - .../Library/ItemResolveEventArgs.cs | 125 +++++++++++++++++++++ 2 files changed, 125 insertions(+), 1 deletion(-) create mode 100644 MediaBrowser.Controller/Library/ItemResolveEventArgs.cs (limited to 'MediaBrowser.Controller/Library') diff --git a/MediaBrowser.Controller/Library/ItemController.cs b/MediaBrowser.Controller/Library/ItemController.cs index df7cf8810..fdc2276d0 100644 --- a/MediaBrowser.Controller/Library/ItemController.cs +++ b/MediaBrowser.Controller/Library/ItemController.cs @@ -4,7 +4,6 @@ using System.Collections.Generic; using System.IO; using System.Linq; using System.Threading.Tasks; -using MediaBrowser.Controller.Events; using MediaBrowser.Controller.IO; using MediaBrowser.Model.Entities; diff --git a/MediaBrowser.Controller/Library/ItemResolveEventArgs.cs b/MediaBrowser.Controller/Library/ItemResolveEventArgs.cs new file mode 100644 index 000000000..0daca3b44 --- /dev/null +++ b/MediaBrowser.Controller/Library/ItemResolveEventArgs.cs @@ -0,0 +1,125 @@ +using System; +using System.IO; +using MediaBrowser.Controller.IO; +using MediaBrowser.Model.Entities; + +namespace MediaBrowser.Controller.Library +{ + /// + /// This is an EventArgs object used when resolving a Path into a BaseItem + /// + public class ItemResolveEventArgs : PreBeginResolveEventArgs + { + public WIN32_FIND_DATA[] FileSystemChildren { get; set; } + + public WIN32_FIND_DATA? GetFileSystemEntry(string path) + { + for (int i = 0; i < FileSystemChildren.Length; i++) + { + WIN32_FIND_DATA entry = FileSystemChildren[i]; + + if (entry.Path.Equals(path, StringComparison.OrdinalIgnoreCase)) + { + return entry; + } + } + + return null; + } + + public bool ContainsFile(string name) + { + for (int i = 0; i < FileSystemChildren.Length; i++) + { + if (System.IO.Path.GetFileName(FileSystemChildren[i].Path).Equals(name, StringComparison.OrdinalIgnoreCase)) + { + return true; + } + } + + return false; + } + + public bool ContainsFolder(string name) + { + for (int i = 0; i < FileSystemChildren.Length; i++) + { + if (System.IO.Path.GetFileName(FileSystemChildren[i].Path).Equals(name, StringComparison.OrdinalIgnoreCase)) + { + return true; + } + } + + return false; + } + } + + /// + /// This is an EventArgs object used before we begin resolving a Path into a BaseItem + /// File system children have not been collected yet, but consuming events will + /// have a chance to cancel resolution based on the Path, Parent and FileAttributes + /// + public class PreBeginResolveEventArgs : EventArgs + { + public Folder Parent { get; set; } + + public bool Cancel { get; set; } + + public WIN32_FIND_DATA FileInfo { get; set; } + + public string Path { get; set; } + + public bool IsDirectory + { + get + { + return FileInfo.dwFileAttributes.HasFlag(FileAttributes.Directory); + } + } + + public VirtualFolder VirtualFolder + { + get + { + if (Parent != null) + { + return Parent.VirtualFolder; + } + + return null; + } + } + + public string VirtualFolderCollectionType + { + get + { + VirtualFolder vf = VirtualFolder; + + if (vf == null) + { + return null; + } + + return vf.CollectionType; + } + } + + public bool IsHidden + { + get + { + return FileInfo.IsHidden; + } + } + + public bool IsSystemFile + { + get + { + return FileInfo.IsSystemFile; + } + } + + } +} -- cgit v1.2.3