Files
BinaryObjectScanner/BurnOutSharp/FileType/BFPK.cs
2023-03-09 15:07:35 -05:00

43 lines
1.1 KiB
C#

using System;
using System.IO;
using BinaryObjectScanner.Interfaces;
namespace BurnOutSharp.FileType
{
/// <summary>
/// BFPK custom archive format
/// </summary>
public class BFPK : IExtractable
{
/// <inheritdoc/>
public string Extract(string file)
{
if (!File.Exists(file))
return null;
using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.Read))
{
return Extract(fs, file);
}
}
/// <inheritdoc/>
public string Extract(Stream stream, string file)
{
// 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;
}
}
}