Merge pull request #726 from EraYaN/remove-wrappers-for-system-io

Clean up IFileSystem wrappers around stdlib.
This commit is contained in:
Vasily
2019-01-29 16:50:01 +03:00
committed by GitHub
106 changed files with 388 additions and 587 deletions

View File

@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
@@ -228,7 +229,7 @@ namespace MediaBrowser.Controller.Entities
return Path;
}
return FileSystem.GetDirectoryName(Path);
return System.IO.Path.GetDirectoryName(Path);
}
}
@@ -2208,7 +2209,7 @@ namespace MediaBrowser.Controller.Entities
{
var allFiles = ImageInfos
.Where(i => i.IsLocalFile)
.Select(i => FileSystem.GetDirectoryName(i.Path))
.Select(i => System.IO.Path.GetDirectoryName(i.Path))
.Distinct(StringComparer.OrdinalIgnoreCase)
.SelectMany(i => directoryService.GetFilePaths(i))
.ToList();
@@ -2343,7 +2344,7 @@ namespace MediaBrowser.Controller.Entities
var newImagePaths = images.Select(i => i.FullName).ToList();
var deleted = existingImages
.Where(i => i.IsLocalFile && !newImagePaths.Contains(i.Path, StringComparer.OrdinalIgnoreCase) && !FileSystem.FileExists(i.Path))
.Where(i => i.IsLocalFile && !newImagePaths.Contains(i.Path, StringComparer.OrdinalIgnoreCase) && !File.Exists(i.Path))
.ToList();
if (deleted.Count > 0)
@@ -2396,7 +2397,7 @@ namespace MediaBrowser.Controller.Entities
var extensions = new List<string> { ".nfo", ".xml", ".srt", ".vtt", ".sub", ".idx", ".txt", ".edl", ".bif", ".smi", ".ttml" };
extensions.AddRange(SupportedImageExtensions);
return FileSystem.GetFiles(FileSystem.GetDirectoryName(Path), extensions.ToArray(), false, false)
return FileSystem.GetFiles(System.IO.Path.GetDirectoryName(Path), extensions.ToArray(), false, false)
.Where(i => System.IO.Path.GetFileNameWithoutExtension(i.FullName).StartsWith(filename, StringComparison.OrdinalIgnoreCase))
.ToList();
}
@@ -2508,7 +2509,7 @@ namespace MediaBrowser.Controller.Entities
if (string.IsNullOrEmpty(Name) && !string.IsNullOrEmpty(Path))
{
Name = FileSystem.GetFileNameWithoutExtension(Path);
Name = System.IO.Path.GetFileNameWithoutExtension(Path);
hasChanges = true;
}

View File

@@ -87,7 +87,7 @@ namespace MediaBrowser.Controller.Entities
return new[] {
new FileSystemMetadata
{
FullName = FileSystem.GetDirectoryName(Path),
FullName = System.IO.Path.GetDirectoryName(Path),
IsDirectory = true
}
};

View File

@@ -97,7 +97,7 @@ namespace MediaBrowser.Controller.Entities.TV
return series.Path;
}
return FileSystem.GetDirectoryName(Path);
return System.IO.Path.GetDirectoryName(Path);
}
}

View File

@@ -1,4 +1,5 @@
using System;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
using MediaBrowser.Controller.Library;
@@ -167,18 +168,18 @@ namespace MediaBrowser.Controller.Entities
var oldConfigurationDirectory = ConfigurationDirectoryPath;
// Exceptions will be thrown if these paths already exist
if (FileSystem.DirectoryExists(newConfigDirectory))
if (Directory.Exists(newConfigDirectory))
{
FileSystem.DeleteDirectory(newConfigDirectory, true);
Directory.Delete(newConfigDirectory, true);
}
if (FileSystem.DirectoryExists(oldConfigurationDirectory))
if (Directory.Exists(oldConfigurationDirectory))
{
FileSystem.MoveDirectory(oldConfigurationDirectory, newConfigDirectory);
Directory.Move(oldConfigurationDirectory, newConfigDirectory);
}
else
{
FileSystem.CreateDirectory(newConfigDirectory);
Directory.CreateDirectory(newConfigDirectory);
}
}

View File

@@ -345,7 +345,7 @@ namespace MediaBrowser.Controller.Entities
{
if (IsStacked)
{
return FileSystem.GetDirectoryName(Path);
return System.IO.Path.GetDirectoryName(Path);
}
if (!IsPlaceHolder)

View File

@@ -85,7 +85,7 @@ namespace MediaBrowser.Controller.Library
return false;
}
var parentDir = BaseItem.FileSystem.GetDirectoryName(Path) ?? string.Empty;
var parentDir = System.IO.Path.GetDirectoryName(Path) ?? string.Empty;
return parentDir.Length > _appPaths.RootFolderPath.Length
&& parentDir.StartsWith(_appPaths.RootFolderPath, StringComparison.OrdinalIgnoreCase);

View File

@@ -434,7 +434,7 @@ namespace MediaBrowser.Controller.MediaEncoding
if (string.Equals(Path.GetExtension(subtitlePath), ".sub", StringComparison.OrdinalIgnoreCase))
{
var idxFile = Path.ChangeExtension(subtitlePath, ".idx");
if (_fileSystem.FileExists(idxFile))
if (File.Exists(idxFile))
{
subtitlePath = idxFile;
}
@@ -542,7 +542,7 @@ namespace MediaBrowser.Controller.MediaEncoding
// var fallbackFontPath = Path.Combine(_appPaths.ProgramDataPath, "fonts", "DroidSansFallback.ttf");
// string fallbackFontParam = string.Empty;
// if (!_fileSystem.FileExists(fallbackFontPath))
// if (!File.Exists(fallbackFontPath))
// {
// _fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(fallbackFontPath));
// using (var stream = _assemblyInfo.GetManifestResourceStream(GetType(), GetType().Namespace + ".DroidSansFallback.ttf"))

View File

@@ -50,7 +50,7 @@ namespace MediaBrowser.Controller.Playlists
if (IsPlaylistFile(path))
{
return FileSystem.GetDirectoryName(path);
return System.IO.Path.GetDirectoryName(path);
}
return path;