mirror of
https://github.com/SabreTools/BinaryObjectScanner.git
synced 2026-07-09 02:16:46 +00:00
Use new SGA extraction
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
namespace BurnOutSharp.Models.SGA
|
||||
{
|
||||
/// <summary>
|
||||
/// SGA game archive
|
||||
/// </summary>
|
||||
/// <see href="https://github.com/RavuAlHemio/hllib/blob/master/HLLib/SGAFile.h"/>
|
||||
public class File
|
||||
{
|
||||
|
||||
69
BurnOutSharp/FileType/SGA.cs
Normal file
69
BurnOutSharp/FileType/SGA.cs
Normal file
@@ -0,0 +1,69 @@
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.IO;
|
||||
using BurnOutSharp.Interfaces;
|
||||
using static BurnOutSharp.Utilities.Dictionary;
|
||||
|
||||
namespace BurnOutSharp.FileType
|
||||
{
|
||||
/// <summary>
|
||||
/// SGA game archive
|
||||
/// </summary>
|
||||
public class SGA : IScannable
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public ConcurrentDictionary<string, ConcurrentQueue<string>> Scan(Scanner scanner, string file)
|
||||
{
|
||||
if (!File.Exists(file))
|
||||
return null;
|
||||
|
||||
using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.Read))
|
||||
{
|
||||
return Scan(scanner, fs, file);
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public ConcurrentDictionary<string, ConcurrentQueue<string>> Scan(Scanner scanner, Stream stream, string file)
|
||||
{
|
||||
// If the SGA file itself fails
|
||||
try
|
||||
{
|
||||
string tempPath = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
|
||||
Directory.CreateDirectory(tempPath);
|
||||
|
||||
// Create the wrapper
|
||||
Wrappers.SGA sga = Wrappers.SGA.Create(stream);
|
||||
if (sga == null)
|
||||
return null;
|
||||
|
||||
// Loop through and extract all files
|
||||
sga.ExtractAll(tempPath);
|
||||
|
||||
// Collect and format all found protections
|
||||
var protections = scanner.GetProtections(tempPath);
|
||||
|
||||
// If temp directory cleanup fails
|
||||
try
|
||||
{
|
||||
Directory.Delete(tempPath, true);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (scanner.IncludeDebug) Console.WriteLine(ex);
|
||||
}
|
||||
|
||||
// Remove temporary path references
|
||||
StripFromKeys(protections, tempPath);
|
||||
|
||||
return protections;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (scanner.IncludeDebug) Console.WriteLine(ex);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -473,6 +473,14 @@ namespace BurnOutSharp
|
||||
AppendToDictionary(protections, subProtections);
|
||||
}
|
||||
|
||||
// SGA
|
||||
if (scannable is SGA)
|
||||
{
|
||||
var subProtections = scannable.Scan(this, stream, fileName);
|
||||
PrependToKeys(subProtections, fileName);
|
||||
AppendToDictionary(protections, subProtections);
|
||||
}
|
||||
|
||||
// Tape Archive
|
||||
if (scannable is TapeArchive)
|
||||
{
|
||||
|
||||
@@ -640,6 +640,7 @@ namespace BurnOutSharp.Tools
|
||||
case SupportedFileType.RAR: return new FileType.RAR();
|
||||
case SupportedFileType.SevenZip: return new FileType.SevenZip();
|
||||
case SupportedFileType.SFFS: return new FileType.SFFS();
|
||||
case SupportedFileType.SGA: return new FileType.SGA();
|
||||
case SupportedFileType.TapeArchive: return new FileType.TapeArchive();
|
||||
case SupportedFileType.Textfile: return new FileType.Textfile();
|
||||
case SupportedFileType.VBSP: return new FileType.VBSP();
|
||||
|
||||
@@ -166,7 +166,7 @@ Below is a list of container formats that are supported in some way:
|
||||
| PlayJ audio file (PLJ) | No | Yes | No | |
|
||||
| Portable Executable | Yes | Yes | No* | Some packed executables are supported |
|
||||
| RAR archive (RAR) | No | Yes | Yes | Via `SharpCompress` |
|
||||
| SGA? | No | No | No | Skeleton only |
|
||||
| SGA game archive | Yes | Yes | Yes | |
|
||||
| StarForce Filesystem file (SFFS) | No | Yes | No | Skeleton only |
|
||||
| Tape archive (TAR) | No | Yes | Yes | Via `SharpCompress` |
|
||||
| Valve Package File (VPK) | Yes | Yes | Yes | |
|
||||
|
||||
@@ -424,7 +424,7 @@ namespace Test
|
||||
pak.Print();
|
||||
}
|
||||
|
||||
// PAK
|
||||
// SGA
|
||||
else if (ft == SupportedFileType.SGA)
|
||||
{
|
||||
// Build the archive information
|
||||
|
||||
Reference in New Issue
Block a user