mirror of
https://github.com/SabreTools/BinaryObjectScanner.git
synced 2026-07-20 15:55:15 +00:00
Add cabinet finding
This commit is contained in:
@@ -269,6 +269,18 @@ namespace BurnOutSharp.FileType
|
||||
|
||||
#region Public Functionality
|
||||
|
||||
/// <summary>
|
||||
/// Find the start of an MS-CAB cabinet in a set of data, if possible
|
||||
/// </summary>
|
||||
public int FindCabinet(byte[] data)
|
||||
{
|
||||
if (data == null || data.Length < CFHEADER.SignatureBytes.Length)
|
||||
return -1;
|
||||
|
||||
bool found = data.FirstPosition(CFHEADER.SignatureBytes, out int index);
|
||||
return found ? index : -1;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Extract a single file from the archive to <paramref name="outputDirectory"/>
|
||||
/// </summary>
|
||||
|
||||
@@ -164,6 +164,15 @@ namespace BurnOutSharp.Tools
|
||||
return positions;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Find the first position of one array in another, if possible
|
||||
/// </summary>
|
||||
public static bool FirstPosition(this byte[] stack, byte[] needle, out int position, int start = 0, int end = -1)
|
||||
{
|
||||
byte?[] nullableNeedle = needle != null ? needle.Select(b => (byte?)b).ToArray() : null;
|
||||
return stack.FirstPosition(nullableNeedle, out position, start, end);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Find the first position of one array in another, if possible
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user