Add extract all to BFPK

This commit is contained in:
Matt Nadareski
2023-01-03 09:19:35 -08:00
parent 580bf0494d
commit c2c125fd29
2 changed files with 27 additions and 9 deletions

View File

@@ -97,11 +97,32 @@ namespace BurnOutSharp.Wrappers
#region Data
/// <summary>
/// Extract a single file based on index
/// Extract all files from the BFPK to an output directory
/// </summary>
/// <param name="index">Index of the file to extract</param>
/// <param name="outputDirectory">Directory to write the file to</param>
/// <returns>True if the extraction succeeded, false otherwise</returns>
/// <param name="outputDirectory">Output directory to write to</param>
/// <returns>True if all files extracted, false otherwise</returns>
public bool ExtractAll(string outputDirectory)
{
// If we have no files
if (FileTable == null || FileTable.Length == 0)
return false;
// Loop through and extract all files to the output
bool allExtracted = true;
for (int i = 0; i < FileTable.Length; i++)
{
allExtracted &= ExtractFile(i, outputDirectory);
}
return allExtracted;
}
/// <summary>
/// Extract a file from the BFPK to an output directory by index
/// </summary>
/// <param name="index">File index to extract</param>
/// <param name="outputDirectory">Output directory to write to</param>
/// <returns>True if the file extracted, false otherwise</returns>
public bool ExtractFile(int index, string outputDirectory)
{
// If we have no files

View File

@@ -37,11 +37,8 @@ namespace BurnOutSharp.FileType
if (bfpk == null)
return null;
// Loop through and extract all files
for (int i = 0; i < bfpk.Files; i++)
{
bfpk.ExtractFile(i, tempPath);
}
// Extract all files
bfpk.ExtractAll(tempPath);
// Collect and format all found protections
var protections = scanner.GetProtections(tempPath);