mirror of
https://github.com/SabreTools/BinaryObjectScanner.git
synced 2026-07-08 18:06:34 +00:00
Add MS-CAB GetFolderIndex helper
This commit is contained in:
@@ -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,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user