misc: chore: Fix object creation in Common project
This commit is contained in:
parent
ae92fbf539
commit
7f5a356c3d
@ -164,7 +164,7 @@ namespace Ryujinx.Common.Extensions
|
|||||||
// Not enough data in the current segment, try to peek for the data we need.
|
// Not enough data in the current segment, try to peek for the data we need.
|
||||||
T buffer = default;
|
T buffer = default;
|
||||||
|
|
||||||
Span<byte> tempSpan = new Span<byte>(&buffer, sizeof(T));
|
Span<byte> tempSpan = new(&buffer, sizeof(T));
|
||||||
|
|
||||||
if (!reader.TryCopyTo(tempSpan))
|
if (!reader.TryCopyTo(tempSpan))
|
||||||
{
|
{
|
||||||
|
@ -91,7 +91,7 @@ namespace Ryujinx.Common
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
using StreamReader reader = new StreamReader(stream);
|
using StreamReader reader = new(stream);
|
||||||
return reader.ReadToEnd();
|
return reader.ReadToEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,7 +103,7 @@ namespace Ryujinx.Common
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
using StreamReader reader = new StreamReader(stream);
|
using StreamReader reader = new(stream);
|
||||||
return await reader.ReadToEndAsync();
|
return await reader.ReadToEndAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ namespace Ryujinx.Common.Utilities
|
|||||||
public static void CopyDirectory(string sourceDir, string destinationDir, bool recursive)
|
public static void CopyDirectory(string sourceDir, string destinationDir, bool recursive)
|
||||||
{
|
{
|
||||||
// Get information about the source directory
|
// Get information about the source directory
|
||||||
DirectoryInfo dir = new DirectoryInfo(sourceDir);
|
DirectoryInfo dir = new(sourceDir);
|
||||||
|
|
||||||
// Check if the source directory exists
|
// Check if the source directory exists
|
||||||
if (!dir.Exists)
|
if (!dir.Exists)
|
||||||
@ -49,7 +49,7 @@ namespace Ryujinx.Common.Utilities
|
|||||||
|
|
||||||
public static string SanitizeFileName(string fileName)
|
public static string SanitizeFileName(string fileName)
|
||||||
{
|
{
|
||||||
HashSet<char> reservedChars = new HashSet<char>(Path.GetInvalidFileNameChars());
|
HashSet<char> reservedChars = new(Path.GetInvalidFileNameChars());
|
||||||
return string.Concat(fileName.Select(c => reservedChars.Contains(c) ? '_' : c));
|
return string.Concat(fileName.Select(c => reservedChars.Contains(c) ? '_' : c));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ namespace Ryujinx.Common.Utilities
|
|||||||
|
|
||||||
public static string Format(MessagePackObject obj)
|
public static string Format(MessagePackObject obj)
|
||||||
{
|
{
|
||||||
IndentedStringBuilder builder = new IndentedStringBuilder();
|
IndentedStringBuilder builder = new();
|
||||||
|
|
||||||
FormatMsgPackObj(obj, builder);
|
FormatMsgPackObj(obj, builder);
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ namespace Ryujinx.Common.Utilities
|
|||||||
{
|
{
|
||||||
if (Path.GetExtension(filename).Equals(".XCI", StringComparison.InvariantCultureIgnoreCase))
|
if (Path.GetExtension(filename).Equals(".XCI", StringComparison.InvariantCultureIgnoreCase))
|
||||||
{
|
{
|
||||||
XCIFileTrimmer trimmer = new XCIFileTrimmer(filename, log);
|
XCIFileTrimmer trimmer = new(filename, log);
|
||||||
return trimmer.CanBeTrimmed;
|
return trimmer.CanBeTrimmed;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,7 +57,7 @@ namespace Ryujinx.Common.Utilities
|
|||||||
{
|
{
|
||||||
if (Path.GetExtension(filename).Equals(".XCI", StringComparison.InvariantCultureIgnoreCase))
|
if (Path.GetExtension(filename).Equals(".XCI", StringComparison.InvariantCultureIgnoreCase))
|
||||||
{
|
{
|
||||||
XCIFileTrimmer trimmer = new XCIFileTrimmer(filename, log);
|
XCIFileTrimmer trimmer = new(filename, log);
|
||||||
return trimmer.CanBeUntrimmed;
|
return trimmer.CanBeUntrimmed;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -267,7 +267,7 @@ namespace Ryujinx.Common.Utilities
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
FileInfo info = new FileInfo(Filename);
|
FileInfo info = new(Filename);
|
||||||
if ((info.Attributes & FileAttributes.ReadOnly) == FileAttributes.ReadOnly)
|
if ((info.Attributes & FileAttributes.ReadOnly) == FileAttributes.ReadOnly)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -288,7 +288,7 @@ namespace Ryujinx.Common.Utilities
|
|||||||
return OperationOutcome.FileSizeChanged;
|
return OperationOutcome.FileSizeChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
FileStream outfileStream = new FileStream(_filename, FileMode.Open, FileAccess.Write, FileShare.Write);
|
FileStream outfileStream = new(_filename, FileMode.Open, FileAccess.Write, FileShare.Write);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -327,7 +327,7 @@ namespace Ryujinx.Common.Utilities
|
|||||||
{
|
{
|
||||||
Log?.Write(LogType.Info, "Untrimming...");
|
Log?.Write(LogType.Info, "Untrimming...");
|
||||||
|
|
||||||
FileInfo info = new FileInfo(Filename);
|
FileInfo info = new(Filename);
|
||||||
if ((info.Attributes & FileAttributes.ReadOnly) == FileAttributes.ReadOnly)
|
if ((info.Attributes & FileAttributes.ReadOnly) == FileAttributes.ReadOnly)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -348,7 +348,7 @@ namespace Ryujinx.Common.Utilities
|
|||||||
return OperationOutcome.FileSizeChanged;
|
return OperationOutcome.FileSizeChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
FileStream outfileStream = new FileStream(_filename, FileMode.Append, FileAccess.Write, FileShare.Write);
|
FileStream outfileStream = new(_filename, FileMode.Append, FileAccess.Write, FileShare.Write);
|
||||||
long bytesToWriteB = UntrimmedFileSizeB - FileSizeB;
|
long bytesToWriteB = UntrimmedFileSizeB - FileSizeB;
|
||||||
|
|
||||||
try
|
try
|
||||||
|
Loading…
x
Reference in New Issue
Block a user