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