mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-05-24 02:02:29 -04:00
Unwrapped OpenRead
and CopyFile
This commit is contained in:
parent
d7c6d16250
commit
a430568082
@ -1,4 +1,4 @@
|
|||||||
//============================================================================
|
//============================================================================
|
||||||
// BDInfo - Blu-ray Video and Audio Analysis Tool
|
// BDInfo - Blu-ray Video and Audio Analysis Tool
|
||||||
// Copyright © 2010 Cinema Squid
|
// Copyright © 2010 Cinema Squid
|
||||||
//
|
//
|
||||||
@ -231,7 +231,7 @@ namespace BDInfo
|
|||||||
Streams.Clear();
|
Streams.Clear();
|
||||||
StreamClips.Clear();
|
StreamClips.Clear();
|
||||||
|
|
||||||
fileStream = _fileSystem.OpenRead(FileInfo.FullName);
|
fileStream = File.OpenRead(FileInfo.FullName);
|
||||||
fileReader = new BinaryReader(fileStream);
|
fileReader = new BinaryReader(fileStream);
|
||||||
|
|
||||||
byte[] data = new byte[fileStream.Length];
|
byte[] data = new byte[fileStream.Length];
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
//============================================================================
|
//============================================================================
|
||||||
// BDInfo - Blu-ray Video and Audio Analysis Tool
|
// BDInfo - Blu-ray Video and Audio Analysis Tool
|
||||||
// Copyright © 2010 Cinema Squid
|
// Copyright © 2010 Cinema Squid
|
||||||
//
|
//
|
||||||
@ -57,7 +57,7 @@ namespace BDInfo
|
|||||||
#endif
|
#endif
|
||||||
Streams.Clear();
|
Streams.Clear();
|
||||||
|
|
||||||
fileStream = _fileSystem.OpenRead(FileInfo.FullName);
|
fileStream = File.OpenRead(FileInfo.FullName);
|
||||||
fileReader = new BinaryReader(fileStream);
|
fileReader = new BinaryReader(fileStream);
|
||||||
|
|
||||||
byte[] data = new byte[fileStream.Length];
|
byte[] data = new byte[fileStream.Length];
|
||||||
|
@ -29,7 +29,7 @@ namespace Emby.Server.Implementations.Archiving
|
|||||||
/// <param name="overwriteExistingFiles">if set to <c>true</c> [overwrite existing files].</param>
|
/// <param name="overwriteExistingFiles">if set to <c>true</c> [overwrite existing files].</param>
|
||||||
public void ExtractAll(string sourceFile, string targetPath, bool overwriteExistingFiles)
|
public void ExtractAll(string sourceFile, string targetPath, bool overwriteExistingFiles)
|
||||||
{
|
{
|
||||||
using (var fileStream = _fileSystem.OpenRead(sourceFile))
|
using (var fileStream = File.OpenRead(sourceFile))
|
||||||
{
|
{
|
||||||
ExtractAll(fileStream, targetPath, overwriteExistingFiles);
|
ExtractAll(fileStream, targetPath, overwriteExistingFiles);
|
||||||
}
|
}
|
||||||
@ -115,7 +115,7 @@ namespace Emby.Server.Implementations.Archiving
|
|||||||
/// <param name="overwriteExistingFiles">if set to <c>true</c> [overwrite existing files].</param>
|
/// <param name="overwriteExistingFiles">if set to <c>true</c> [overwrite existing files].</param>
|
||||||
public void ExtractAllFrom7z(string sourceFile, string targetPath, bool overwriteExistingFiles)
|
public void ExtractAllFrom7z(string sourceFile, string targetPath, bool overwriteExistingFiles)
|
||||||
{
|
{
|
||||||
using (var fileStream = _fileSystem.OpenRead(sourceFile))
|
using (var fileStream = File.OpenRead(sourceFile))
|
||||||
{
|
{
|
||||||
ExtractAllFrom7z(fileStream, targetPath, overwriteExistingFiles);
|
ExtractAllFrom7z(fileStream, targetPath, overwriteExistingFiles);
|
||||||
}
|
}
|
||||||
@ -155,7 +155,7 @@ namespace Emby.Server.Implementations.Archiving
|
|||||||
/// <param name="overwriteExistingFiles">if set to <c>true</c> [overwrite existing files].</param>
|
/// <param name="overwriteExistingFiles">if set to <c>true</c> [overwrite existing files].</param>
|
||||||
public void ExtractAllFromTar(string sourceFile, string targetPath, bool overwriteExistingFiles)
|
public void ExtractAllFromTar(string sourceFile, string targetPath, bool overwriteExistingFiles)
|
||||||
{
|
{
|
||||||
using (var fileStream = _fileSystem.OpenRead(sourceFile))
|
using (var fileStream = File.OpenRead(sourceFile))
|
||||||
{
|
{
|
||||||
ExtractAllFromTar(fileStream, targetPath, overwriteExistingFiles);
|
ExtractAllFromTar(fileStream, targetPath, overwriteExistingFiles);
|
||||||
}
|
}
|
||||||
|
@ -300,7 +300,7 @@ namespace Emby.Server.Implementations.Images
|
|||||||
var ext = Path.GetExtension(image);
|
var ext = Path.GetExtension(image);
|
||||||
|
|
||||||
var outputPath = Path.ChangeExtension(outputPathWithoutExtension, ext);
|
var outputPath = Path.ChangeExtension(outputPathWithoutExtension, ext);
|
||||||
FileSystem.CopyFile(image, outputPath, true);
|
File.Copy(image, outputPath, true);
|
||||||
|
|
||||||
return outputPath;
|
return outputPath;
|
||||||
}
|
}
|
||||||
|
@ -1827,7 +1827,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
|
|||||||
// preserve original image extension
|
// preserve original image extension
|
||||||
imageSavePath = Path.ChangeExtension(imageSavePath, Path.GetExtension(image.Path));
|
imageSavePath = Path.ChangeExtension(imageSavePath, Path.GetExtension(image.Path));
|
||||||
|
|
||||||
_fileSystem.CopyFile(image.Path, imageSavePath, true);
|
File.Copy(image.Path, imageSavePath, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task SaveRecordingImages(string recordingPath, LiveTvProgram program)
|
private async Task SaveRecordingImages(string recordingPath, LiveTvProgram program)
|
||||||
|
@ -85,7 +85,7 @@ namespace Jellyfin.Server.Implementations.LiveTv.Listings
|
|||||||
|
|
||||||
Directory.CreateDirectory(Path.GetDirectoryName(cacheFile));
|
Directory.CreateDirectory(Path.GetDirectoryName(cacheFile));
|
||||||
|
|
||||||
_fileSystem.CopyFile(tempFile, cacheFile, true);
|
File.Copy(tempFile, cacheFile, true);
|
||||||
|
|
||||||
return UnzipIfNeeded(path, cacheFile);
|
return UnzipIfNeeded(path, cacheFile);
|
||||||
}
|
}
|
||||||
@ -122,7 +122,7 @@ namespace Jellyfin.Server.Implementations.LiveTv.Listings
|
|||||||
|
|
||||||
private string ExtractFirstFileFromGz(string file)
|
private string ExtractFirstFileFromGz(string file)
|
||||||
{
|
{
|
||||||
using (var stream = _fileSystem.OpenRead(file))
|
using (var stream = File.OpenRead(file))
|
||||||
{
|
{
|
||||||
string tempFolder = Path.Combine(_config.ApplicationPaths.TempDirectory, Guid.NewGuid().ToString());
|
string tempFolder = Path.Combine(_config.ApplicationPaths.TempDirectory, Guid.NewGuid().ToString());
|
||||||
Directory.CreateDirectory(tempFolder);
|
Directory.CreateDirectory(tempFolder);
|
||||||
@ -135,7 +135,7 @@ namespace Jellyfin.Server.Implementations.LiveTv.Listings
|
|||||||
|
|
||||||
private string ExtractGz(string file)
|
private string ExtractGz(string file)
|
||||||
{
|
{
|
||||||
using (var stream = _fileSystem.OpenRead(file))
|
using (var stream = File.OpenRead(file))
|
||||||
{
|
{
|
||||||
string tempFolder = Path.Combine(_config.ApplicationPaths.TempDirectory, Guid.NewGuid().ToString());
|
string tempFolder = Path.Combine(_config.ApplicationPaths.TempDirectory, Guid.NewGuid().ToString());
|
||||||
Directory.CreateDirectory(tempFolder);
|
Directory.CreateDirectory(tempFolder);
|
||||||
|
@ -61,7 +61,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
|
|||||||
UserAgent = _appHost.ApplicationUserAgent
|
UserAgent = _appHost.ApplicationUserAgent
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return Task.FromResult(_fileSystem.OpenRead(url));
|
return Task.FromResult((Stream)File.OpenRead(url));
|
||||||
}
|
}
|
||||||
|
|
||||||
const string ExtInfPrefix = "#EXTINF:";
|
const string ExtInfPrefix = "#EXTINF:";
|
||||||
|
@ -316,7 +316,7 @@ namespace Emby.Server.Implementations.Localization
|
|||||||
/// <returns>Dictionary{System.StringParentalRating}.</returns>
|
/// <returns>Dictionary{System.StringParentalRating}.</returns>
|
||||||
private void LoadRatings(string file)
|
private void LoadRatings(string file)
|
||||||
{
|
{
|
||||||
var dict = _fileSystem.ReadAllLines(file).Select(i =>
|
var dict = File.ReadAllLines(file).Select(i =>
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrWhiteSpace(i))
|
if (!string.IsNullOrWhiteSpace(i))
|
||||||
{
|
{
|
||||||
|
@ -146,7 +146,7 @@ namespace Emby.Server.Implementations.MediaEncoder
|
|||||||
var container = video.Container;
|
var container = video.Container;
|
||||||
|
|
||||||
var tempFile = await _encoder.ExtractVideoImage(inputPath, container, protocol, video.GetDefaultVideoStream(), video.Video3DFormat, time, cancellationToken).ConfigureAwait(false);
|
var tempFile = await _encoder.ExtractVideoImage(inputPath, container, protocol, video.GetDefaultVideoStream(), video.Video3DFormat, time, cancellationToken).ConfigureAwait(false);
|
||||||
_fileSystem.CopyFile(tempFile, path, true);
|
File.Copy(tempFile, path, true);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -86,7 +86,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
lines = _fileSystem.ReadAllLines(path).Where(i => !string.IsNullOrWhiteSpace(i)).Distinct(StringComparer.OrdinalIgnoreCase).ToList();
|
lines = File.ReadAllLines(path).Where(i => !string.IsNullOrWhiteSpace(i)).Distinct(StringComparer.OrdinalIgnoreCase).ToList();
|
||||||
|
|
||||||
foreach (var key in lines)
|
foreach (var key in lines)
|
||||||
{
|
{
|
||||||
|
@ -107,7 +107,7 @@ namespace Emby.Server.Implementations.Serialization
|
|||||||
public object DeserializeFromFile(Type type, string file)
|
public object DeserializeFromFile(Type type, string file)
|
||||||
{
|
{
|
||||||
_logger.LogDebug("Deserializing file {0}", file);
|
_logger.LogDebug("Deserializing file {0}", file);
|
||||||
using (var stream = _fileSystem.OpenRead(file))
|
using (var stream = File.OpenRead(file))
|
||||||
{
|
{
|
||||||
return DeserializeFromStream(type, stream);
|
return DeserializeFromStream(type, stream);
|
||||||
}
|
}
|
||||||
|
@ -555,7 +555,7 @@ namespace Emby.Server.Implementations.Updates
|
|||||||
var packageChecksum = string.IsNullOrWhiteSpace(package.checksum) ? Guid.Empty : new Guid(package.checksum);
|
var packageChecksum = string.IsNullOrWhiteSpace(package.checksum) ? Guid.Empty : new Guid(package.checksum);
|
||||||
if (!packageChecksum.Equals(Guid.Empty)) // support for legacy uploads for now
|
if (!packageChecksum.Equals(Guid.Empty)) // support for legacy uploads for now
|
||||||
{
|
{
|
||||||
using (var stream = _fileSystem.OpenRead(tempFile))
|
using (var stream = File.OpenRead(tempFile))
|
||||||
{
|
{
|
||||||
var check = Guid.Parse(BitConverter.ToString(_cryptographyProvider.ComputeMD5(stream)).Replace("-", string.Empty));
|
var check = Guid.Parse(BitConverter.ToString(_cryptographyProvider.ComputeMD5(stream)).Replace("-", string.Empty));
|
||||||
if (check != packageChecksum)
|
if (check != packageChecksum)
|
||||||
@ -571,7 +571,7 @@ namespace Emby.Server.Implementations.Updates
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
Directory.CreateDirectory(Path.GetDirectoryName(target));
|
Directory.CreateDirectory(Path.GetDirectoryName(target));
|
||||||
_fileSystem.CopyFile(tempFile, target, true);
|
File.Copy(tempFile, target, true);
|
||||||
//If it is an archive - write out a version file so we know what it is
|
//If it is an archive - write out a version file so we know what it is
|
||||||
if (isArchive)
|
if (isArchive)
|
||||||
{
|
{
|
||||||
|
@ -220,7 +220,7 @@ namespace Jellyfin.Drawing.Skia
|
|||||||
var tempPath = Path.Combine(_appPaths.TempDirectory, Guid.NewGuid() + Path.GetExtension(path) ?? string.Empty);
|
var tempPath = Path.Combine(_appPaths.TempDirectory, Guid.NewGuid() + Path.GetExtension(path) ?? string.Empty);
|
||||||
|
|
||||||
Directory.CreateDirectory(Path.GetDirectoryName(tempPath));
|
Directory.CreateDirectory(Path.GetDirectoryName(tempPath));
|
||||||
fileSystem.CopyFile(path, tempPath, true);
|
File.Copy(path, tempPath, true);
|
||||||
|
|
||||||
return tempPath;
|
return tempPath;
|
||||||
}
|
}
|
||||||
|
@ -102,7 +102,7 @@ namespace MediaBrowser.LocalMetadata.Parsers
|
|||||||
{
|
{
|
||||||
item.ResetPeople();
|
item.ResetPeople();
|
||||||
|
|
||||||
using (var fileStream = FileSystem.OpenRead(metadataFile))
|
using (var fileStream = File.OpenRead(metadataFile))
|
||||||
{
|
{
|
||||||
using (var streamReader = new StreamReader(fileStream, encoding))
|
using (var streamReader = new StreamReader(fileStream, encoding))
|
||||||
{
|
{
|
||||||
|
@ -269,7 +269,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles
|
|||||||
var subLanguageId = NormalizeLanguage(request.Language);
|
var subLanguageId = NormalizeLanguage(request.Language);
|
||||||
string hash;
|
string hash;
|
||||||
|
|
||||||
using (var fileStream = _fileSystem.OpenRead(request.MediaPath))
|
using (var fileStream = File.OpenRead(request.MediaPath))
|
||||||
{
|
{
|
||||||
hash = Utilities.ComputeHash(fileStream);
|
hash = Utilities.ComputeHash(fileStream);
|
||||||
}
|
}
|
||||||
|
@ -210,7 +210,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return _fileSystem.OpenRead(path);
|
return File.OpenRead(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<SubtitleInfo> GetReadableFile(
|
private async Task<SubtitleInfo> GetReadableFile(
|
||||||
@ -672,7 +672,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles
|
|||||||
string text;
|
string text;
|
||||||
Encoding encoding;
|
Encoding encoding;
|
||||||
|
|
||||||
using (var fileStream = _fileSystem.OpenRead(file))
|
using (var fileStream = File.OpenRead(file))
|
||||||
using (var reader = new StreamReader(fileStream, true))
|
using (var reader = new StreamReader(fileStream, true))
|
||||||
{
|
{
|
||||||
encoding = reader.CurrentEncoding;
|
encoding = reader.CurrentEncoding;
|
||||||
|
@ -70,7 +70,7 @@ namespace MediaBrowser.Providers.MediaInfo
|
|||||||
|
|
||||||
var tempFile = await _mediaEncoder.ExtractAudioImage(item.Path, imageStreamIndex, cancellationToken).ConfigureAwait(false);
|
var tempFile = await _mediaEncoder.ExtractAudioImage(item.Path, imageStreamIndex, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
_fileSystem.CopyFile(tempFile, path, true);
|
File.Copy(tempFile, path, true);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
@ -196,7 +197,7 @@ namespace MediaBrowser.Providers.MediaInfo
|
|||||||
|
|
||||||
private void FetchShortcutInfo(BaseItem item)
|
private void FetchShortcutInfo(BaseItem item)
|
||||||
{
|
{
|
||||||
item.ShortcutPath = _fileSystem.ReadAllLines(item.Path)
|
item.ShortcutPath = File.ReadAllLines(item.Path)
|
||||||
.Select(NormalizeStrmLine)
|
.Select(NormalizeStrmLine)
|
||||||
.FirstOrDefault(i => !string.IsNullOrWhiteSpace(i) && !i.StartsWith("#", StringComparison.OrdinalIgnoreCase));
|
.FirstOrDefault(i => !string.IsNullOrWhiteSpace(i) && !i.StartsWith("#", StringComparison.OrdinalIgnoreCase));
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ namespace MediaBrowser.Providers.Playlists
|
|||||||
return Task.FromResult(ItemUpdateType.None);
|
return Task.FromResult(ItemUpdateType.None);
|
||||||
}
|
}
|
||||||
|
|
||||||
using (var stream = _fileSystem.OpenRead(path))
|
using (var stream = File.OpenRead(path))
|
||||||
{
|
{
|
||||||
var items = GetItems(stream, extension).ToArray();
|
var items = GetItems(stream, extension).ToArray();
|
||||||
|
|
||||||
|
@ -155,7 +155,7 @@ namespace MediaBrowser.Providers.Studios
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
fileSystem.CopyFile(temp, file, true);
|
File.Copy(temp, file, true);
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
|
@ -263,7 +263,7 @@ namespace MediaBrowser.Providers.TV
|
|||||||
|
|
||||||
if (!string.Equals(downloadLangaugeXmlFile, saveAsLanguageXmlFile, StringComparison.OrdinalIgnoreCase))
|
if (!string.Equals(downloadLangaugeXmlFile, saveAsLanguageXmlFile, StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
_fileSystem.CopyFile(downloadLangaugeXmlFile, saveAsLanguageXmlFile, true);
|
File.Copy(downloadLangaugeXmlFile, saveAsLanguageXmlFile, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
await ExtractEpisodes(seriesDataPath, downloadLangaugeXmlFile, lastTvDbUpdateTime).ConfigureAwait(false);
|
await ExtractEpisodes(seriesDataPath, downloadLangaugeXmlFile, lastTvDbUpdateTime).ConfigureAwait(false);
|
||||||
|
@ -443,7 +443,7 @@ namespace MediaBrowser.WebDashboard.Api
|
|||||||
|
|
||||||
//Copy all the files & Replaces any files with the same name
|
//Copy all the files & Replaces any files with the same name
|
||||||
foreach (var newPath in _fileSystem.GetFiles(source, true))
|
foreach (var newPath in _fileSystem.GetFiles(source, true))
|
||||||
_fileSystem.CopyFile(newPath.FullName, newPath.FullName.Replace(source, destination), true);
|
File.Copy(newPath.FullName, newPath.FullName.Replace(source, destination), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,7 +108,7 @@ namespace MediaBrowser.XbmcMetadata.Parsers
|
|||||||
{
|
{
|
||||||
if (!SupportsUrlAfterClosingXmlTag)
|
if (!SupportsUrlAfterClosingXmlTag)
|
||||||
{
|
{
|
||||||
using (var fileStream = FileSystem.OpenRead(metadataFile))
|
using (var fileStream = File.OpenRead(metadataFile))
|
||||||
{
|
{
|
||||||
using (var streamReader = new StreamReader(fileStream, Encoding.UTF8))
|
using (var streamReader = new StreamReader(fileStream, Encoding.UTF8))
|
||||||
{
|
{
|
||||||
@ -140,7 +140,7 @@ namespace MediaBrowser.XbmcMetadata.Parsers
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
using (var fileStream = FileSystem.OpenRead(metadataFile))
|
using (var fileStream = File.OpenRead(metadataFile))
|
||||||
{
|
{
|
||||||
using (var streamReader = new StreamReader(fileStream, Encoding.UTF8))
|
using (var streamReader = new StreamReader(fileStream, Encoding.UTF8))
|
||||||
{
|
{
|
||||||
|
@ -28,7 +28,7 @@ namespace MediaBrowser.XbmcMetadata.Parsers
|
|||||||
|
|
||||||
protected override void Fetch(MetadataResult<Episode> item, string metadataFile, XmlReaderSettings settings, CancellationToken cancellationToken)
|
protected override void Fetch(MetadataResult<Episode> item, string metadataFile, XmlReaderSettings settings, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
using (var fileStream = FileSystem.OpenRead(metadataFile))
|
using (var fileStream = File.OpenRead(metadataFile))
|
||||||
{
|
{
|
||||||
using (var streamReader = new StreamReader(fileStream, Encoding.UTF8))
|
using (var streamReader = new StreamReader(fileStream, Encoding.UTF8))
|
||||||
{
|
{
|
||||||
|
@ -974,7 +974,7 @@ namespace MediaBrowser.XbmcMetadata.Savers
|
|||||||
settings.IgnoreProcessingInstructions = true;
|
settings.IgnoreProcessingInstructions = true;
|
||||||
settings.IgnoreComments = true;
|
settings.IgnoreComments = true;
|
||||||
|
|
||||||
using (var fileStream = fileSystem.OpenRead(path))
|
using (var fileStream = File.OpenRead(path))
|
||||||
{
|
{
|
||||||
using (var streamReader = new StreamReader(fileStream, Encoding.UTF8))
|
using (var streamReader = new StreamReader(fileStream, Encoding.UTF8))
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user