diff --git a/SabreTools.DatTools/Rebuilder.cs b/SabreTools.DatTools/Rebuilder.cs index 36a72864..6f977428 100644 --- a/SabreTools.DatTools/Rebuilder.cs +++ b/SabreTools.DatTools/Rebuilder.cs @@ -744,7 +744,10 @@ namespace SabreTools.DatTools { BaseArchive? archive = BaseArchive.Create(file); if (archive != null) - (stream, _) = archive.CopyToStream(datItem.GetName() ?? datItem.GetStringFieldValue(Models.Metadata.DatItem.TypeKey).AsEnumValue().AsStringValue() ?? string.Empty); + { + ItemType itemType = datItem.GetStringFieldValue(Models.Metadata.DatItem.TypeKey).AsEnumValue(); + (stream, _) = archive.CopyToStream(datItem.GetName() ?? itemType.AsStringValue() ?? string.Empty); + } } // Otherwise, just open the filestream else diff --git a/SabreTools.FileTypes/Archives/GZipArchive.cs b/SabreTools.FileTypes/Archives/GZipArchive.cs index d355d7db..8c773236 100644 --- a/SabreTools.FileTypes/Archives/GZipArchive.cs +++ b/SabreTools.FileTypes/Archives/GZipArchive.cs @@ -130,9 +130,9 @@ namespace SabreTools.FileTypes.Archives public override string? CopyToFile(string entryName, string outDir) { // Try to extract a stream using the given information - (MemoryStream? ms, string? realEntry) = CopyToStream(entryName); + (Stream? ms, string? realEntry) = CopyToStream(entryName); - // If the memory stream and the entry name are both non-null, we write to file + // If the stream and the entry name are both non-null, we write to file if (ms != null && realEntry != null) { realEntry = Path.Combine(outDir, realEntry); @@ -170,9 +170,9 @@ namespace SabreTools.FileTypes.Archives } /// - public override (MemoryStream?, string?) CopyToStream(string entryName) + public override (Stream?, string?) CopyToStream(string entryName) { - MemoryStream? ms = new(); + var ms = new MemoryStream(); string? realEntry; // If we have an invalid file diff --git a/SabreTools.FileTypes/Archives/LRZipArchive.cs b/SabreTools.FileTypes/Archives/LRZipArchive.cs index f3029f28..d727dcd3 100644 --- a/SabreTools.FileTypes/Archives/LRZipArchive.cs +++ b/SabreTools.FileTypes/Archives/LRZipArchive.cs @@ -49,7 +49,7 @@ namespace SabreTools.FileTypes.Archives } /// - public override (MemoryStream, string) CopyToStream(string entryName) + public override (Stream?, string?) CopyToStream(string entryName) { throw new NotImplementedException(); } diff --git a/SabreTools.FileTypes/Archives/LZ4Archive.cs b/SabreTools.FileTypes/Archives/LZ4Archive.cs index 3457fc6d..6f89ab0b 100644 --- a/SabreTools.FileTypes/Archives/LZ4Archive.cs +++ b/SabreTools.FileTypes/Archives/LZ4Archive.cs @@ -49,7 +49,7 @@ namespace SabreTools.FileTypes.Archives } /// - public override (MemoryStream, string) CopyToStream(string entryName) + public override (Stream?, string?) CopyToStream(string entryName) { throw new NotImplementedException(); } diff --git a/SabreTools.FileTypes/Archives/RarArchive.cs b/SabreTools.FileTypes/Archives/RarArchive.cs index a5b10675..f5712a73 100644 --- a/SabreTools.FileTypes/Archives/RarArchive.cs +++ b/SabreTools.FileTypes/Archives/RarArchive.cs @@ -96,9 +96,9 @@ namespace SabreTools.FileTypes.Archives public override string? CopyToFile(string entryName, string outDir) { // Try to extract a stream using the given information - (MemoryStream? ms, string? realEntry) = CopyToStream(entryName); + (Stream? ms, string? realEntry) = CopyToStream(entryName); - // If the memory stream and the entry name are both non-null, we write to file + // If the stream and the entry name are both non-null, we write to file if (ms != null && realEntry != null) { realEntry = Path.Combine(outDir, realEntry); @@ -134,10 +134,10 @@ namespace SabreTools.FileTypes.Archives } /// - public override (MemoryStream?, string?) CopyToStream(string entryName) + public override (Stream?, string?) CopyToStream(string entryName) { #if NET462_OR_GREATER || NETCOREAPP - MemoryStream? ms = new(); + var ms = new MemoryStream(); string? realEntry = null; // If we have an invalid file diff --git a/SabreTools.FileTypes/Archives/SevenZipArchive.cs b/SabreTools.FileTypes/Archives/SevenZipArchive.cs index 705f9eb2..f60dddb6 100644 --- a/SabreTools.FileTypes/Archives/SevenZipArchive.cs +++ b/SabreTools.FileTypes/Archives/SevenZipArchive.cs @@ -183,9 +183,9 @@ namespace SabreTools.FileTypes.Archives public override string? CopyToFile(string entryName, string outDir) { // Try to extract a stream using the given information - (MemoryStream? ms, string? realEntry) = CopyToStream(entryName); + (Stream? ms, string? realEntry) = CopyToStream(entryName); - // If the memory stream and the entry name are both non-null, we write to file + // If the stream and the entry name are both non-null, we write to file if (ms != null && realEntry != null) { realEntry = Path.Combine(outDir, realEntry); @@ -221,9 +221,9 @@ namespace SabreTools.FileTypes.Archives } /// - public override (MemoryStream?, string?) CopyToStream(string entryName) + public override (Stream?, string?) CopyToStream(string entryName) { - MemoryStream? ms = new(); + var ms = new MemoryStream(); string? realEntry = null; // If we have an invalid file diff --git a/SabreTools.FileTypes/Archives/TapeArchive.cs b/SabreTools.FileTypes/Archives/TapeArchive.cs index 2d6eefd9..5082bc64 100644 --- a/SabreTools.FileTypes/Archives/TapeArchive.cs +++ b/SabreTools.FileTypes/Archives/TapeArchive.cs @@ -97,9 +97,9 @@ namespace SabreTools.FileTypes.Archives public override string? CopyToFile(string entryName, string outDir) { // Try to extract a stream using the given information - (MemoryStream? ms, string? realEntry) = CopyToStream(entryName); + (Stream? ms, string? realEntry) = CopyToStream(entryName); - // If the memory stream and the entry name are both non-null, we write to file + // If the stream and the entry name are both non-null, we write to file if (ms != null && realEntry != null) { realEntry = Path.Combine(outDir, realEntry); @@ -135,10 +135,10 @@ namespace SabreTools.FileTypes.Archives } /// - public override (MemoryStream?, string?) CopyToStream(string entryName) + public override (Stream?, string?) CopyToStream(string entryName) { #if NET462_OR_GREATER || NETCOREAPP - MemoryStream? ms = new(); + var ms = new MemoryStream(); string? realEntry = null; try diff --git a/SabreTools.FileTypes/Archives/XZArchive.cs b/SabreTools.FileTypes/Archives/XZArchive.cs index d1115cd2..550140e5 100644 --- a/SabreTools.FileTypes/Archives/XZArchive.cs +++ b/SabreTools.FileTypes/Archives/XZArchive.cs @@ -114,9 +114,9 @@ namespace SabreTools.FileTypes.Archives public override string? CopyToFile(string entryName, string outDir) { // Try to extract a stream using the given information - (MemoryStream? ms, string? realEntry) = CopyToStream(entryName); + (Stream? ms, string? realEntry) = CopyToStream(entryName); - // If the memory stream and the entry name are both non-null, we write to file + // If the stream and the entry name are both non-null, we write to file if (ms != null && realEntry != null) { realEntry = Path.Combine(outDir, realEntry); @@ -152,10 +152,10 @@ namespace SabreTools.FileTypes.Archives } /// - public override (MemoryStream?, string?) CopyToStream(string entryName) + public override (Stream?, string?) CopyToStream(string entryName) { #if NET462_OR_GREATER || NETCOREAPP - MemoryStream? ms = new(); + var ms = new MemoryStream(); string? realEntry; try diff --git a/SabreTools.FileTypes/Archives/ZPAQArchive.cs b/SabreTools.FileTypes/Archives/ZPAQArchive.cs index a7ac4502..cb958663 100644 --- a/SabreTools.FileTypes/Archives/ZPAQArchive.cs +++ b/SabreTools.FileTypes/Archives/ZPAQArchive.cs @@ -49,7 +49,7 @@ namespace SabreTools.FileTypes.Archives } /// - public override (MemoryStream, string) CopyToStream(string entryName) + public override (Stream?, string?) CopyToStream(string entryName) { throw new NotImplementedException(); } diff --git a/SabreTools.FileTypes/Archives/ZipArchive.cs b/SabreTools.FileTypes/Archives/ZipArchive.cs index 3cea1a26..776d1d9c 100644 --- a/SabreTools.FileTypes/Archives/ZipArchive.cs +++ b/SabreTools.FileTypes/Archives/ZipArchive.cs @@ -158,9 +158,9 @@ namespace SabreTools.FileTypes.Archives public override string? CopyToFile(string entryName, string outDir) { // Try to extract a stream using the given information - (MemoryStream? ms, string? realEntry) = CopyToStream(entryName); + (Stream? ms, string? realEntry) = CopyToStream(entryName); - // If the memory stream and the entry name are both non-null, we write to file + // If the stream and the entry name are both non-null, we write to file if (ms != null && realEntry != null) { realEntry = Path.Combine(outDir, realEntry); @@ -196,9 +196,9 @@ namespace SabreTools.FileTypes.Archives } /// - public override (MemoryStream?, string?) CopyToStream(string entryName) + public override (Stream?, string?) CopyToStream(string entryName) { - MemoryStream? ms = new(); + var ms = new MemoryStream(); string? realEntry = null; try diff --git a/SabreTools.FileTypes/Archives/ZstdArchive.cs b/SabreTools.FileTypes/Archives/ZstdArchive.cs index a123264b..468e6079 100644 --- a/SabreTools.FileTypes/Archives/ZstdArchive.cs +++ b/SabreTools.FileTypes/Archives/ZstdArchive.cs @@ -49,7 +49,7 @@ namespace SabreTools.FileTypes.Archives } /// - public override (MemoryStream, string) CopyToStream(string entryName) + public override (Stream?, string?) CopyToStream(string entryName) { throw new NotImplementedException(); } diff --git a/SabreTools.FileTypes/BaseArchive.cs b/SabreTools.FileTypes/BaseArchive.cs index 9f34bcfe..2df1ece4 100644 --- a/SabreTools.FileTypes/BaseArchive.cs +++ b/SabreTools.FileTypes/BaseArchive.cs @@ -121,7 +121,7 @@ namespace SabreTools.FileTypes public override abstract string? CopyToFile(string entryName, string outDir); /// - public override abstract (MemoryStream?, string?) CopyToStream(string entryName); + public override abstract (Stream?, string?) CopyToStream(string entryName); #endregion diff --git a/SabreTools.FileTypes/Folder.cs b/SabreTools.FileTypes/Folder.cs index b227ad67..544d13ae 100644 --- a/SabreTools.FileTypes/Folder.cs +++ b/SabreTools.FileTypes/Folder.cs @@ -210,9 +210,9 @@ namespace SabreTools.FileTypes /// /// Name of the entry to be extracted /// MemoryStream representing the entry, null on error - public virtual (MemoryStream?, string?) CopyToStream(string entryName) + public virtual (Stream?, string?) CopyToStream(string entryName) { - MemoryStream ms = new(); + var ms = new MemoryStream(); string? realentry = null; // If we have an invalid filename