aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations/IO/ManagedFileSystem.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Emby.Server.Implementations/IO/ManagedFileSystem.cs')
-rw-r--r--Emby.Server.Implementations/IO/ManagedFileSystem.cs50
1 files changed, 22 insertions, 28 deletions
diff --git a/Emby.Server.Implementations/IO/ManagedFileSystem.cs b/Emby.Server.Implementations/IO/ManagedFileSystem.cs
index 0f85e0642..5a5523a56 100644
--- a/Emby.Server.Implementations/IO/ManagedFileSystem.cs
+++ b/Emby.Server.Implementations/IO/ManagedFileSystem.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
@@ -85,17 +85,11 @@ namespace Emby.Server.Implementations.IO
{
// Be consistent across platforms because the windows server will fail to query network shares that don't follow windows conventions
// https://referencesource.microsoft.com/#mscorlib/system/io/path.cs
- _invalidFileNameChars = new char[] { '\"', '<', '>', '|', '\0', (Char)1, (Char)2, (Char)3, (Char)4, (Char)5, (Char)6, (Char)7, (Char)8, (Char)9, (Char)10, (Char)11, (Char)12, (Char)13, (Char)14, (Char)15, (Char)16, (Char)17, (Char)18, (Char)19, (Char)20, (Char)21, (Char)22, (Char)23, (Char)24, (Char)25, (Char)26, (Char)27, (Char)28, (Char)29, (Char)30, (Char)31, ':', '*', '?', '\\', '/' };
+ _invalidFileNameChars = new char[] { '\"', '<', '>', '|', '\0', (char)1, (char)2, (char)3, (char)4, (char)5, (char)6, (char)7, (char)8, (char)9, (char)10, (char)11, (char)12, (char)13, (char)14, (char)15, (char)16, (char)17, (char)18, (char)19, (char)20, (char)21, (char)22, (char)23, (char)24, (char)25, (char)26, (char)27, (char)28, (char)29, (char)30, (char)31, ':', '*', '?', '\\', '/' };
}
}
- public char DirectorySeparatorChar
- {
- get
- {
- return Path.DirectorySeparatorChar;
- }
- }
+ public char DirectorySeparatorChar => Path.DirectorySeparatorChar;
public string GetFullPath(string path)
{
@@ -112,7 +106,7 @@ namespace Emby.Server.Implementations.IO
{
if (string.IsNullOrEmpty(filename))
{
- throw new ArgumentNullException("filename");
+ throw new ArgumentNullException(nameof(filename));
}
var extension = Path.GetExtension(filename);
@@ -129,7 +123,7 @@ namespace Emby.Server.Implementations.IO
{
if (string.IsNullOrEmpty(filename))
{
- throw new ArgumentNullException("filename");
+ throw new ArgumentNullException(nameof(filename));
}
var extension = Path.GetExtension(filename);
@@ -145,7 +139,7 @@ namespace Emby.Server.Implementations.IO
public string MakeAbsolutePath(string folderPath, string filePath)
{
- if (String.IsNullOrWhiteSpace(filePath)) return filePath;
+ if (string.IsNullOrWhiteSpace(filePath)) return filePath;
if (filePath.Contains(@"://")) return filePath; //stream
if (filePath.Length > 3 && filePath[1] == ':' && filePath[2] == '/') return filePath; //absolute local path
@@ -200,12 +194,12 @@ namespace Emby.Server.Implementations.IO
{
if (string.IsNullOrEmpty(shortcutPath))
{
- throw new ArgumentNullException("shortcutPath");
+ throw new ArgumentNullException(nameof(shortcutPath));
}
if (string.IsNullOrEmpty(target))
{
- throw new ArgumentNullException("target");
+ throw new ArgumentNullException(nameof(target));
}
var extension = Path.GetExtension(shortcutPath);
@@ -321,7 +315,7 @@ namespace Emby.Server.Implementations.IO
return result;
}
- private ExtendedFileSystemInfo GetExtendedFileSystemInfo(string path)
+ private static ExtendedFileSystemInfo GetExtendedFileSystemInfo(string path)
{
var result = new ExtendedFileSystemInfo();
@@ -456,13 +450,13 @@ namespace Emby.Server.Implementations.IO
return new FileStream(path, GetFileMode(mode), GetFileAccess(access), GetFileShare(share), defaultBufferSize, GetFileOptions(fileOpenOptions));
}
- private FileOptions GetFileOptions(FileOpenOptions mode)
+ private static FileOptions GetFileOptions(FileOpenOptions mode)
{
var val = (int)mode;
return (FileOptions)val;
}
- private FileMode GetFileMode(FileOpenMode mode)
+ private static FileMode GetFileMode(FileOpenMode mode)
{
switch (mode)
{
@@ -483,7 +477,7 @@ namespace Emby.Server.Implementations.IO
}
}
- private FileAccess GetFileAccess(FileAccessMode mode)
+ private static FileAccess GetFileAccess(FileAccessMode mode)
{
switch (mode)
{
@@ -498,7 +492,7 @@ namespace Emby.Server.Implementations.IO
}
}
- private FileShare GetFileShare(FileShareMode mode)
+ private static FileShare GetFileShare(FileShareMode mode)
{
switch (mode)
{
@@ -619,12 +613,12 @@ namespace Emby.Server.Implementations.IO
{
if (string.IsNullOrEmpty(file1))
{
- throw new ArgumentNullException("file1");
+ throw new ArgumentNullException(nameof(file1));
}
if (string.IsNullOrEmpty(file2))
{
- throw new ArgumentNullException("file2");
+ throw new ArgumentNullException(nameof(file2));
}
var temp1 = Path.Combine(_tempPath, Guid.NewGuid().ToString("N"));
@@ -640,7 +634,7 @@ namespace Emby.Server.Implementations.IO
CopyFile(temp1, file2, true);
}
- private char GetDirectorySeparatorChar(string path)
+ private static char GetDirectorySeparatorChar(string path)
{
return Path.DirectorySeparatorChar;
}
@@ -649,12 +643,12 @@ namespace Emby.Server.Implementations.IO
{
if (string.IsNullOrEmpty(parentPath))
{
- throw new ArgumentNullException("parentPath");
+ throw new ArgumentNullException(nameof(parentPath));
}
if (string.IsNullOrEmpty(path))
{
- throw new ArgumentNullException("path");
+ throw new ArgumentNullException(nameof(path));
}
var separatorChar = GetDirectorySeparatorChar(parentPath);
@@ -666,7 +660,7 @@ namespace Emby.Server.Implementations.IO
{
if (string.IsNullOrEmpty(path))
{
- throw new ArgumentNullException("path");
+ throw new ArgumentNullException(nameof(path));
}
var parent = GetDirectoryName(path);
@@ -688,7 +682,7 @@ namespace Emby.Server.Implementations.IO
{
if (string.IsNullOrEmpty(path))
{
- throw new ArgumentNullException("path");
+ throw new ArgumentNullException(nameof(path));
}
if (path.EndsWith(":\\", StringComparison.OrdinalIgnoreCase))
@@ -772,7 +766,7 @@ namespace Emby.Server.Implementations.IO
}).ToList();
}
- private string GetName(DriveInfo drive)
+ private static string GetName(DriveInfo drive)
{
return drive.Name;
}
@@ -972,7 +966,7 @@ namespace Emby.Server.Implementations.IO
}
}
- private void RunProcess(string path, string args, string workingDirectory)
+ private static void RunProcess(string path, string args, string workingDirectory)
{
using (var process = Process.Start(new ProcessStartInfo
{