aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations/IO
diff options
context:
space:
mode:
Diffstat (limited to 'Emby.Server.Implementations/IO')
-rw-r--r--Emby.Server.Implementations/IO/ExtendedFileSystemInfo.cs4
-rw-r--r--Emby.Server.Implementations/IO/FileRefresher.cs14
-rw-r--r--Emby.Server.Implementations/IO/IsoManager.cs8
-rw-r--r--Emby.Server.Implementations/IO/LibraryMonitor.cs27
-rw-r--r--Emby.Server.Implementations/IO/ManagedFileSystem.cs96
-rw-r--r--Emby.Server.Implementations/IO/MbLinkShortcutHandler.cs15
-rw-r--r--Emby.Server.Implementations/IO/StreamHelper.cs4
-rw-r--r--Emby.Server.Implementations/IO/ThrottledStream.cs65
8 files changed, 80 insertions, 153 deletions
diff --git a/Emby.Server.Implementations/IO/ExtendedFileSystemInfo.cs b/Emby.Server.Implementations/IO/ExtendedFileSystemInfo.cs
index 6b08c26c9..48b34a3a0 100644
--- a/Emby.Server.Implementations/IO/ExtendedFileSystemInfo.cs
+++ b/Emby.Server.Implementations/IO/ExtendedFileSystemInfo.cs
@@ -1,7 +1,3 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
namespace Emby.Server.Implementations.IO
{
public class ExtendedFileSystemInfo
diff --git a/Emby.Server.Implementations/IO/FileRefresher.cs b/Emby.Server.Implementations/IO/FileRefresher.cs
index 34c711324..6bee178ea 100644
--- a/Emby.Server.Implementations/IO/FileRefresher.cs
+++ b/Emby.Server.Implementations/IO/FileRefresher.cs
@@ -1,16 +1,16 @@
-using System;
+using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
-using MediaBrowser.Model.IO;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library;
using MediaBrowser.Model.Extensions;
-using Microsoft.Extensions.Logging;
+using MediaBrowser.Model.IO;
using MediaBrowser.Model.System;
using MediaBrowser.Model.Tasks;
using MediaBrowser.Model.Threading;
+using Microsoft.Extensions.Logging;
namespace Emby.Server.Implementations.IO
{
@@ -51,7 +51,7 @@ namespace Emby.Server.Implementations.IO
{
if (string.IsNullOrEmpty(path))
{
- throw new ArgumentNullException("path");
+ throw new ArgumentNullException(nameof(path));
}
if (!_affectedPaths.Contains(path, StringComparer.Ordinal))
@@ -64,7 +64,7 @@ namespace Emby.Server.Implementations.IO
{
if (string.IsNullOrEmpty(path))
{
- throw new ArgumentNullException("path");
+ throw new ArgumentNullException(nameof(path));
}
lock (_timerLock)
@@ -156,7 +156,7 @@ namespace Emby.Server.Implementations.IO
continue;
}
- Logger.LogInformation("{name} ({path}}) will be refreshed.", item.Name, item.Path);
+ Logger.LogInformation("{name} ({path}) will be refreshed.", item.Name, item.Path);
try
{
@@ -164,7 +164,7 @@ namespace Emby.Server.Implementations.IO
}
catch (IOException ex)
{
- // For now swallow and log.
+ // For now swallow and log.
// Research item: If an IOException occurs, the item may be in a disconnected state (media unavailable)
// Should we remove it from it's parent?
Logger.LogError(ex, "Error refreshing {name}", item.Name);
diff --git a/Emby.Server.Implementations/IO/IsoManager.cs b/Emby.Server.Implementations/IO/IsoManager.cs
index 903d5f301..f0a15097c 100644
--- a/Emby.Server.Implementations/IO/IsoManager.cs
+++ b/Emby.Server.Implementations/IO/IsoManager.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
@@ -23,13 +23,13 @@ namespace Emby.Server.Implementations.IO
/// <param name="isoPath">The iso path.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>IsoMount.</returns>
- /// <exception cref="System.ArgumentNullException">isoPath</exception>
- /// <exception cref="System.ArgumentException"></exception>
+ /// <exception cref="ArgumentNullException">isoPath</exception>
+ /// <exception cref="ArgumentException"></exception>
public Task<IIsoMount> Mount(string isoPath, CancellationToken cancellationToken)
{
if (string.IsNullOrEmpty(isoPath))
{
- throw new ArgumentNullException("isoPath");
+ throw new ArgumentNullException(nameof(isoPath));
}
var mounter = _mounters.FirstOrDefault(i => i.CanMount(isoPath));
diff --git a/Emby.Server.Implementations/IO/LibraryMonitor.cs b/Emby.Server.Implementations/IO/LibraryMonitor.cs
index ca5810fd6..6a3204011 100644
--- a/Emby.Server.Implementations/IO/LibraryMonitor.cs
+++ b/Emby.Server.Implementations/IO/LibraryMonitor.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.IO;
@@ -9,10 +9,10 @@ using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Plugins;
using MediaBrowser.Model.IO;
-using Microsoft.Extensions.Logging;
using MediaBrowser.Model.System;
using MediaBrowser.Model.Tasks;
using MediaBrowser.Model.Threading;
+using Microsoft.Extensions.Logging;
namespace Emby.Server.Implementations.IO
{
@@ -77,7 +77,7 @@ namespace Emby.Server.Implementations.IO
{
if (string.IsNullOrEmpty(path))
{
- throw new ArgumentNullException("path");
+ throw new ArgumentNullException(nameof(path));
}
TemporarilyIgnore(path);
@@ -95,7 +95,7 @@ namespace Emby.Server.Implementations.IO
{
if (string.IsNullOrEmpty(path))
{
- throw new ArgumentNullException("path");
+ throw new ArgumentNullException(nameof(path));
}
// This is an arbitraty amount of time, but delay it because file system writes often trigger events long after the file was actually written to.
@@ -103,8 +103,7 @@ namespace Emby.Server.Implementations.IO
// But if we make this delay too high, we risk missing legitimate changes, such as user adding a new file, or hand-editing metadata
await Task.Delay(45000).ConfigureAwait(false);
- string val;
- _tempIgnoredPaths.TryRemove(path, out val);
+ _tempIgnoredPaths.TryRemove(path, out var val);
if (refreshPath)
{
@@ -145,7 +144,7 @@ namespace Emby.Server.Implementations.IO
{
if (taskManager == null)
{
- throw new ArgumentNullException("taskManager");
+ throw new ArgumentNullException(nameof(taskManager));
}
LibraryManager = libraryManager;
@@ -263,12 +262,12 @@ namespace Emby.Server.Implementations.IO
/// <param name="lst">The LST.</param>
/// <param name="path">The path.</param>
/// <returns><c>true</c> if [contains parent folder] [the specified LST]; otherwise, <c>false</c>.</returns>
- /// <exception cref="System.ArgumentNullException">path</exception>
+ /// <exception cref="ArgumentNullException">path</exception>
private static bool ContainsParentFolder(IEnumerable<string> lst, string path)
{
if (string.IsNullOrEmpty(path))
{
- throw new ArgumentNullException("path");
+ throw new ArgumentNullException(nameof(path));
}
path = path.TrimEnd(Path.DirectorySeparatorChar);
@@ -365,9 +364,7 @@ namespace Emby.Server.Implementations.IO
/// <param name="path">The path.</param>
private void StopWatchingPath(string path)
{
- FileSystemWatcher watcher;
-
- if (_fileSystemWatchers.TryGetValue(path, out watcher))
+ if (_fileSystemWatchers.TryGetValue(path, out var watcher))
{
DisposeWatcher(watcher, true);
}
@@ -424,9 +421,7 @@ namespace Emby.Server.Implementations.IO
/// <param name="watcher">The watcher.</param>
private void RemoveWatcherFromList(FileSystemWatcher watcher)
{
- FileSystemWatcher removed;
-
- _fileSystemWatchers.TryRemove(watcher.Path, out removed);
+ _fileSystemWatchers.TryRemove(watcher.Path, out var removed);
}
/// <summary>
@@ -469,7 +464,7 @@ namespace Emby.Server.Implementations.IO
{
if (string.IsNullOrEmpty(path))
{
- throw new ArgumentNullException("path");
+ throw new ArgumentNullException(nameof(path));
}
var filename = Path.GetFileName(path);
diff --git a/Emby.Server.Implementations/IO/ManagedFileSystem.cs b/Emby.Server.Implementations/IO/ManagedFileSystem.cs
index 0f85e0642..3e7774abf 100644
--- a/Emby.Server.Implementations/IO/ManagedFileSystem.cs
+++ b/Emby.Server.Implementations/IO/ManagedFileSystem.cs
@@ -1,12 +1,12 @@
-using System;
+using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using MediaBrowser.Model.IO;
-using Microsoft.Extensions.Logging;
using MediaBrowser.Model.System;
+using Microsoft.Extensions.Logging;
namespace Emby.Server.Implementations.IO
{
@@ -29,9 +29,14 @@ namespace Emby.Server.Implementations.IO
private string _defaultDirectory;
- public ManagedFileSystem(ILogger logger, IEnvironmentInfo environmentInfo, string defaultDirectory, string tempPath, bool enableSeparateFileAndDirectoryQueries)
+ public ManagedFileSystem(
+ ILoggerFactory loggerFactory,
+ IEnvironmentInfo environmentInfo,
+ string defaultDirectory,
+ string tempPath,
+ bool enableSeparateFileAndDirectoryQueries)
{
- Logger = logger;
+ Logger = loggerFactory.CreateLogger("FileSystem");
_supportsAsyncFileStreams = true;
_tempPath = tempPath;
_environmentInfo = environmentInfo;
@@ -85,17 +90,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)
{
@@ -107,12 +106,12 @@ namespace Emby.Server.Implementations.IO
/// </summary>
/// <param name="filename">The filename.</param>
/// <returns><c>true</c> if the specified filename is shortcut; otherwise, <c>false</c>.</returns>
- /// <exception cref="System.ArgumentNullException">filename</exception>
+ /// <exception cref="ArgumentNullException">filename</exception>
public virtual bool IsShortcut(string filename)
{
if (string.IsNullOrEmpty(filename))
{
- throw new ArgumentNullException("filename");
+ throw new ArgumentNullException(nameof(filename));
}
var extension = Path.GetExtension(filename);
@@ -124,12 +123,12 @@ namespace Emby.Server.Implementations.IO
/// </summary>
/// <param name="filename">The filename.</param>
/// <returns>System.String.</returns>
- /// <exception cref="System.ArgumentNullException">filename</exception>
+ /// <exception cref="ArgumentNullException">filename</exception>
public virtual string ResolveShortcut(string filename)
{
if (string.IsNullOrEmpty(filename))
{
- throw new ArgumentNullException("filename");
+ throw new ArgumentNullException(nameof(filename));
}
var extension = Path.GetExtension(filename);
@@ -145,7 +144,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
@@ -159,7 +158,7 @@ namespace Emby.Server.Implementations.IO
var firstChar = filePath[0];
if (firstChar == '/')
{
- // For this we don't really know.
+ // For this we don't really know.
return filePath;
}
if (firstChar == '\\') //relative path
@@ -191,7 +190,7 @@ namespace Emby.Server.Implementations.IO
/// </summary>
/// <param name="shortcutPath">The shortcut path.</param>
/// <param name="target">The target.</param>
- /// <exception cref="System.ArgumentNullException">
+ /// <exception cref="ArgumentNullException">
/// shortcutPath
/// or
/// target
@@ -200,12 +199,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 +320,7 @@ namespace Emby.Server.Implementations.IO
return result;
}
- private ExtendedFileSystemInfo GetExtendedFileSystemInfo(string path)
+ private static ExtendedFileSystemInfo GetExtendedFileSystemInfo(string path)
{
var result = new ExtendedFileSystemInfo();
@@ -350,7 +349,7 @@ namespace Emby.Server.Implementations.IO
/// </summary>
/// <param name="filename">The filename.</param>
/// <returns>System.String.</returns>
- /// <exception cref="System.ArgumentNullException">filename</exception>
+ /// <exception cref="ArgumentNullException">filename</exception>
public string GetValidFilename(string filename)
{
var builder = new StringBuilder(filename);
@@ -451,18 +450,15 @@ namespace Emby.Server.Implementations.IO
}
public Stream GetFileStream(string path, FileOpenMode mode, FileAccessMode access, FileShareMode share, FileOpenOptions fileOpenOptions)
- {
- var defaultBufferSize = 4096;
- return new FileStream(path, GetFileMode(mode), GetFileAccess(access), GetFileShare(share), defaultBufferSize, GetFileOptions(fileOpenOptions));
- }
+ => new FileStream(path, GetFileMode(mode), GetFileAccess(access), GetFileShare(share), 4096, 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 +479,7 @@ namespace Emby.Server.Implementations.IO
}
}
- private FileAccess GetFileAccess(FileAccessMode mode)
+ private static FileAccess GetFileAccess(FileAccessMode mode)
{
switch (mode)
{
@@ -498,7 +494,7 @@ namespace Emby.Server.Implementations.IO
}
}
- private FileShare GetFileShare(FileShareMode mode)
+ private static FileShare GetFileShare(FileShareMode mode)
{
switch (mode)
{
@@ -532,7 +528,7 @@ namespace Emby.Server.Implementations.IO
}
else
{
- FileAttributes attributes = File.GetAttributes(path);
+ var attributes = File.GetAttributes(path);
attributes = RemoveAttribute(attributes, FileAttributes.Hidden);
File.SetAttributes(path, attributes);
}
@@ -556,7 +552,7 @@ namespace Emby.Server.Implementations.IO
}
else
{
- FileAttributes attributes = File.GetAttributes(path);
+ var attributes = File.GetAttributes(path);
attributes = RemoveAttribute(attributes, FileAttributes.ReadOnly);
File.SetAttributes(path, attributes);
}
@@ -619,12 +615,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 +636,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 +645,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 +662,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 +684,7 @@ namespace Emby.Server.Implementations.IO
{
if (string.IsNullOrEmpty(path))
{
- throw new ArgumentNullException("path");
+ throw new ArgumentNullException(nameof(path));
}
if (path.EndsWith(":\\", StringComparison.OrdinalIgnoreCase))
@@ -765,18 +761,13 @@ namespace Emby.Server.Implementations.IO
// Only include drives in the ready state or this method could end up being very slow, waiting for drives to timeout
return DriveInfo.GetDrives().Where(d => d.IsReady).Select(d => new FileSystemMetadata
{
- Name = GetName(d),
+ Name = d.Name,
FullName = d.RootDirectory.FullName,
IsDirectory = true
}).ToList();
}
- private string GetName(DriveInfo drive)
- {
- return drive.Name;
- }
-
public IEnumerable<FileSystemMetadata> GetDirectories(string path, bool recursive = false)
{
var searchOption = recursive ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly;
@@ -852,17 +843,6 @@ namespace Emby.Server.Implementations.IO
return File.OpenRead(path);
}
- private void CopyFileUsingStreams(string source, string target, bool overwrite)
- {
- using (var sourceStream = OpenRead(source))
- {
- using (var targetStream = GetFileStream(target, FileOpenMode.Create, FileAccessMode.Write, FileShareMode.Read))
- {
- sourceStream.CopyTo(targetStream);
- }
- }
- }
-
public void CopyFile(string source, string target, bool overwrite)
{
File.Copy(source, target, overwrite);
@@ -972,7 +952,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
{
diff --git a/Emby.Server.Implementations/IO/MbLinkShortcutHandler.cs b/Emby.Server.Implementations/IO/MbLinkShortcutHandler.cs
index aef53751e..a306f94b3 100644
--- a/Emby.Server.Implementations/IO/MbLinkShortcutHandler.cs
+++ b/Emby.Server.Implementations/IO/MbLinkShortcutHandler.cs
@@ -1,7 +1,5 @@
-using System;
+using System;
using System.IO;
-
-using MediaBrowser.Controller.IO;
using MediaBrowser.Model.IO;
namespace Emby.Server.Implementations.IO
@@ -15,16 +13,13 @@ namespace Emby.Server.Implementations.IO
_fileSystem = fileSystem;
}
- public string Extension
- {
- get { return ".mblink"; }
- }
+ public string Extension => ".mblink";
public string Resolve(string shortcutPath)
{
if (string.IsNullOrEmpty(shortcutPath))
{
- throw new ArgumentNullException("filenshortcutPathame");
+ throw new ArgumentException("Shortcut path is empty or null.", nameof(shortcutPath));
}
if (string.Equals(Path.GetExtension(shortcutPath), ".mblink", StringComparison.OrdinalIgnoreCase))
@@ -41,12 +36,12 @@ namespace Emby.Server.Implementations.IO
{
if (string.IsNullOrEmpty(shortcutPath))
{
- throw new ArgumentNullException("shortcutPath");
+ throw new ArgumentNullException(nameof(shortcutPath));
}
if (string.IsNullOrEmpty(targetPath))
{
- throw new ArgumentNullException("targetPath");
+ throw new ArgumentNullException(nameof(targetPath));
}
_fileSystem.WriteAllText(shortcutPath, targetPath);
diff --git a/Emby.Server.Implementations/IO/StreamHelper.cs b/Emby.Server.Implementations/IO/StreamHelper.cs
index e91817611..09cf4d4a3 100644
--- a/Emby.Server.Implementations/IO/StreamHelper.cs
+++ b/Emby.Server.Implementations/IO/StreamHelper.cs
@@ -1,6 +1,6 @@
-using System.IO;
-using System.Threading;
using System;
+using System.IO;
+using System.Threading;
using System.Threading.Tasks;
using MediaBrowser.Model.IO;
diff --git a/Emby.Server.Implementations/IO/ThrottledStream.cs b/Emby.Server.Implementations/IO/ThrottledStream.cs
index 81760b639..81e8abc98 100644
--- a/Emby.Server.Implementations/IO/ThrottledStream.cs
+++ b/Emby.Server.Implementations/IO/ThrottledStream.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
@@ -42,13 +42,7 @@ namespace Emby.Server.Implementations.IO
/// Gets the current milliseconds.
/// </summary>
/// <value>The current milliseconds.</value>
- protected long CurrentMilliseconds
- {
- get
- {
- return Environment.TickCount;
- }
- }
+ protected long CurrentMilliseconds => Environment.TickCount;
/// <summary>
/// Gets or sets the maximum bytes per second that can be transferred through the base stream.
@@ -56,10 +50,7 @@ namespace Emby.Server.Implementations.IO
/// <value>The maximum bytes per second.</value>
public long MaximumBytesPerSecond
{
- get
- {
- return _maximumBytesPerSecond;
- }
+ get => _maximumBytesPerSecond;
set
{
if (MaximumBytesPerSecond != value)
@@ -74,39 +65,21 @@ namespace Emby.Server.Implementations.IO
/// Gets a value indicating whether the current stream supports reading.
/// </summary>
/// <returns>true if the stream supports reading; otherwise, false.</returns>
- public override bool CanRead
- {
- get
- {
- return _baseStream.CanRead;
- }
- }
+ public override bool CanRead => _baseStream.CanRead;
/// <summary>
/// Gets a value indicating whether the current stream supports seeking.
/// </summary>
/// <value></value>
/// <returns>true if the stream supports seeking; otherwise, false.</returns>
- public override bool CanSeek
- {
- get
- {
- return _baseStream.CanSeek;
- }
- }
+ public override bool CanSeek => _baseStream.CanSeek;
/// <summary>
/// Gets a value indicating whether the current stream supports writing.
/// </summary>
/// <value></value>
/// <returns>true if the stream supports writing; otherwise, false.</returns>
- public override bool CanWrite
- {
- get
- {
- return _baseStream.CanWrite;
- }
- }
+ public override bool CanWrite => _baseStream.CanWrite;
/// <summary>
/// Gets the length in bytes of the stream.
@@ -115,13 +88,7 @@ namespace Emby.Server.Implementations.IO
/// <returns>A long value representing the length of the stream in bytes.</returns>
/// <exception cref="T:System.NotSupportedException">The base stream does not support seeking. </exception>
/// <exception cref="T:System.ObjectDisposedException">Methods were called after the stream was closed. </exception>
- public override long Length
- {
- get
- {
- return _baseStream.Length;
- }
- }
+ public override long Length => _baseStream.Length;
/// <summary>
/// Gets or sets the position within the current stream.
@@ -133,14 +100,8 @@ namespace Emby.Server.Implementations.IO
/// <exception cref="T:System.ObjectDisposedException">Methods were called after the stream was closed. </exception>
public override long Position
{
- get
- {
- return _baseStream.Position;
- }
- set
- {
- _baseStream.Position = value;
- }
+ get => _baseStream.Position;
+ set => _baseStream.Position = value;
}
#endregion
@@ -158,12 +119,12 @@ namespace Emby.Server.Implementations.IO
{
if (baseStream == null)
{
- throw new ArgumentNullException("baseStream");
+ throw new ArgumentNullException(nameof(baseStream));
}
if (maximumBytesPerSecond < 0)
{
- throw new ArgumentOutOfRangeException("maximumBytesPerSecond",
+ throw new ArgumentOutOfRangeException(nameof(maximumBytesPerSecond),
maximumBytesPerSecond, "The maximum number of bytes per second can't be negative.");
}
@@ -303,7 +264,7 @@ namespace Emby.Server.Implementations.IO
{
if (!ThrottleCheck(bufferSizeInBytes))
{
- return ;
+ return;
}
_byteCount += bufferSizeInBytes;
@@ -391,4 +352,4 @@ namespace Emby.Server.Implementations.IO
}
#endregion
}
-} \ No newline at end of file
+}