From 49a8ffd3e29f00e510c1a7c534545336d1cc8c55 Mon Sep 17 00:00:00 2001 From: Xpl0itR Date: Sat, 8 Aug 2020 17:47:16 +0100 Subject: [PATCH] Expose bufferSize as a variable in CopyTo and CopyToStream --- src/LibHac/FsSystem/StorageExtensions.cs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/LibHac/FsSystem/StorageExtensions.cs b/src/LibHac/FsSystem/StorageExtensions.cs index 6438116b..495d46ce 100644 --- a/src/LibHac/FsSystem/StorageExtensions.cs +++ b/src/LibHac/FsSystem/StorageExtensions.cs @@ -71,10 +71,8 @@ namespace LibHac.FsSystem public static IFile AsFile(this IStorage storage, OpenMode mode) => new StorageFile(storage, mode); - public static void CopyTo(this IStorage input, IStorage output, IProgressReport progress = null) + public static void CopyTo(this IStorage input, IStorage output, IProgressReport progress = null, int bufferSize = 81920) { - const int bufferSize = 81920; - input.GetSize(out long inputSize).ThrowIfFailure(); output.GetSize(out long outputSize).ThrowIfFailure(); @@ -186,9 +184,8 @@ namespace LibHac.FsSystem return arr; } - public static void CopyToStream(this IStorage input, Stream output, long length, IProgressReport progress = null) + public static void CopyToStream(this IStorage input, Stream output, long length, IProgressReport progress = null, int bufferSize = 0x8000) { - const int bufferSize = 0x8000; long remaining = length; long inOffset = 0; using var buffer = new RentedArray(bufferSize); @@ -207,10 +204,10 @@ namespace LibHac.FsSystem } } - public static void CopyToStream(this IStorage input, Stream output) + public static void CopyToStream(this IStorage input, Stream output, int bufferSize = 0x8000) { input.GetSize(out long inputSize).ThrowIfFailure(); - CopyToStream(input, output, inputSize); + CopyToStream(input, output, inputSize, bufferSize: bufferSize); } public static IStorage AsStorage(this Stream stream)