From 38b6427e4e0c9130da2a8d4ed629f6ee3af825b2 Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Thu, 31 Jul 2025 09:11:43 -0400 Subject: [PATCH] Wire through include debug flag --- SabreTools.Serialization/Wrappers/BFPK.cs | 14 +++++++++----- SabreTools.Serialization/Wrappers/BSP.cs | 12 ++++++++---- SabreTools.Serialization/Wrappers/CFB.cs | 11 +++++++---- SabreTools.Serialization/Wrappers/GCF.cs | 11 +++++++---- .../Wrappers/InstallShieldArchiveV3.cs | 12 ++++++++---- SabreTools.Serialization/Wrappers/LZKWAJ.cs | 7 +++++-- SabreTools.Serialization/Wrappers/LZQBasic.cs | 8 +++++--- SabreTools.Serialization/Wrappers/LZSZDD.cs | 7 +++++-- SabreTools.Serialization/Wrappers/PAK.cs | 12 ++++++++---- SabreTools.Serialization/Wrappers/PFF.cs | 12 ++++++++---- SabreTools.Serialization/Wrappers/Quantum.cs | 12 +++++++++--- SabreTools.Serialization/Wrappers/SGA.cs | 11 +++++++---- SabreTools.Serialization/Wrappers/VBSP.cs | 12 ++++++++---- SabreTools.Serialization/Wrappers/VPK.cs | 14 +++++++++----- SabreTools.Serialization/Wrappers/WAD3.cs | 12 ++++++++---- SabreTools.Serialization/Wrappers/XZP.cs | 11 +++++++---- 16 files changed, 118 insertions(+), 60 deletions(-) diff --git a/SabreTools.Serialization/Wrappers/BFPK.cs b/SabreTools.Serialization/Wrappers/BFPK.cs index 096722f5..74049529 100644 --- a/SabreTools.Serialization/Wrappers/BFPK.cs +++ b/SabreTools.Serialization/Wrappers/BFPK.cs @@ -1,4 +1,5 @@ -using System.IO; +using System; +using System.IO; using SabreTools.IO.Compression.Deflate; using SabreTools.Models.BFPK; @@ -90,8 +91,9 @@ namespace SabreTools.Serialization.Wrappers /// Extract all files from the BFPK to an output directory /// /// Output directory to write to + /// True to include debug data, false otherwise /// True if all files extracted, false otherwise - public bool ExtractAll(string outputDirectory) + public bool ExtractAll(string outputDirectory, bool includeDebug) { // If we have no files if (Files == null || Files.Length == 0) @@ -101,7 +103,7 @@ namespace SabreTools.Serialization.Wrappers bool allExtracted = true; for (int i = 0; i < Files.Length; i++) { - allExtracted &= ExtractFile(i, outputDirectory); + allExtracted &= ExtractFile(i, outputDirectory, includeDebug); } return allExtracted; @@ -112,8 +114,9 @@ namespace SabreTools.Serialization.Wrappers /// /// File index to extract /// Output directory to write to + /// True to include debug data, false otherwise /// True if the file extracted, false otherwise - public bool ExtractFile(int index, string outputDirectory) + public bool ExtractFile(int index, string outputDirectory, bool includeDebug) { // If we have no files if (Files == null || Files.Length == 0) @@ -181,8 +184,9 @@ namespace SabreTools.Serialization.Wrappers fs.Flush(); } } - catch + catch (Exception ex) { + if (includeDebug) Console.WriteLine(ex); return false; } diff --git a/SabreTools.Serialization/Wrappers/BSP.cs b/SabreTools.Serialization/Wrappers/BSP.cs index 2dacbb1b..d023819f 100644 --- a/SabreTools.Serialization/Wrappers/BSP.cs +++ b/SabreTools.Serialization/Wrappers/BSP.cs @@ -1,3 +1,4 @@ +using System; using System.IO; using SabreTools.Models.BSP; @@ -89,8 +90,9 @@ namespace SabreTools.Serialization.Wrappers /// Extract all lumps from the BSP to an output directory /// /// Output directory to write to + /// True to include debug data, false otherwise /// True if all lumps extracted, false otherwise - public bool ExtractAllLumps(string outputDirectory) + public bool ExtractAllLumps(string outputDirectory, bool includeDebug) { // If we have no lumps if (Lumps == null || Lumps.Length == 0) @@ -100,7 +102,7 @@ namespace SabreTools.Serialization.Wrappers bool allExtracted = true; for (int i = 0; i < Lumps.Length; i++) { - allExtracted &= ExtractLump(i, outputDirectory); + allExtracted &= ExtractLump(i, outputDirectory, includeDebug); } return allExtracted; @@ -111,8 +113,9 @@ namespace SabreTools.Serialization.Wrappers /// /// Lump index to extract /// Output directory to write to + /// True to include debug data, false otherwise /// True if the lump extracted, false otherwise - public bool ExtractLump(int index, string outputDirectory) + public bool ExtractLump(int index, string outputDirectory, bool includeDebug) { // If we have no lumps if (Lumps == null || Lumps.Length == 0) @@ -164,8 +167,9 @@ namespace SabreTools.Serialization.Wrappers fs.Write(data, 0, data.Length); fs.Flush(); } - catch + catch (Exception ex) { + if (includeDebug) Console.WriteLine(ex); return false; } diff --git a/SabreTools.Serialization/Wrappers/CFB.cs b/SabreTools.Serialization/Wrappers/CFB.cs index b47cc79e..c70fc15a 100644 --- a/SabreTools.Serialization/Wrappers/CFB.cs +++ b/SabreTools.Serialization/Wrappers/CFB.cs @@ -137,8 +137,9 @@ namespace SabreTools.Serialization.Wrappers /// Extract all files from the CFB to an output directory /// /// Output directory to write to + /// True to include debug data, false otherwise /// True if all files extracted, false otherwise - public bool ExtractAll(string outputDirectory) + public bool ExtractAll(string outputDirectory, bool includeDebug) { // If we have no files if (DirectoryEntries == null || DirectoryEntries.Length == 0) @@ -148,7 +149,7 @@ namespace SabreTools.Serialization.Wrappers bool allExtracted = true; for (int i = 0; i < DirectoryEntries.Length; i++) { - allExtracted &= ExtractEntry(i, outputDirectory); + allExtracted &= ExtractEntry(i, outputDirectory, includeDebug); } return allExtracted; @@ -159,8 +160,9 @@ namespace SabreTools.Serialization.Wrappers /// /// Entry index to extract /// Output directory to write to + /// True to include debug data, false otherwise /// True if the file extracted, false otherwise - public bool ExtractEntry(int index, string outputDirectory) + public bool ExtractEntry(int index, string outputDirectory, bool includeDebug) { // If we have no entries if (DirectoryEntries == null || DirectoryEntries.Length == 0) @@ -219,8 +221,9 @@ namespace SabreTools.Serialization.Wrappers fs.Write(data); fs.Flush(); } - catch + catch (Exception ex) { + if (includeDebug) Console.WriteLine(ex); return false; } diff --git a/SabreTools.Serialization/Wrappers/GCF.cs b/SabreTools.Serialization/Wrappers/GCF.cs index aec5c662..eb418fed 100644 --- a/SabreTools.Serialization/Wrappers/GCF.cs +++ b/SabreTools.Serialization/Wrappers/GCF.cs @@ -232,8 +232,9 @@ namespace SabreTools.Serialization.Wrappers /// Extract all files from the GCF to an output directory /// /// Output directory to write to + /// True to include debug data, false otherwise /// True if all files extracted, false otherwise - public bool ExtractAll(string outputDirectory) + public bool ExtractAll(string outputDirectory, bool includeDebug) { // If we have no files if (Files == null || Files.Length == 0) @@ -243,7 +244,7 @@ namespace SabreTools.Serialization.Wrappers bool allExtracted = true; for (int i = 0; i < Files.Length; i++) { - allExtracted &= ExtractFile(i, outputDirectory); + allExtracted &= ExtractFile(i, outputDirectory, includeDebug); } return allExtracted; @@ -254,8 +255,9 @@ namespace SabreTools.Serialization.Wrappers /// /// File index to extract /// Output directory to write to + /// True to include debug data, false otherwise /// True if the file extracted, false otherwise - public bool ExtractFile(int index, string outputDirectory) + public bool ExtractFile(int index, string outputDirectory, bool includeDebug) { // If we have no files if (Files == null || Files.Length == 0 || DataBlockOffsets == null) @@ -326,8 +328,9 @@ namespace SabreTools.Serialization.Wrappers fs.Flush(); } } - catch + catch (Exception ex) { + if (includeDebug) Console.WriteLine(ex); return false; } diff --git a/SabreTools.Serialization/Wrappers/InstallShieldArchiveV3.cs b/SabreTools.Serialization/Wrappers/InstallShieldArchiveV3.cs index 35b3ac87..35170eeb 100644 --- a/SabreTools.Serialization/Wrappers/InstallShieldArchiveV3.cs +++ b/SabreTools.Serialization/Wrappers/InstallShieldArchiveV3.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using System.IO; using SabreTools.IO.Compression.Blast; @@ -176,8 +177,9 @@ namespace SabreTools.Serialization.Wrappers /// Extract all files from the ISAv3 to an output directory /// /// Output directory to write to + /// True to include debug data, false otherwise /// True if all files extracted, false otherwise - public bool ExtractAll(string outputDirectory) + public bool ExtractAll(string outputDirectory, bool includeDebug) { // Get the file count int fileCount = Files.Length; @@ -188,7 +190,7 @@ namespace SabreTools.Serialization.Wrappers bool allExtracted = true; for (int i = 0; i < fileCount; i++) { - allExtracted &= ExtractFile(i, outputDirectory); + allExtracted &= ExtractFile(i, outputDirectory, includeDebug); } return allExtracted; @@ -199,8 +201,9 @@ namespace SabreTools.Serialization.Wrappers /// /// File index to extract /// Output directory to write to + /// True to include debug data, false otherwise /// True if the file extracted, false otherwise - public bool ExtractFile(int index, string outputDirectory) + public bool ExtractFile(int index, string outputDirectory, bool includeDebug) { // If the files index is invalid if (index < 0 || index >= FileCount) @@ -279,8 +282,9 @@ namespace SabreTools.Serialization.Wrappers fs.Write(data, 0, data.Length); fs.Flush(); } - catch + catch (Exception ex) { + if (includeDebug) Console.WriteLine(ex); return false; } diff --git a/SabreTools.Serialization/Wrappers/LZKWAJ.cs b/SabreTools.Serialization/Wrappers/LZKWAJ.cs index 81ce0e57..ba135515 100644 --- a/SabreTools.Serialization/Wrappers/LZKWAJ.cs +++ b/SabreTools.Serialization/Wrappers/LZKWAJ.cs @@ -1,3 +1,4 @@ +using System; using System.IO; using SabreTools.IO.Compression.SZDD; using SabreTools.Models.LZ; @@ -99,8 +100,9 @@ namespace SabreTools.Serialization.Wrappers /// Extract the contents to an output directory /// /// Output directory to write to + /// True to include debug data, false otherwise /// True if the contents extracted, false otherwise - public bool Extract(string outputDirectory) + public bool Extract(string outputDirectory, bool includeDebug) { // Get the length of the compressed data long compressedSize = Length - DataOffset; @@ -146,8 +148,9 @@ namespace SabreTools.Serialization.Wrappers decompressor.CopyTo(fs); fs.Flush(); } - catch + catch (Exception ex) { + if (includeDebug) Console.WriteLine(ex); return false; } diff --git a/SabreTools.Serialization/Wrappers/LZQBasic.cs b/SabreTools.Serialization/Wrappers/LZQBasic.cs index 896eac7c..7a3f0ac7 100644 --- a/SabreTools.Serialization/Wrappers/LZQBasic.cs +++ b/SabreTools.Serialization/Wrappers/LZQBasic.cs @@ -1,3 +1,4 @@ +using System; using System.IO; using SabreTools.IO.Compression.SZDD; using SabreTools.Models.LZ; @@ -82,10 +83,10 @@ namespace SabreTools.Serialization.Wrappers /// /// Extract the contents to an output directory /// - /// Original filename to use as a base /// Output directory to write to + /// True to include debug data, false otherwise /// True if the contents extracted, false otherwise - public bool Extract(string outputDirectory) + public bool Extract(string outputDirectory, bool includeDebug) { // Get the length of the compressed data long compressedSize = Length - 12; @@ -127,8 +128,9 @@ namespace SabreTools.Serialization.Wrappers decompressor.CopyTo(fs); fs.Flush(); } - catch + catch (Exception ex) { + if (includeDebug) Console.WriteLine(ex); return false; } diff --git a/SabreTools.Serialization/Wrappers/LZSZDD.cs b/SabreTools.Serialization/Wrappers/LZSZDD.cs index 0c65f2e4..5cdc5336 100644 --- a/SabreTools.Serialization/Wrappers/LZSZDD.cs +++ b/SabreTools.Serialization/Wrappers/LZSZDD.cs @@ -1,3 +1,4 @@ +using System; using System.IO; using SabreTools.IO.Compression.SZDD; using SabreTools.Models.LZ; @@ -91,8 +92,9 @@ namespace SabreTools.Serialization.Wrappers /// /// Original filename to use as a base /// Output directory to write to + /// True to include debug data, false otherwise /// True if the contents extracted, false otherwise - public bool Extract(string filename, string outputDirectory) + public bool Extract(string filename, string outputDirectory, bool includeDebug) { // Get the length of the compressed data long compressedSize = Length - 14; @@ -136,8 +138,9 @@ namespace SabreTools.Serialization.Wrappers decompressor.CopyTo(fs); fs.Flush(); } - catch + catch (Exception ex) { + if (includeDebug) Console.WriteLine(ex); return false; } diff --git a/SabreTools.Serialization/Wrappers/PAK.cs b/SabreTools.Serialization/Wrappers/PAK.cs index 74bc99a6..cd96df6a 100644 --- a/SabreTools.Serialization/Wrappers/PAK.cs +++ b/SabreTools.Serialization/Wrappers/PAK.cs @@ -1,3 +1,4 @@ +using System; using System.IO; using SabreTools.Models.PAK; @@ -89,8 +90,9 @@ namespace SabreTools.Serialization.Wrappers /// Extract all files from the PAK to an output directory /// /// Output directory to write to + /// True to include debug data, false otherwise /// True if all files extracted, false otherwise - public bool ExtractAll(string outputDirectory) + public bool ExtractAll(string outputDirectory, bool includeDebug) { // If we have no directory items if (DirectoryItems == null || DirectoryItems.Length == 0) @@ -100,7 +102,7 @@ namespace SabreTools.Serialization.Wrappers bool allExtracted = true; for (int i = 0; i < DirectoryItems.Length; i++) { - allExtracted &= ExtractFile(i, outputDirectory); + allExtracted &= ExtractFile(i, outputDirectory, includeDebug); } return allExtracted; @@ -111,8 +113,9 @@ namespace SabreTools.Serialization.Wrappers /// /// File index to extract /// Output directory to write to + /// True to include debug data, false otherwise /// True if the file extracted, false otherwise - public bool ExtractFile(int index, string outputDirectory) + public bool ExtractFile(int index, string outputDirectory, bool includeDebug) { // If we have no directory items if (DirectoryItems == null || DirectoryItems.Length == 0) @@ -153,8 +156,9 @@ namespace SabreTools.Serialization.Wrappers fs.Write(data, 0, data.Length); fs.Flush(); } - catch + catch (Exception ex) { + if (includeDebug) Console.WriteLine(ex); return false; } diff --git a/SabreTools.Serialization/Wrappers/PFF.cs b/SabreTools.Serialization/Wrappers/PFF.cs index 0104a9d9..0c9f3201 100644 --- a/SabreTools.Serialization/Wrappers/PFF.cs +++ b/SabreTools.Serialization/Wrappers/PFF.cs @@ -1,3 +1,4 @@ +using System; using System.IO; using SabreTools.Models.PFF; @@ -94,8 +95,9 @@ namespace SabreTools.Serialization.Wrappers /// Extract all segments from the PFF to an output directory /// /// Output directory to write to + /// True to include debug data, false otherwise /// True if all segments extracted, false otherwise - public bool ExtractAll(string outputDirectory) + public bool ExtractAll(string outputDirectory, bool includeDebug) { // If we have no segments if (Segments == null || Segments.Length == 0) @@ -105,7 +107,7 @@ namespace SabreTools.Serialization.Wrappers bool allExtracted = true; for (int i = 0; i < Segments.Length; i++) { - allExtracted &= ExtractSegment(i, outputDirectory); + allExtracted &= ExtractSegment(i, outputDirectory, includeDebug); } return allExtracted; @@ -116,8 +118,9 @@ namespace SabreTools.Serialization.Wrappers /// /// Segment index to extract /// Output directory to write to + /// True to include debug data, false otherwise /// True if the segment extracted, false otherwise - public bool ExtractSegment(int index, string outputDirectory) + public bool ExtractSegment(int index, string outputDirectory, bool includeDebug) { // If we have no files if (FileCount == 0) @@ -165,8 +168,9 @@ namespace SabreTools.Serialization.Wrappers return true; } - catch + catch (Exception ex) { + if (includeDebug) Console.WriteLine(ex); return false; } } diff --git a/SabreTools.Serialization/Wrappers/Quantum.cs b/SabreTools.Serialization/Wrappers/Quantum.cs index 140cb9b2..e9e1015c 100644 --- a/SabreTools.Serialization/Wrappers/Quantum.cs +++ b/SabreTools.Serialization/Wrappers/Quantum.cs @@ -1,3 +1,4 @@ +using System; using System.IO; using SabreTools.Models.Quantum; @@ -98,8 +99,9 @@ namespace SabreTools.Serialization.Wrappers /// Extract all files from the Quantum archive to an output directory /// /// Output directory to write to + /// True to include debug data, false otherwise /// True if all files extracted, false otherwise - public bool ExtractAll(string outputDirectory) + public bool ExtractAll(string outputDirectory, bool includeDebug) { // If we have no files if (FileList == null || FileList.Length == 0) @@ -109,7 +111,7 @@ namespace SabreTools.Serialization.Wrappers bool allExtracted = true; for (int i = 0; i < FileList.Length; i++) { - allExtracted &= ExtractFile(i, outputDirectory); + allExtracted &= ExtractFile(i, outputDirectory, includeDebug); } return allExtracted; @@ -120,8 +122,9 @@ namespace SabreTools.Serialization.Wrappers /// /// File index to extract /// Output directory to write to + /// True to include debug data, false otherwise /// True if the file extracted, false otherwise - public bool ExtractFile(int index, string outputDirectory) + public bool ExtractFile(int index, string outputDirectory, bool includeDebug) { // If we have no files if (Header == null || FileCount == 0 || FileList == null || FileList.Length == 0) @@ -139,6 +142,9 @@ namespace SabreTools.Serialization.Wrappers int compressedDataLength = GetEndOfFile() - compressedDataOffset; var compressedData = ReadFromDataSource(compressedDataOffset, compressedDataLength); + // Print a debug reminder + if (includeDebug) Console.WriteLine("Quantum archive extraction is unsupported"); + // TODO: Figure out decompression // - Single-file archives seem to work // - Single-file archives with files that span a window boundary seem to work diff --git a/SabreTools.Serialization/Wrappers/SGA.cs b/SabreTools.Serialization/Wrappers/SGA.cs index ccaad245..b31602db 100644 --- a/SabreTools.Serialization/Wrappers/SGA.cs +++ b/SabreTools.Serialization/Wrappers/SGA.cs @@ -128,8 +128,9 @@ namespace SabreTools.Serialization.Wrappers /// Extract all files from the SGA to an output directory /// /// Output directory to write to + /// True to include debug data, false otherwise /// True if all files extracted, false otherwise - public bool ExtractAll(string outputDirectory) + public bool ExtractAll(string outputDirectory, bool includeDebug) { // Get the file count int fileCount = FileCount; @@ -140,7 +141,7 @@ namespace SabreTools.Serialization.Wrappers bool allExtracted = true; for (int i = 0; i < fileCount; i++) { - allExtracted &= ExtractFile(i, outputDirectory); + allExtracted &= ExtractFile(i, outputDirectory, includeDebug); } return allExtracted; @@ -151,8 +152,9 @@ namespace SabreTools.Serialization.Wrappers /// /// File index to extract /// Output directory to write to + /// True to include debug data, false otherwise /// True if the file extracted, false otherwise - public bool ExtractFile(int index, string outputDirectory) + public bool ExtractFile(int index, string outputDirectory, bool includeDebug) { // Get the file count int fileCount = FileCount; @@ -259,8 +261,9 @@ namespace SabreTools.Serialization.Wrappers fs.Write(data, 0, data.Length); fs.Flush(); } - catch + catch (Exception ex) { + if (includeDebug) Console.WriteLine(ex); return false; } diff --git a/SabreTools.Serialization/Wrappers/VBSP.cs b/SabreTools.Serialization/Wrappers/VBSP.cs index dd316866..8c8873a1 100644 --- a/SabreTools.Serialization/Wrappers/VBSP.cs +++ b/SabreTools.Serialization/Wrappers/VBSP.cs @@ -1,3 +1,4 @@ +using System; using System.IO; using SabreTools.Models.BSP; @@ -89,8 +90,9 @@ namespace SabreTools.Serialization.Wrappers /// Extract all lumps from the VBSP to an output directory /// /// Output directory to write to + /// True to include debug data, false otherwise /// True if all lumps extracted, false otherwise - public bool ExtractAllLumps(string outputDirectory) + public bool ExtractAllLumps(string outputDirectory, bool includeDebug) { // If we have no lumps if (Lumps == null || Lumps.Length == 0) @@ -100,7 +102,7 @@ namespace SabreTools.Serialization.Wrappers bool allExtracted = true; for (int i = 0; i < Lumps.Length; i++) { - allExtracted &= ExtractLump(i, outputDirectory); + allExtracted &= ExtractLump(i, outputDirectory, includeDebug); } return allExtracted; @@ -111,8 +113,9 @@ namespace SabreTools.Serialization.Wrappers /// /// Lump index to extract /// Output directory to write to + /// True to include debug data, false otherwise /// True if the lump extracted, false otherwise - public bool ExtractLump(int index, string outputDirectory) + public bool ExtractLump(int index, string outputDirectory, bool includeDebug) { // If we have no lumps if (Lumps == null || Lumps.Length == 0) @@ -164,8 +167,9 @@ namespace SabreTools.Serialization.Wrappers fs.Write(data, 0, data.Length); fs.Flush(); } - catch + catch (Exception ex) { + if (includeDebug) Console.WriteLine(ex); return false; } diff --git a/SabreTools.Serialization/Wrappers/VPK.cs b/SabreTools.Serialization/Wrappers/VPK.cs index cf1b6efe..8e4273bf 100644 --- a/SabreTools.Serialization/Wrappers/VPK.cs +++ b/SabreTools.Serialization/Wrappers/VPK.cs @@ -155,8 +155,9 @@ namespace SabreTools.Serialization.Wrappers /// Extract all files from the VPK to an output directory /// /// Output directory to write to + /// True to include debug data, false otherwise /// True if all files extracted, false otherwise - public bool ExtractAll(string outputDirectory) + public bool ExtractAll(string outputDirectory, bool includeDebug) { // If we have no directory items if (DirectoryItems == null || DirectoryItems.Length == 0) @@ -166,7 +167,7 @@ namespace SabreTools.Serialization.Wrappers bool allExtracted = true; for (int i = 0; i < DirectoryItems.Length; i++) { - allExtracted &= ExtractFile(i, outputDirectory); + allExtracted &= ExtractFile(i, outputDirectory, includeDebug); } return allExtracted; @@ -177,8 +178,9 @@ namespace SabreTools.Serialization.Wrappers /// /// File index to extract /// Output directory to write to + /// True to include debug data, false otherwise /// True if the file extracted, false otherwise - public bool ExtractFile(int index, string outputDirectory) + public bool ExtractFile(int index, string outputDirectory, bool includeDebug) { // If we have no directory items if (DirectoryItems == null || DirectoryItems.Length == 0) @@ -234,8 +236,9 @@ namespace SabreTools.Serialization.Wrappers // Read the directory item bytes data = archiveStream.ReadBytes((int)directoryItem.DirectoryEntry.EntryLength); } - catch + catch (Exception ex) { + if (includeDebug) Console.WriteLine(ex); return false; } finally @@ -279,8 +282,9 @@ namespace SabreTools.Serialization.Wrappers fs.Write(data, 0, data.Length); fs.Flush(); } - catch + catch (Exception ex) { + if (includeDebug) Console.WriteLine(ex); return false; } diff --git a/SabreTools.Serialization/Wrappers/WAD3.cs b/SabreTools.Serialization/Wrappers/WAD3.cs index fc90fe85..cf04731d 100644 --- a/SabreTools.Serialization/Wrappers/WAD3.cs +++ b/SabreTools.Serialization/Wrappers/WAD3.cs @@ -1,3 +1,4 @@ +using System; using System.IO; namespace SabreTools.Serialization.Wrappers @@ -88,8 +89,9 @@ namespace SabreTools.Serialization.Wrappers /// Extract all lumps from the WAD3 to an output directory /// /// Output directory to write to + /// True to include debug data, false otherwise /// True if all lumps extracted, false otherwise - public bool ExtractAllLumps(string outputDirectory) + public bool ExtractAllLumps(string outputDirectory, bool includeDebug) { // If we have no lumps if (DirEntries == null || DirEntries.Length == 0) @@ -99,7 +101,7 @@ namespace SabreTools.Serialization.Wrappers bool allExtracted = true; for (int i = 0; i < DirEntries.Length; i++) { - allExtracted &= ExtractLump(i, outputDirectory); + allExtracted &= ExtractLump(i, outputDirectory, includeDebug); } return allExtracted; @@ -110,8 +112,9 @@ namespace SabreTools.Serialization.Wrappers /// /// Lump index to extract /// Output directory to write to + /// True to include debug data, false otherwise /// True if the lump extracted, false otherwise - public bool ExtractLump(int index, string outputDirectory) + public bool ExtractLump(int index, string outputDirectory, bool includeDebug) { // If we have no lumps if (DirEntries == null || DirEntries.Length == 0) @@ -152,8 +155,9 @@ namespace SabreTools.Serialization.Wrappers fs.Write(data, 0, data.Length); fs.Flush(); } - catch + catch (Exception ex) { + if (includeDebug) Console.WriteLine(ex); return false; } diff --git a/SabreTools.Serialization/Wrappers/XZP.cs b/SabreTools.Serialization/Wrappers/XZP.cs index b58409b5..a3c5fcb9 100644 --- a/SabreTools.Serialization/Wrappers/XZP.cs +++ b/SabreTools.Serialization/Wrappers/XZP.cs @@ -92,8 +92,9 @@ namespace SabreTools.Serialization.Wrappers /// Extract all files from the XZP to an output directory /// /// Output directory to write to + /// True to include debug data, false otherwise /// True if all files extracted, false otherwise - public bool ExtractAll(string outputDirectory) + public bool ExtractAll(string outputDirectory, bool includeDebug) { // If we have no directory entries if (DirectoryEntries == null || DirectoryEntries.Length == 0) @@ -103,7 +104,7 @@ namespace SabreTools.Serialization.Wrappers bool allExtracted = true; for (int i = 0; i < DirectoryEntries.Length; i++) { - allExtracted &= ExtractFile(i, outputDirectory); + allExtracted &= ExtractFile(i, outputDirectory, includeDebug); } return allExtracted; @@ -114,8 +115,9 @@ namespace SabreTools.Serialization.Wrappers /// /// File index to extract /// Output directory to write to + /// True to include debug data, false otherwise /// True if the file extracted, false otherwise - public bool ExtractFile(int index, string outputDirectory) + public bool ExtractFile(int index, string outputDirectory, bool includeDebug) { // If we have no directory entries if (DirectoryEntries == null || DirectoryEntries.Length == 0) @@ -165,8 +167,9 @@ namespace SabreTools.Serialization.Wrappers fs.Write(data, 0, data.Length); fs.Flush(); } - catch + catch (Exception ex) { + if (includeDebug) Console.WriteLine(ex); return false; }