ItemResolveEventArgs.cs 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. using MediaBrowser.Controller.Entities;
  2. using MediaBrowser.Controller.IO;
  3. using System;
  4. using System.IO;
  5. namespace MediaBrowser.Controller.Library
  6. {
  7. /// <summary>
  8. /// This is an EventArgs object used when resolving a Path into a BaseItem
  9. /// </summary>
  10. public class ItemResolveEventArgs : PreBeginResolveEventArgs
  11. {
  12. public WIN32_FIND_DATA[] FileSystemChildren { get; set; }
  13. public WIN32_FIND_DATA? GetFileSystemEntry(string path)
  14. {
  15. for (int i = 0; i < FileSystemChildren.Length; i++)
  16. {
  17. WIN32_FIND_DATA entry = FileSystemChildren[i];
  18. if (entry.Path.Equals(path, StringComparison.OrdinalIgnoreCase))
  19. {
  20. return entry;
  21. }
  22. }
  23. return null;
  24. }
  25. public bool ContainsFile(string name)
  26. {
  27. for (int i = 0; i < FileSystemChildren.Length; i++)
  28. {
  29. if (FileSystemChildren[i].cFileName.Equals(name, StringComparison.OrdinalIgnoreCase))
  30. {
  31. return true;
  32. }
  33. }
  34. return false;
  35. }
  36. public bool ContainsFolder(string name)
  37. {
  38. return ContainsFile(name);
  39. }
  40. }
  41. /// <summary>
  42. /// This is an EventArgs object used before we begin resolving a Path into a BaseItem
  43. /// File system children have not been collected yet, but consuming events will
  44. /// have a chance to cancel resolution based on the Path, Parent and FileAttributes
  45. /// </summary>
  46. public class PreBeginResolveEventArgs : EventArgs
  47. {
  48. public Folder Parent { get; set; }
  49. public bool Cancel { get; set; }
  50. public WIN32_FIND_DATA FileInfo { get; set; }
  51. public string Path { get; set; }
  52. public bool IsDirectory
  53. {
  54. get
  55. {
  56. return FileInfo.dwFileAttributes.HasFlag(FileAttributes.Directory);
  57. }
  58. }
  59. public bool IsHidden
  60. {
  61. get
  62. {
  63. return FileInfo.IsHidden;
  64. }
  65. }
  66. public bool IsSystemFile
  67. {
  68. get
  69. {
  70. return FileInfo.IsSystemFile;
  71. }
  72. }
  73. }
  74. }