mirror of
https://github.com/SabreTools/BinaryObjectScanner.git
synced 2026-04-26 08:10:32 +00:00
37 lines
1.0 KiB
C#
37 lines
1.0 KiB
C#
using System.IO;
|
|
using BinaryObjectScanner.Interfaces;
|
|
|
|
namespace BinaryObjectScanner.FileType
|
|
{
|
|
/// <summary>
|
|
/// LZ-compressed file, SZDD variant
|
|
/// </summary>
|
|
public class LZSZDD : IExtractable
|
|
{
|
|
/// <inheritdoc/>
|
|
public bool Extract(string file, string outDir, bool includeDebug)
|
|
{
|
|
if (!File.Exists(file))
|
|
return false;
|
|
|
|
using var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
|
|
return Extract(fs, file, outDir, includeDebug);
|
|
}
|
|
|
|
/// <inheritdoc/>
|
|
public bool Extract(Stream? stream, string file, string outDir, bool includeDebug)
|
|
{
|
|
// Create the wrapper
|
|
var szdd = SabreTools.Serialization.Wrappers.LZSZDD.Create(stream);
|
|
if (szdd == null)
|
|
return false;
|
|
|
|
// Loop through and extract all files
|
|
Directory.CreateDirectory(outDir);
|
|
szdd.Extract(Path.GetFileName(file), outDir);
|
|
|
|
return true;
|
|
}
|
|
}
|
|
}
|