2012-09-11 03:34:02 +02:00
|
|
|
|
using MediaBrowser.Controller.Entities;
|
2012-08-21 01:53:32 +02:00
|
|
|
|
using MediaBrowser.Controller.IO;
|
2012-09-17 17:12:43 +02:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
2012-09-11 03:34:02 +02:00
|
|
|
|
using System;
|
|
|
|
|
using System.IO;
|
2012-07-12 08:55:27 +02:00
|
|
|
|
|
2012-08-23 22:51:10 +02:00
|
|
|
|
namespace MediaBrowser.Controller.Library
|
2012-07-12 08:55:27 +02:00
|
|
|
|
{
|
2012-07-20 04:22:44 +02:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// This is an EventArgs object used when resolving a Path into a BaseItem
|
|
|
|
|
/// </summary>
|
2012-07-12 08:55:27 +02:00
|
|
|
|
public class ItemResolveEventArgs : PreBeginResolveEventArgs
|
|
|
|
|
{
|
2012-08-23 07:45:26 +02:00
|
|
|
|
public WIN32_FIND_DATA[] FileSystemChildren { get; set; }
|
2012-07-12 08:55:27 +02:00
|
|
|
|
|
2012-09-17 17:12:43 +02:00
|
|
|
|
protected List<string> _additionalLocations = new List<string>();
|
|
|
|
|
public List<string> AdditionalLocations
|
2012-07-12 08:55:27 +02:00
|
|
|
|
{
|
2012-09-17 17:12:43 +02:00
|
|
|
|
get
|
2012-07-12 08:55:27 +02:00
|
|
|
|
{
|
2012-09-17 17:12:43 +02:00
|
|
|
|
return _additionalLocations;
|
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
_additionalLocations = value;
|
2012-07-12 08:55:27 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
2012-08-21 05:56:28 +02:00
|
|
|
|
|
2012-09-17 17:12:43 +02:00
|
|
|
|
public IEnumerable<string> PhysicalLocations
|
2012-07-12 08:55:27 +02:00
|
|
|
|
{
|
2012-09-17 17:12:43 +02:00
|
|
|
|
get
|
2012-07-12 08:55:27 +02:00
|
|
|
|
{
|
2012-09-17 17:12:43 +02:00
|
|
|
|
return (new List<string>() {this.Path}).Concat(AdditionalLocations);
|
2012-07-12 08:55:27 +02:00
|
|
|
|
}
|
2012-09-17 17:12:43 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool IsBDFolder { get; set; }
|
|
|
|
|
public bool IsDVDFolder { get; set; }
|
2012-07-12 08:55:27 +02:00
|
|
|
|
|
2012-09-17 17:12:43 +02:00
|
|
|
|
public WIN32_FIND_DATA? GetFileSystemEntry(string path)
|
|
|
|
|
{
|
|
|
|
|
WIN32_FIND_DATA entry = FileSystemChildren.FirstOrDefault(f => f.Path.Equals(path, StringComparison.OrdinalIgnoreCase));
|
|
|
|
|
return entry.cFileName != null ? (WIN32_FIND_DATA?)entry : null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool ContainsFile(string name)
|
|
|
|
|
{
|
|
|
|
|
return FileSystemChildren.FirstOrDefault(f => f.cFileName.Equals(name, StringComparison.OrdinalIgnoreCase)).cFileName != null;
|
2012-07-12 08:55:27 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool ContainsFolder(string name)
|
|
|
|
|
{
|
2012-08-27 14:18:59 +02:00
|
|
|
|
return ContainsFile(name);
|
2012-07-12 08:55:27 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-07-20 04:22:44 +02: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 08:55:27 +02:00
|
|
|
|
public class PreBeginResolveEventArgs : EventArgs
|
|
|
|
|
{
|
2012-07-13 05:50:50 +02:00
|
|
|
|
public Folder Parent { get; set; }
|
2012-07-12 08:55:27 +02:00
|
|
|
|
|
|
|
|
|
public bool Cancel { get; set; }
|
|
|
|
|
|
2012-08-23 07:45:26 +02:00
|
|
|
|
public WIN32_FIND_DATA FileInfo { get; set; }
|
2012-07-12 08:55:27 +02:00
|
|
|
|
|
2012-08-23 07:45:26 +02:00
|
|
|
|
public string Path { get; set; }
|
2012-07-12 08:55:27 +02:00
|
|
|
|
|
2012-08-21 16:42:40 +02:00
|
|
|
|
public bool IsDirectory
|
2012-07-12 08:55:27 +02:00
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2012-08-23 07:45:26 +02:00
|
|
|
|
return FileInfo.dwFileAttributes.HasFlag(FileAttributes.Directory);
|
2012-07-12 08:55:27 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-08-23 07:45:26 +02:00
|
|
|
|
public bool IsHidden
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return FileInfo.IsHidden;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool IsSystemFile
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return FileInfo.IsSystemFile;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-07-12 08:55:27 +02:00
|
|
|
|
}
|
|
|
|
|
}
|