Skip to content

Commit 6613f82

Browse files
Finished work for now.
1 parent 109c746 commit 6613f82

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

SabreTools.Serialization/Wrappers/MicrosoftCabinet.Extraction.cs

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Collections.Generic;
23
using System.IO;
34
using SabreTools.Data.Models.MicrosoftCabinet;
45
using SabreTools.IO.Extensions;
@@ -189,6 +190,9 @@ public bool Extract(string outputDirectory, bool includeDebug)
189190
}
190191
cabinet = cabinet.Next;
191192
cabinet?.Prev = null;
193+
194+
// TODO: already-extracted data isn't being cleared from memory, at least not nearly enough.
195+
192196
if (cabinet?.Folders == null || cabinet.Folders.Length == 0)
193197
break;
194198
}
@@ -226,13 +230,29 @@ private bool ExtractFolder(string? filename,
226230

227231
// Loop through the files
228232
bool allExtracted = true;
229-
var files = GetSpannedFiles(filename, folderIndex, ignorePrev);
233+
var filterFiles = GetSpannedFiles(filename, folderIndex, ignorePrev);
234+
List<CFFILE> fileList = [];
235+
236+
// Filtering, add debug output eventually
237+
for (int i = 0; i < filterFiles.Length; i++)
238+
{
239+
var file = filterFiles[i];
240+
241+
if (file.FolderIndex == FolderIndex.CONTINUED_PREV_AND_NEXT ||
242+
file.FolderIndex == FolderIndex.CONTINUED_FROM_PREV)
243+
{
244+
// debug output for inconsistencies would go here
245+
continue;
246+
}
247+
248+
fileList.Add(file);
249+
}
250+
251+
CFFILE[] files = fileList.ToArray();
230252
blockStream.SeekIfPossible(0, SeekOrigin.Begin);
231253
for (int i = 0; i < files.Length; i++)
232254
{
233255
var file = files[i];
234-
if (file.FolderIndex == FolderIndex.CONTINUED_PREV_AND_NEXT || file.FolderIndex == FolderIndex.CONTINUED_FROM_PREV)
235-
continue;
236256

237257
allExtracted &= ExtractFiles(outputDirectory, blockStream, file, includeDebug);
238258
}

0 commit comments

Comments
 (0)