From 9e3c41ed2c88f06c50944319a8ea7811cf806d3a Mon Sep 17 00:00:00 2001 From: Alex Barney Date: Tue, 11 Dec 2018 13:59:46 -0600 Subject: [PATCH] Add keepOpen parameter to AsStream and AsStorage --- src/LibHac/IO/StorageExtensions.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/LibHac/IO/StorageExtensions.cs b/src/LibHac/IO/StorageExtensions.cs index 2b362ca4..f4d5bcd7 100644 --- a/src/LibHac/IO/StorageExtensions.cs +++ b/src/LibHac/IO/StorageExtensions.cs @@ -42,6 +42,7 @@ namespace LibHac.IO } public static Stream AsStream(this IStorage storage) => new StorageStream(storage, true); + public static Stream AsStream(this IStorage storage, bool keepOpen) => new StorageStream(storage, keepOpen); public static void CopyTo(this IStorage input, IStorage output, IProgressReport progress = null) { @@ -112,6 +113,12 @@ namespace LibHac.IO return new StreamStorage(stream, true); } + public static Storage AsStorage(this Stream stream, bool keepOpen) + { + if (stream == null) return null; + return new StreamStorage(stream, keepOpen); + } + public static Storage AsStorage(this Stream stream, long start) { if (stream == null) return null; @@ -123,5 +130,11 @@ namespace LibHac.IO if (stream == null) return null; return new StreamStorage(stream, true).Slice(start, length); } + + public static Storage AsStorage(this Stream stream, long start, int length, bool keepOpen) + { + if (stream == null) return null; + return new StreamStorage(stream, keepOpen).Slice(start, length); + } } }