< Summary - Jellyfin

Information
Class: MediaBrowser.MediaEncoding.BdInfo.BdInfoDirectoryInfo
Assembly: MediaBrowser.MediaEncoding
File(s): /srv/git/jellyfin/MediaBrowser.MediaEncoding/BdInfo/BdInfoDirectoryInfo.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 29
Coverable lines: 29
Total lines: 122
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 2
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%210%
.ctor(...)100%210%
get_Name()100%210%
get_FullName()100%210%
get_Parent()0%620%
GetDirectories()100%210%
GetFiles()100%210%
GetFiles(...)100%210%
GetFiles(...)100%210%
FromFileSystemPath(...)100%210%

File(s)

/srv/git/jellyfin/MediaBrowser.MediaEncoding/BdInfo/BdInfoDirectoryInfo.cs

#LineLine coverage
 1using System.IO;
 2using System.Linq;
 3using BDInfo.IO;
 4using MediaBrowser.Model.IO;
 5
 6namespace MediaBrowser.MediaEncoding.BdInfo;
 7
 8/// <summary>
 9/// Class BdInfoDirectoryInfo.
 10/// </summary>
 11public class BdInfoDirectoryInfo : IDirectoryInfo
 12{
 13    private readonly IFileSystem _fileSystem;
 14
 15    private readonly FileSystemMetadata _impl;
 16
 17    /// <summary>
 18    /// Initializes a new instance of the <see cref="BdInfoDirectoryInfo" /> class.
 19    /// </summary>
 20    /// <param name="fileSystem">The filesystem.</param>
 21    /// <param name="path">The path.</param>
 22    public BdInfoDirectoryInfo(IFileSystem fileSystem, string path)
 23    {
 024        _fileSystem = fileSystem;
 025        _impl = _fileSystem.GetDirectoryInfo(path);
 026    }
 27
 28    private BdInfoDirectoryInfo(IFileSystem fileSystem, FileSystemMetadata impl)
 29    {
 030        _fileSystem = fileSystem;
 031        _impl = impl;
 032    }
 33
 34    /// <summary>
 35    /// Gets the name.
 36    /// </summary>
 037    public string Name => _impl.Name;
 38
 39    /// <summary>
 40    /// Gets the full name.
 41    /// </summary>
 042    public string FullName => _impl.FullName;
 43
 44    /// <summary>
 45    /// Gets the parent directory information.
 46    /// </summary>
 47    public IDirectoryInfo? Parent
 48    {
 49        get
 50        {
 051            var parentFolder = Path.GetDirectoryName(_impl.FullName);
 052            if (parentFolder is not null)
 53            {
 054                return new BdInfoDirectoryInfo(_fileSystem, parentFolder);
 55            }
 56
 057            return null;
 58        }
 59    }
 60
 61    /// <summary>
 62    /// Gets the directories.
 63    /// </summary>
 64    /// <returns>An array with all directories.</returns>
 65    public IDirectoryInfo[] GetDirectories()
 66    {
 067        return _fileSystem.GetDirectories(_impl.FullName)
 068            .Select(x => new BdInfoDirectoryInfo(_fileSystem, x))
 069            .ToArray();
 70    }
 71
 72    /// <summary>
 73    /// Gets the files.
 74    /// </summary>
 75    /// <returns>All files of the directory.</returns>
 76    public IFileInfo[] GetFiles()
 77    {
 078        return _fileSystem.GetFiles(_impl.FullName)
 079            .Select(x => new BdInfoFileInfo(x))
 080            .ToArray();
 81    }
 82
 83    /// <summary>
 84    /// Gets the files matching a pattern.
 85    /// </summary>
 86    /// <param name="searchPattern">The search pattern.</param>
 87    /// <returns>All files of the directory matchign the search pattern.</returns>
 88    public IFileInfo[] GetFiles(string searchPattern)
 89    {
 090        return _fileSystem.GetFiles(_impl.FullName, new[] { searchPattern }, false, false)
 091            .Select(x => new BdInfoFileInfo(x))
 092            .ToArray();
 93    }
 94
 95    /// <summary>
 96    /// Gets the files matching a pattern and search options.
 97    /// </summary>
 98    /// <param name="searchPattern">The search pattern.</param>
 99    /// <param name="searchOption">The search optin.</param>
 100    /// <returns>All files of the directory matchign the search pattern and options.</returns>
 101    public IFileInfo[] GetFiles(string searchPattern, SearchOption searchOption)
 102    {
 0103        return _fileSystem.GetFiles(
 0104                _impl.FullName,
 0105                new[] { searchPattern },
 0106                false,
 0107                searchOption == SearchOption.AllDirectories)
 0108            .Select(x => new BdInfoFileInfo(x))
 0109            .ToArray();
 110    }
 111
 112    /// <summary>
 113    /// Gets the bdinfo of a file system path.
 114    /// </summary>
 115    /// <param name="fs">The file system.</param>
 116    /// <param name="path">The path.</param>
 117    /// <returns>The BD directory information of the path on the file system.</returns>
 118    public static IDirectoryInfo FromFileSystemPath(IFileSystem fs, string path)
 119    {
 0120        return new BdInfoDirectoryInfo(fs, path);
 121    }
 122}