Skip to content

Commit 38b6427

Browse files
committed
Wire through include debug flag
1 parent e36822a commit 38b6427

File tree

16 files changed

+118
-60
lines changed

16 files changed

+118
-60
lines changed

SabreTools.Serialization/Wrappers/BFPK.cs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.IO;
1+
using System;
2+
using System.IO;
23
using SabreTools.IO.Compression.Deflate;
34
using SabreTools.Models.BFPK;
45

@@ -90,8 +91,9 @@ public BFPK(Archive? model, Stream? data)
9091
/// Extract all files from the BFPK to an output directory
9192
/// </summary>
9293
/// <param name="outputDirectory">Output directory to write to</param>
94+
/// <param name="includeDebug">True to include debug data, false otherwise</param>
9395
/// <returns>True if all files extracted, false otherwise</returns>
94-
public bool ExtractAll(string outputDirectory)
96+
public bool ExtractAll(string outputDirectory, bool includeDebug)
9597
{
9698
// If we have no files
9799
if (Files == null || Files.Length == 0)
@@ -101,7 +103,7 @@ public bool ExtractAll(string outputDirectory)
101103
bool allExtracted = true;
102104
for (int i = 0; i < Files.Length; i++)
103105
{
104-
allExtracted &= ExtractFile(i, outputDirectory);
106+
allExtracted &= ExtractFile(i, outputDirectory, includeDebug);
105107
}
106108

107109
return allExtracted;
@@ -112,8 +114,9 @@ public bool ExtractAll(string outputDirectory)
112114
/// </summary>
113115
/// <param name="index">File index to extract</param>
114116
/// <param name="outputDirectory">Output directory to write to</param>
117+
/// <param name="includeDebug">True to include debug data, false otherwise</param>
115118
/// <returns>True if the file extracted, false otherwise</returns>
116-
public bool ExtractFile(int index, string outputDirectory)
119+
public bool ExtractFile(int index, string outputDirectory, bool includeDebug)
117120
{
118121
// If we have no files
119122
if (Files == null || Files.Length == 0)
@@ -181,8 +184,9 @@ public bool ExtractFile(int index, string outputDirectory)
181184
fs.Flush();
182185
}
183186
}
184-
catch
187+
catch (Exception ex)
185188
{
189+
if (includeDebug) Console.WriteLine(ex);
186190
return false;
187191
}
188192

SabreTools.Serialization/Wrappers/BSP.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System;
12
using System.IO;
23
using SabreTools.Models.BSP;
34

@@ -89,8 +90,9 @@ public BSP(BspFile? model, Stream? data)
8990
/// Extract all lumps from the BSP to an output directory
9091
/// </summary>
9192
/// <param name="outputDirectory">Output directory to write to</param>
93+
/// <param name="includeDebug">True to include debug data, false otherwise</param>
9294
/// <returns>True if all lumps extracted, false otherwise</returns>
93-
public bool ExtractAllLumps(string outputDirectory)
95+
public bool ExtractAllLumps(string outputDirectory, bool includeDebug)
9496
{
9597
// If we have no lumps
9698
if (Lumps == null || Lumps.Length == 0)
@@ -100,7 +102,7 @@ public bool ExtractAllLumps(string outputDirectory)
100102
bool allExtracted = true;
101103
for (int i = 0; i < Lumps.Length; i++)
102104
{
103-
allExtracted &= ExtractLump(i, outputDirectory);
105+
allExtracted &= ExtractLump(i, outputDirectory, includeDebug);
104106
}
105107

106108
return allExtracted;
@@ -111,8 +113,9 @@ public bool ExtractAllLumps(string outputDirectory)
111113
/// </summary>
112114
/// <param name="index">Lump index to extract</param>
113115
/// <param name="outputDirectory">Output directory to write to</param>
116+
/// <param name="includeDebug">True to include debug data, false otherwise</param>
114117
/// <returns>True if the lump extracted, false otherwise</returns>
115-
public bool ExtractLump(int index, string outputDirectory)
118+
public bool ExtractLump(int index, string outputDirectory, bool includeDebug)
116119
{
117120
// If we have no lumps
118121
if (Lumps == null || Lumps.Length == 0)
@@ -164,8 +167,9 @@ public bool ExtractLump(int index, string outputDirectory)
164167
fs.Write(data, 0, data.Length);
165168
fs.Flush();
166169
}
167-
catch
170+
catch (Exception ex)
168171
{
172+
if (includeDebug) Console.WriteLine(ex);
169173
return false;
170174
}
171175

SabreTools.Serialization/Wrappers/CFB.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,9 @@ public CFB(Binary? model, Stream? data)
137137
/// Extract all files from the CFB to an output directory
138138
/// </summary>
139139
/// <param name="outputDirectory">Output directory to write to</param>
140+
/// <param name="includeDebug">True to include debug data, false otherwise</param>
140141
/// <returns>True if all files extracted, false otherwise</returns>
141-
public bool ExtractAll(string outputDirectory)
142+
public bool ExtractAll(string outputDirectory, bool includeDebug)
142143
{
143144
// If we have no files
144145
if (DirectoryEntries == null || DirectoryEntries.Length == 0)
@@ -148,7 +149,7 @@ public bool ExtractAll(string outputDirectory)
148149
bool allExtracted = true;
149150
for (int i = 0; i < DirectoryEntries.Length; i++)
150151
{
151-
allExtracted &= ExtractEntry(i, outputDirectory);
152+
allExtracted &= ExtractEntry(i, outputDirectory, includeDebug);
152153
}
153154

154155
return allExtracted;
@@ -159,8 +160,9 @@ public bool ExtractAll(string outputDirectory)
159160
/// </summary>
160161
/// <param name="index">Entry index to extract</param>
161162
/// <param name="outputDirectory">Output directory to write to</param>
163+
/// <param name="includeDebug">True to include debug data, false otherwise</param>
162164
/// <returns>True if the file extracted, false otherwise</returns>
163-
public bool ExtractEntry(int index, string outputDirectory)
165+
public bool ExtractEntry(int index, string outputDirectory, bool includeDebug)
164166
{
165167
// If we have no entries
166168
if (DirectoryEntries == null || DirectoryEntries.Length == 0)
@@ -219,8 +221,9 @@ public bool ExtractEntry(int index, string outputDirectory)
219221
fs.Write(data);
220222
fs.Flush();
221223
}
222-
catch
224+
catch (Exception ex)
223225
{
226+
if (includeDebug) Console.WriteLine(ex);
224227
return false;
225228
}
226229

SabreTools.Serialization/Wrappers/GCF.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,9 @@ public GCF(Models.GCF.File? model, Stream? data)
232232
/// Extract all files from the GCF to an output directory
233233
/// </summary>
234234
/// <param name="outputDirectory">Output directory to write to</param>
235+
/// <param name="includeDebug">True to include debug data, false otherwise</param>
235236
/// <returns>True if all files extracted, false otherwise</returns>
236-
public bool ExtractAll(string outputDirectory)
237+
public bool ExtractAll(string outputDirectory, bool includeDebug)
237238
{
238239
// If we have no files
239240
if (Files == null || Files.Length == 0)
@@ -243,7 +244,7 @@ public bool ExtractAll(string outputDirectory)
243244
bool allExtracted = true;
244245
for (int i = 0; i < Files.Length; i++)
245246
{
246-
allExtracted &= ExtractFile(i, outputDirectory);
247+
allExtracted &= ExtractFile(i, outputDirectory, includeDebug);
247248
}
248249

249250
return allExtracted;
@@ -254,8 +255,9 @@ public bool ExtractAll(string outputDirectory)
254255
/// </summary>
255256
/// <param name="index">File index to extract</param>
256257
/// <param name="outputDirectory">Output directory to write to</param>
258+
/// <param name="includeDebug">True to include debug data, false otherwise</param>
257259
/// <returns>True if the file extracted, false otherwise</returns>
258-
public bool ExtractFile(int index, string outputDirectory)
260+
public bool ExtractFile(int index, string outputDirectory, bool includeDebug)
259261
{
260262
// If we have no files
261263
if (Files == null || Files.Length == 0 || DataBlockOffsets == null)
@@ -326,8 +328,9 @@ public bool ExtractFile(int index, string outputDirectory)
326328
fs.Flush();
327329
}
328330
}
329-
catch
331+
catch (Exception ex)
330332
{
333+
if (includeDebug) Console.WriteLine(ex);
331334
return false;
332335
}
333336

SabreTools.Serialization/Wrappers/InstallShieldArchiveV3.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System;
12
using System.Collections.Generic;
23
using System.IO;
34
using SabreTools.IO.Compression.Blast;
@@ -176,8 +177,9 @@ public InstallShieldArchiveV3(Archive? model, Stream? data)
176177
/// Extract all files from the ISAv3 to an output directory
177178
/// </summary>
178179
/// <param name="outputDirectory">Output directory to write to</param>
180+
/// <param name="includeDebug">True to include debug data, false otherwise</param>
179181
/// <returns>True if all files extracted, false otherwise</returns>
180-
public bool ExtractAll(string outputDirectory)
182+
public bool ExtractAll(string outputDirectory, bool includeDebug)
181183
{
182184
// Get the file count
183185
int fileCount = Files.Length;
@@ -188,7 +190,7 @@ public bool ExtractAll(string outputDirectory)
188190
bool allExtracted = true;
189191
for (int i = 0; i < fileCount; i++)
190192
{
191-
allExtracted &= ExtractFile(i, outputDirectory);
193+
allExtracted &= ExtractFile(i, outputDirectory, includeDebug);
192194
}
193195

194196
return allExtracted;
@@ -199,8 +201,9 @@ public bool ExtractAll(string outputDirectory)
199201
/// </summary>
200202
/// <param name="index">File index to extract</param>
201203
/// <param name="outputDirectory">Output directory to write to</param>
204+
/// <param name="includeDebug">True to include debug data, false otherwise</param>
202205
/// <returns>True if the file extracted, false otherwise</returns>
203-
public bool ExtractFile(int index, string outputDirectory)
206+
public bool ExtractFile(int index, string outputDirectory, bool includeDebug)
204207
{
205208
// If the files index is invalid
206209
if (index < 0 || index >= FileCount)
@@ -279,8 +282,9 @@ public bool ExtractFile(int index, string outputDirectory)
279282
fs.Write(data, 0, data.Length);
280283
fs.Flush();
281284
}
282-
catch
285+
catch (Exception ex)
283286
{
287+
if (includeDebug) Console.WriteLine(ex);
284288
return false;
285289
}
286290

SabreTools.Serialization/Wrappers/LZKWAJ.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System;
12
using System.IO;
23
using SabreTools.IO.Compression.SZDD;
34
using SabreTools.Models.LZ;
@@ -99,8 +100,9 @@ public LZKWAJ(KWAJFile? model, Stream? data)
99100
/// Extract the contents to an output directory
100101
/// </summary>
101102
/// <param name="outputDirectory">Output directory to write to</param>
103+
/// <param name="includeDebug">True to include debug data, false otherwise</param>
102104
/// <returns>True if the contents extracted, false otherwise</returns>
103-
public bool Extract(string outputDirectory)
105+
public bool Extract(string outputDirectory, bool includeDebug)
104106
{
105107
// Get the length of the compressed data
106108
long compressedSize = Length - DataOffset;
@@ -146,8 +148,9 @@ public bool Extract(string outputDirectory)
146148
decompressor.CopyTo(fs);
147149
fs.Flush();
148150
}
149-
catch
151+
catch (Exception ex)
150152
{
153+
if (includeDebug) Console.WriteLine(ex);
151154
return false;
152155
}
153156

SabreTools.Serialization/Wrappers/LZQBasic.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System;
12
using System.IO;
23
using SabreTools.IO.Compression.SZDD;
34
using SabreTools.Models.LZ;
@@ -82,10 +83,10 @@ public LZQBasic(QBasicFile? model, Stream? data)
8283
/// <summary>
8384
/// Extract the contents to an output directory
8485
/// </summary>
85-
/// <param name="filename">Original filename to use as a base</param>
8686
/// <param name="outputDirectory">Output directory to write to</param>
87+
/// <param name="includeDebug">True to include debug data, false otherwise</param>
8788
/// <returns>True if the contents extracted, false otherwise</returns>
88-
public bool Extract(string outputDirectory)
89+
public bool Extract(string outputDirectory, bool includeDebug)
8990
{
9091
// Get the length of the compressed data
9192
long compressedSize = Length - 12;
@@ -127,8 +128,9 @@ public bool Extract(string outputDirectory)
127128
decompressor.CopyTo(fs);
128129
fs.Flush();
129130
}
130-
catch
131+
catch (Exception ex)
131132
{
133+
if (includeDebug) Console.WriteLine(ex);
132134
return false;
133135
}
134136

SabreTools.Serialization/Wrappers/LZSZDD.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System;
12
using System.IO;
23
using SabreTools.IO.Compression.SZDD;
34
using SabreTools.Models.LZ;
@@ -91,8 +92,9 @@ public LZSZDD(SZDDFile? model, Stream? data)
9192
/// </summary>
9293
/// <param name="filename">Original filename to use as a base</param>
9394
/// <param name="outputDirectory">Output directory to write to</param>
95+
/// <param name="includeDebug">True to include debug data, false otherwise</param>
9496
/// <returns>True if the contents extracted, false otherwise</returns>
95-
public bool Extract(string filename, string outputDirectory)
97+
public bool Extract(string filename, string outputDirectory, bool includeDebug)
9698
{
9799
// Get the length of the compressed data
98100
long compressedSize = Length - 14;
@@ -136,8 +138,9 @@ public bool Extract(string filename, string outputDirectory)
136138
decompressor.CopyTo(fs);
137139
fs.Flush();
138140
}
139-
catch
141+
catch (Exception ex)
140142
{
143+
if (includeDebug) Console.WriteLine(ex);
141144
return false;
142145
}
143146

SabreTools.Serialization/Wrappers/PAK.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System;
12
using System.IO;
23
using SabreTools.Models.PAK;
34

@@ -89,8 +90,9 @@ public PAK(Models.PAK.File? model, Stream? data)
8990
/// Extract all files from the PAK to an output directory
9091
/// </summary>
9192
/// <param name="outputDirectory">Output directory to write to</param>
93+
/// <param name="includeDebug">True to include debug data, false otherwise</param>
9294
/// <returns>True if all files extracted, false otherwise</returns>
93-
public bool ExtractAll(string outputDirectory)
95+
public bool ExtractAll(string outputDirectory, bool includeDebug)
9496
{
9597
// If we have no directory items
9698
if (DirectoryItems == null || DirectoryItems.Length == 0)
@@ -100,7 +102,7 @@ public bool ExtractAll(string outputDirectory)
100102
bool allExtracted = true;
101103
for (int i = 0; i < DirectoryItems.Length; i++)
102104
{
103-
allExtracted &= ExtractFile(i, outputDirectory);
105+
allExtracted &= ExtractFile(i, outputDirectory, includeDebug);
104106
}
105107

106108
return allExtracted;
@@ -111,8 +113,9 @@ public bool ExtractAll(string outputDirectory)
111113
/// </summary>
112114
/// <param name="index">File index to extract</param>
113115
/// <param name="outputDirectory">Output directory to write to</param>
116+
/// <param name="includeDebug">True to include debug data, false otherwise</param>
114117
/// <returns>True if the file extracted, false otherwise</returns>
115-
public bool ExtractFile(int index, string outputDirectory)
118+
public bool ExtractFile(int index, string outputDirectory, bool includeDebug)
116119
{
117120
// If we have no directory items
118121
if (DirectoryItems == null || DirectoryItems.Length == 0)
@@ -153,8 +156,9 @@ public bool ExtractFile(int index, string outputDirectory)
153156
fs.Write(data, 0, data.Length);
154157
fs.Flush();
155158
}
156-
catch
159+
catch (Exception ex)
157160
{
161+
if (includeDebug) Console.WriteLine(ex);
158162
return false;
159163
}
160164

0 commit comments

Comments
 (0)