2020-08-04 08:08:09 -07:00
|
|
|
#pragma warning disable CS1591
|
|
|
|
|
2019-10-13 02:21:20 -07:00
|
|
|
using System;
|
|
|
|
using System.Linq;
|
|
|
|
using BDInfo.IO;
|
|
|
|
using MediaBrowser.Model.IO;
|
|
|
|
|
|
|
|
namespace MediaBrowser.MediaEncoding.BdInfo
|
|
|
|
{
|
2020-08-04 08:08:09 -07:00
|
|
|
public class BdInfoDirectoryInfo : IDirectoryInfo
|
2019-10-13 02:21:20 -07:00
|
|
|
{
|
2021-05-20 13:10:19 -07:00
|
|
|
private readonly IFileSystem _fileSystem;
|
2019-10-13 02:21:20 -07:00
|
|
|
|
2021-05-20 13:10:19 -07:00
|
|
|
private readonly FileSystemMetadata _impl;
|
2020-01-08 09:52:50 -07:00
|
|
|
|
|
|
|
public BdInfoDirectoryInfo(IFileSystem fileSystem, string path)
|
|
|
|
{
|
|
|
|
_fileSystem = fileSystem;
|
|
|
|
_impl = _fileSystem.GetDirectoryInfo(path);
|
|
|
|
}
|
|
|
|
|
|
|
|
private BdInfoDirectoryInfo(IFileSystem fileSystem, FileSystemMetadata impl)
|
|
|
|
{
|
|
|
|
_fileSystem = fileSystem;
|
|
|
|
_impl = impl;
|
|
|
|
}
|
2019-10-13 02:21:20 -07:00
|
|
|
|
|
|
|
public string Name => _impl.Name;
|
|
|
|
|
|
|
|
public string FullName => _impl.FullName;
|
|
|
|
|
2021-05-20 13:10:19 -07:00
|
|
|
public IDirectoryInfo? Parent
|
2019-10-13 02:21:20 -07:00
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
|
|
|
var parentFolder = System.IO.Path.GetDirectoryName(_impl.FullName);
|
|
|
|
if (parentFolder != null)
|
|
|
|
{
|
|
|
|
return new BdInfoDirectoryInfo(_fileSystem, parentFolder);
|
|
|
|
}
|
2020-01-08 09:52:50 -07:00
|
|
|
|
2019-10-13 02:21:20 -07:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public IDirectoryInfo[] GetDirectories()
|
|
|
|
{
|
2020-08-04 08:08:09 -07:00
|
|
|
return Array.ConvertAll(
|
|
|
|
_fileSystem.GetDirectories(_impl.FullName).ToArray(),
|
2019-10-13 02:21:20 -07:00
|
|
|
x => new BdInfoDirectoryInfo(_fileSystem, x));
|
|
|
|
}
|
|
|
|
|
|
|
|
public IFileInfo[] GetFiles()
|
|
|
|
{
|
2020-08-04 08:08:09 -07:00
|
|
|
return Array.ConvertAll(
|
|
|
|
_fileSystem.GetFiles(_impl.FullName).ToArray(),
|
2020-01-08 09:52:50 -07:00
|
|
|
x => new BdInfoFileInfo(x));
|
2019-10-13 02:21:20 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
public IFileInfo[] GetFiles(string searchPattern)
|
|
|
|
{
|
2020-08-04 08:08:09 -07:00
|
|
|
return Array.ConvertAll(
|
|
|
|
_fileSystem.GetFiles(_impl.FullName, new[] { searchPattern }, false, false).ToArray(),
|
2020-01-08 09:52:50 -07:00
|
|
|
x => new BdInfoFileInfo(x));
|
2019-10-13 02:21:20 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
public IFileInfo[] GetFiles(string searchPattern, System.IO.SearchOption searchOption)
|
|
|
|
{
|
2020-08-04 08:08:09 -07:00
|
|
|
return Array.ConvertAll(
|
|
|
|
_fileSystem.GetFiles(
|
|
|
|
_impl.FullName,
|
|
|
|
new[] { searchPattern },
|
|
|
|
false,
|
2021-03-08 19:04:47 -07:00
|
|
|
(searchOption & System.IO.SearchOption.AllDirectories) == System.IO.SearchOption.AllDirectories).ToArray(),
|
2020-01-08 09:52:50 -07:00
|
|
|
x => new BdInfoFileInfo(x));
|
2019-10-13 02:21:20 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
public static IDirectoryInfo FromFileSystemPath(Model.IO.IFileSystem fs, string path)
|
|
|
|
{
|
|
|
|
return new BdInfoDirectoryInfo(fs, path);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|