BdInfoFileInfo.cs 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. using System.IO;
  2. using MediaBrowser.Model.IO;
  3. namespace MediaBrowser.MediaEncoding.BdInfo;
  4. /// <summary>
  5. /// Class BdInfoFileInfo.
  6. /// </summary>
  7. public class BdInfoFileInfo : BDInfo.IO.IFileInfo
  8. {
  9. private readonly FileSystemMetadata _impl;
  10. /// <summary>
  11. /// Initializes a new instance of the <see cref="BdInfoFileInfo" /> class.
  12. /// </summary>
  13. /// <param name="impl">The <see cref="FileSystemMetadata" />.</param>
  14. public BdInfoFileInfo(FileSystemMetadata impl)
  15. {
  16. _impl = impl;
  17. }
  18. /// <summary>
  19. /// Gets the name.
  20. /// </summary>
  21. public string Name => _impl.Name;
  22. /// <summary>
  23. /// Gets the full name.
  24. /// </summary>
  25. public string FullName => _impl.FullName;
  26. /// <summary>
  27. /// Gets the extension.
  28. /// </summary>
  29. public string Extension => _impl.Extension;
  30. /// <summary>
  31. /// Gets the length.
  32. /// </summary>
  33. public long Length => _impl.Length;
  34. /// <summary>
  35. /// Gets a value indicating whether this is a directory.
  36. /// </summary>
  37. public bool IsDir => _impl.IsDirectory;
  38. /// <summary>
  39. /// Gets a file as file stream.
  40. /// </summary>
  41. /// <returns>A <see cref="FileStream" /> for the file.</returns>
  42. public Stream OpenRead()
  43. {
  44. return new FileStream(
  45. FullName,
  46. FileMode.Open,
  47. FileAccess.Read,
  48. FileShare.Read);
  49. }
  50. /// <summary>
  51. /// Gets a files's content with a stream reader.
  52. /// </summary>
  53. /// <returns>A <see cref="StreamReader" /> for the file's content.</returns>
  54. public StreamReader OpenText()
  55. {
  56. return new StreamReader(OpenRead());
  57. }
  58. }