using System; using System.IO; using BinaryObjectScanner.Interfaces; namespace BurnOutSharp.FileType { /// /// BFPK custom archive format /// public class BFPK : IExtractable { /// public string Extract(string file, bool includeDebug) { if (!File.Exists(file)) return null; using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.Read)) { return Extract(fs, file, includeDebug); } } /// public string Extract(Stream stream, string file, bool includeDebug) { try { // Create the wrapper BinaryObjectScanner.Wrappers.BFPK bfpk = BinaryObjectScanner.Wrappers.BFPK.Create(stream); if (bfpk == null) return null; // Create a temp output directory string tempPath = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString()); Directory.CreateDirectory(tempPath); // Extract all files bfpk.ExtractAll(tempPath); return tempPath; } catch (Exception ex) { if (includeDebug) Console.WriteLine(ex); return null; } } } }