aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Controller/Events
diff options
context:
space:
mode:
authorLukePulverenti Luke Pulverenti luke pulverenti <LukePulverenti Luke Pulverenti luke.pulverenti@gmail.com>2012-07-12 02:55:27 -0400
committerLukePulverenti Luke Pulverenti luke pulverenti <LukePulverenti Luke Pulverenti luke.pulverenti@gmail.com>2012-07-12 02:55:27 -0400
commitb50f78e5da6f3fdfc59e577ca61b88771da7d211 (patch)
tree644ba93dc04bb8837a19a9cd5c3dfa8c6d62a91d /MediaBrowser.Controller/Events
Initial check-in
Diffstat (limited to 'MediaBrowser.Controller/Events')
-rw-r--r--MediaBrowser.Controller/Events/ItemResolveEventArgs.cs94
1 files changed, 94 insertions, 0 deletions
diff --git a/MediaBrowser.Controller/Events/ItemResolveEventArgs.cs b/MediaBrowser.Controller/Events/ItemResolveEventArgs.cs
new file mode 100644
index 000000000..831eb29d4
--- /dev/null
+++ b/MediaBrowser.Controller/Events/ItemResolveEventArgs.cs
@@ -0,0 +1,94 @@
+using System;
+using System.Collections.Generic;
+using MediaBrowser.Model.Entities;
+using System.IO;
+using System.Linq;
+
+namespace MediaBrowser.Controller.Events
+{
+ public class ItemResolveEventArgs : PreBeginResolveEventArgs
+ {
+ public IEnumerable<KeyValuePair<string, FileAttributes>> FileSystemChildren { get; set; }
+
+ public KeyValuePair<string, FileAttributes>? GetFolderByName(string name)
+ {
+ foreach (KeyValuePair<string, FileAttributes> entry in FileSystemChildren)
+ {
+ if (!entry.Value.HasFlag(FileAttributes.Directory))
+ {
+ continue;
+ }
+
+ if (System.IO.Path.GetFileName(entry.Key).Equals(name, StringComparison.OrdinalIgnoreCase))
+ {
+ return entry;
+ }
+ }
+
+ return null;
+ }
+
+ public KeyValuePair<string, FileAttributes>? GetFileByName(string name)
+ {
+ foreach (KeyValuePair<string, FileAttributes> entry in FileSystemChildren)
+ {
+ if (entry.Value.HasFlag(FileAttributes.Directory))
+ {
+ continue;
+ }
+
+ if (System.IO.Path.GetFileName(entry.Key).Equals(name, StringComparison.OrdinalIgnoreCase))
+ {
+ return entry;
+ }
+ }
+
+ return null;
+ }
+
+ public bool ContainsFile(string name)
+ {
+ return GetFileByName(name) != null;
+ }
+
+ public bool ContainsFolder(string name)
+ {
+ return GetFolderByName(name) != null;
+ }
+ }
+
+ public class PreBeginResolveEventArgs : EventArgs
+ {
+ public string Path { get; set; }
+ public BaseItem Parent { get; set; }
+
+ public bool Cancel { get; set; }
+
+ public FileAttributes FileAttributes { get; set; }
+
+ public bool IsFolder
+ {
+ get
+ {
+ return FileAttributes.HasFlag(FileAttributes.Directory);
+ }
+ }
+
+ public bool IsHidden
+ {
+ get
+ {
+ return FileAttributes.HasFlag(FileAttributes.Hidden);
+ }
+ }
+
+ public bool IsSystemFile
+ {
+ get
+ {
+ return FileAttributes.HasFlag(FileAttributes.System);
+ }
+ }
+
+ }
+}