From c2c125fd299f2dcf9dc5f6e1befd167990135322 Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Tue, 3 Jan 2023 09:19:35 -0800 Subject: [PATCH] Add extract all to BFPK --- BurnOutSharp.Wrappers/BFPK.cs | 29 +++++++++++++++++++++++++---- BurnOutSharp/FileType/BFPK.cs | 7 ++----- 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/BurnOutSharp.Wrappers/BFPK.cs b/BurnOutSharp.Wrappers/BFPK.cs index 19e8df4d..1c5d15e3 100644 --- a/BurnOutSharp.Wrappers/BFPK.cs +++ b/BurnOutSharp.Wrappers/BFPK.cs @@ -97,11 +97,32 @@ namespace BurnOutSharp.Wrappers #region Data /// - /// Extract a single file based on index + /// Extract all files from the BFPK to an output directory /// - /// Index of the file to extract - /// Directory to write the file to - /// True if the extraction succeeded, false otherwise + /// Output directory to write to + /// True if all files extracted, false otherwise + 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; + } + + /// + /// Extract a file from the BFPK to an output directory by index + /// + /// File index to extract + /// Output directory to write to + /// True if the file extracted, false otherwise public bool ExtractFile(int index, string outputDirectory) { // If we have no files diff --git a/BurnOutSharp/FileType/BFPK.cs b/BurnOutSharp/FileType/BFPK.cs index 6f366d9a..af881d78 100644 --- a/BurnOutSharp/FileType/BFPK.cs +++ b/BurnOutSharp/FileType/BFPK.cs @@ -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);