< 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: 34
Coverable lines: 34
Total lines: 129
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 9/14/2025 - 12:09:49 AM Line coverage: 0% (0/29) Branch coverage: 0% (0/2) Total lines: 12212/4/2025 - 12:11:49 AM Line coverage: 0% (0/34) Branch coverage: 0% (0/2) Total lines: 129 9/14/2025 - 12:09:49 AM Line coverage: 0% (0/29) Branch coverage: 0% (0/2) Total lines: 12212/4/2025 - 12:11:49 AM Line coverage: 0% (0/34) Branch coverage: 0% (0/2) Total lines: 129

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%
IsHidden(...)100%210%
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;
 2using System.IO;
 3using System.Linq;
 4using BDInfo.IO;
 5using MediaBrowser.Model.IO;
 6
 7namespace MediaBrowser.MediaEncoding.BdInfo;
 8
 9/// <summary>
 10/// Class BdInfoDirectoryInfo.
 11/// </summary>
 12public class BdInfoDirectoryInfo : IDirectoryInfo
 13{
 14    private readonly IFileSystem _fileSystem;
 15
 16    private readonly FileSystemMetadata _impl;
 17
 18    /// <summary>
 19    /// Initializes a new instance of the <see cref="BdInfoDirectoryInfo" /> class.
 20    /// </summary>
 21    /// <param name="fileSystem">The filesystem.</param>
 22    /// <param name="path">The path.</param>
 23    public BdInfoDirectoryInfo(IFileSystem fileSystem, string path)
 24    {
 025        _fileSystem = fileSystem;
 026        _impl = _fileSystem.GetDirectoryInfo(path);
 027    }
 28
 29    private BdInfoDirectoryInfo(IFileSystem fileSystem, FileSystemMetadata impl)
 30    {
 031        _fileSystem = fileSystem;
 032        _impl = impl;
 033    }
 34
 35    /// <summary>
 36    /// Gets the name.
 37    /// </summary>
 038    public string Name => _impl.Name;
 39
 40    /// <summary>
 41    /// Gets the full name.
 42    /// </summary>
 043    public string FullName => _impl.FullName;
 44
 45    /// <summary>
 46    /// Gets the parent directory information.
 47    /// </summary>
 48    public IDirectoryInfo? Parent
 49    {
 50        get
 51        {
 052            var parentFolder = Path.GetDirectoryName(_impl.FullName);
 053            if (parentFolder is not null)
 54            {
 055                return new BdInfoDirectoryInfo(_fileSystem, parentFolder);
 56            }
 57
 058            return null;
 59        }
 60    }
 61
 062    private static bool IsHidden(ReadOnlySpan<char> name) => name.StartsWith('.');
 63
 64    /// <summary>
 65    /// Gets the directories.
 66    /// </summary>
 67    /// <returns>An array with all directories.</returns>
 68    public IDirectoryInfo[] GetDirectories()
 69    {
 070        return _fileSystem.GetDirectories(_impl.FullName)
 071            .Where(d => !IsHidden(d.Name))
 072            .Select(x => new BdInfoDirectoryInfo(_fileSystem, x))
 073            .ToArray();
 74    }
 75
 76    /// <summary>
 77    /// Gets the files.
 78    /// </summary>
 79    /// <returns>All files of the directory.</returns>
 80    public IFileInfo[] GetFiles()
 81    {
 082        return _fileSystem.GetFiles(_impl.FullName)
 083            .Where(d => !IsHidden(d.Name))
 084            .Select(x => new BdInfoFileInfo(x))
 085            .ToArray();
 86    }
 87
 88    /// <summary>
 89    /// Gets the files matching a pattern.
 90    /// </summary>
 91    /// <param name="searchPattern">The search pattern.</param>
 92    /// <returns>All files of the directory matching the search pattern.</returns>
 93    public IFileInfo[] GetFiles(string searchPattern)
 94    {
 095        return _fileSystem.GetFiles(_impl.FullName, new[] { searchPattern }, false, false)
 096            .Where(d => !IsHidden(d.Name))
 097            .Select(x => new BdInfoFileInfo(x))
 098            .ToArray();
 99    }
 100
 101    /// <summary>
 102    /// Gets the files matching a pattern and search options.
 103    /// </summary>
 104    /// <param name="searchPattern">The search pattern.</param>
 105    /// <param name="searchOption">The search option.</param>
 106    /// <returns>All files of the directory matching the search pattern and options.</returns>
 107    public IFileInfo[] GetFiles(string searchPattern, SearchOption searchOption)
 108    {
 0109        return _fileSystem.GetFiles(
 0110                _impl.FullName,
 0111                new[] { searchPattern },
 0112                false,
 0113                searchOption == SearchOption.AllDirectories)
 0114            .Where(d => !IsHidden(d.Name))
 0115            .Select(x => new BdInfoFileInfo(x))
 0116            .ToArray();
 117    }
 118
 119    /// <summary>
 120    /// Gets the bdinfo of a file system path.
 121    /// </summary>
 122    /// <param name="fs">The file system.</param>
 123    /// <param name="path">The path.</param>
 124    /// <returns>The BD directory information of the path on the file system.</returns>
 125    public static IDirectoryInfo FromFileSystemPath(IFileSystem fs, string path)
 126    {
 0127        return new BdInfoDirectoryInfo(fs, path);
 128    }
 129}