You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
jellyfin/MediaBrowser.Controller/Library/ItemResolveEventArgs.cs

126 lines
3.2 KiB

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