2012-07-11 23:55:27 -07:00
|
|
|
|
using System;
|
|
|
|
|
using System.IO;
|
2012-08-20 16:53:32 -07:00
|
|
|
|
using MediaBrowser.Controller.IO;
|
2012-08-20 18:51:00 -07:00
|
|
|
|
using MediaBrowser.Model.Entities;
|
2012-07-11 23:55:27 -07:00
|
|
|
|
|
2012-08-23 13:51:10 -07:00
|
|
|
|
namespace MediaBrowser.Controller.Library
|
2012-07-11 23:55:27 -07:00
|
|
|
|
{
|
2012-07-19 19:22:44 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// This is an EventArgs object used when resolving a Path into a BaseItem
|
|
|
|
|
/// </summary>
|
2012-07-11 23:55:27 -07:00
|
|
|
|
public class ItemResolveEventArgs : PreBeginResolveEventArgs
|
|
|
|
|
{
|
2012-08-22 22:45:26 -07:00
|
|
|
|
public WIN32_FIND_DATA[] FileSystemChildren { get; set; }
|
2012-07-11 23:55:27 -07:00
|
|
|
|
|
2012-08-22 22:45:26 -07:00
|
|
|
|
public WIN32_FIND_DATA? GetFileSystemEntry(string path)
|
2012-07-11 23:55:27 -07:00
|
|
|
|
{
|
2012-08-20 18:51:00 -07:00
|
|
|
|
for (int i = 0; i < FileSystemChildren.Length; i++)
|
2012-07-11 23:55:27 -07:00
|
|
|
|
{
|
2012-08-22 22:45:26 -07:00
|
|
|
|
WIN32_FIND_DATA entry = FileSystemChildren[i];
|
2012-08-20 18:51:00 -07:00
|
|
|
|
|
2012-08-20 20:56:28 -07:00
|
|
|
|
if (entry.Path.Equals(path, StringComparison.OrdinalIgnoreCase))
|
2012-07-11 23:55:27 -07:00
|
|
|
|
{
|
|
|
|
|
return entry;
|
|
|
|
|
}
|
|
|
|
|
}
|
2012-08-22 22:45:26 -07:00
|
|
|
|
|
2012-07-11 23:55:27 -07:00
|
|
|
|
return null;
|
|
|
|
|
}
|
2012-08-20 20:56:28 -07:00
|
|
|
|
|
2012-08-22 22:45:26 -07:00
|
|
|
|
public bool ContainsFile(string name)
|
2012-07-11 23:55:27 -07:00
|
|
|
|
{
|
2012-08-20 18:51:00 -07:00
|
|
|
|
for (int i = 0; i < FileSystemChildren.Length; i++)
|
2012-07-11 23:55:27 -07:00
|
|
|
|
{
|
2012-08-27 05:18:59 -07:00
|
|
|
|
if (FileSystemChildren[i].cFileName.Equals(name, StringComparison.OrdinalIgnoreCase))
|
2012-07-11 23:55:27 -07:00
|
|
|
|
{
|
2012-08-22 22:45:26 -07:00
|
|
|
|
return true;
|
2012-07-11 23:55:27 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-08-22 22:45:26 -07:00
|
|
|
|
return false;
|
2012-07-11 23:55:27 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool ContainsFolder(string name)
|
|
|
|
|
{
|
2012-08-27 05:18:59 -07:00
|
|
|
|
return ContainsFile(name);
|
2012-07-11 23:55:27 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-07-19 19:22:44 -07: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-11 23:55:27 -07:00
|
|
|
|
public class PreBeginResolveEventArgs : EventArgs
|
|
|
|
|
{
|
2012-07-12 20:50:50 -07:00
|
|
|
|
public Folder Parent { get; set; }
|
2012-07-11 23:55:27 -07:00
|
|
|
|
|
|
|
|
|
public bool Cancel { get; set; }
|
|
|
|
|
|
2012-08-22 22:45:26 -07:00
|
|
|
|
public WIN32_FIND_DATA FileInfo { get; set; }
|
2012-07-11 23:55:27 -07:00
|
|
|
|
|
2012-08-22 22:45:26 -07:00
|
|
|
|
public string Path { get; set; }
|
2012-07-11 23:55:27 -07:00
|
|
|
|
|
2012-08-21 07:42:40 -07:00
|
|
|
|
public bool IsDirectory
|
2012-07-11 23:55:27 -07:00
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2012-08-22 22:45:26 -07:00
|
|
|
|
return FileInfo.dwFileAttributes.HasFlag(FileAttributes.Directory);
|
2012-07-11 23:55:27 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-08-22 22:45:26 -07:00
|
|
|
|
public bool IsHidden
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return FileInfo.IsHidden;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool IsSystemFile
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return FileInfo.IsSystemFile;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-07-11 23:55:27 -07:00
|
|
|
|
}
|
|
|
|
|
}
|