jellyfin/MediaBrowser.Controller/Library/ItemResolveEventArgs.cs

126 lines
3.2 KiB
C#
Raw Normal View History

2012-07-12 06:55:27 +00:00
using System;
using System.IO;
using MediaBrowser.Controller.IO;
using MediaBrowser.Model.Entities;
2012-07-12 06:55:27 +00:00
namespace MediaBrowser.Controller.Library
2012-07-12 06:55:27 +00:00
{
/// <summary>
/// This is an EventArgs object used when resolving a Path into a BaseItem
/// </summary>
2012-07-12 06:55:27 +00:00
public class ItemResolveEventArgs : PreBeginResolveEventArgs
{
public WIN32_FIND_DATA[] FileSystemChildren { get; set; }
2012-07-12 06:55:27 +00:00
public WIN32_FIND_DATA? GetFileSystemEntry(string path)
2012-07-12 06:55:27 +00:00
{
for (int i = 0; i < FileSystemChildren.Length; i++)
2012-07-12 06:55:27 +00:00
{
WIN32_FIND_DATA entry = FileSystemChildren[i];
if (entry.Path.Equals(path, StringComparison.OrdinalIgnoreCase))
2012-07-12 06:55:27 +00:00
{
return entry;
}
}
2012-07-12 06:55:27 +00:00
return null;
}
public bool ContainsFile(string name)
2012-07-12 06:55:27 +00:00
{
for (int i = 0; i < FileSystemChildren.Length; i++)
2012-07-12 06:55:27 +00:00
{
if (System.IO.Path.GetFileName(FileSystemChildren[i].Path).Equals(name, StringComparison.OrdinalIgnoreCase))
2012-07-12 06:55:27 +00:00
{
return true;
2012-07-12 06:55:27 +00:00
}
}
return false;
2012-07-12 06:55:27 +00:00
}
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;
2012-07-12 06:55:27 +00:00
}
}
/// <summary>
/// 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
/// </summary>
2012-07-12 06:55:27 +00:00
public class PreBeginResolveEventArgs : EventArgs
{
public Folder Parent { get; set; }
2012-07-12 06:55:27 +00:00
public bool Cancel { get; set; }
public WIN32_FIND_DATA FileInfo { get; set; }
2012-07-12 06:55:27 +00:00
public string Path { get; set; }
2012-07-12 06:55:27 +00:00
2012-08-21 14:42:40 +00:00
public bool IsDirectory
2012-07-12 06:55:27 +00:00
{
get
{
return FileInfo.dwFileAttributes.HasFlag(FileAttributes.Directory);
2012-07-12 06:55:27 +00:00
}
}
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;
}
}
2012-07-12 06:55:27 +00:00
}
}