Add MS-CAB GetFolderIndex helper

This commit is contained in:
Matt Nadareski
2025-07-28 13:09:08 -04:00
parent f2fe2623c6
commit cf7a68602b

View File

@@ -104,7 +104,7 @@ namespace BinaryObjectScanner.FileType
// Loop through the files
foreach (var compressedFile in cabArchive.Model.Files)
{
if (compressedFile?.Name == null || compressedFile.FolderIndex != (FolderIndex)f)
if (compressedFile?.Name == null || GetFolderIndex(cabArchive, compressedFile) != f)
continue;
try
@@ -169,5 +169,19 @@ namespace BinaryObjectScanner.FileType
}
#endif
}
/// <summary>
/// Get the corrected folder index
/// </summary>
private int GetFolderIndex(SabreTools.Serialization.Wrappers.MicrosoftCabinet cabArchive, CFFILE file)
{
return file.FolderIndex switch
{
FolderIndex.CONTINUED_FROM_PREV => 0,
FolderIndex.CONTINUED_TO_NEXT => (cabArchive.Model.Header?.FolderCount ?? 1) - 1,
FolderIndex.CONTINUED_PREV_AND_NEXT => 0,
_ => (int)file.FolderIndex,
};
}
}
}