From 9e7a84d2d6d239a8230680257112e239484c6f47 Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Mon, 26 Dec 2022 14:45:49 -0800 Subject: [PATCH] Remove generic "Valve" --- BurnOutSharp/FileType/Valve.cs | 87 --------------------------------- BurnOutSharp/Tools/Utilities.cs | 1 - 2 files changed, 88 deletions(-) delete mode 100644 BurnOutSharp/FileType/Valve.cs diff --git a/BurnOutSharp/FileType/Valve.cs b/BurnOutSharp/FileType/Valve.cs deleted file mode 100644 index af80695a..00000000 --- a/BurnOutSharp/FileType/Valve.cs +++ /dev/null @@ -1,87 +0,0 @@ -using System; -using System.Collections.Concurrent; -using System.IO; -using BurnOutSharp.Interfaces; -using BurnOutSharp.Utilities; -using HLLib.Directory; -using HLLib.Packages; -using static BurnOutSharp.Utilities.Dictionary; - -namespace BurnOutSharp.FileType -{ - /// - /// Various Valve archive formats - /// - public class Valve : IScannable - { - /// - public ConcurrentDictionary> 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); - } - } - - // TODO: Add stream opening support - /// - public ConcurrentDictionary> Scan(Scanner scanner, Stream stream, string file) - { - // If the Valve archive itself fails - try - { - string tempPath = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString()); - Directory.CreateDirectory(tempPath); - - // Get the package type - byte[] magic = stream.ReadBytes(16); - PackageType packageType = Package.GetPackageType(magic); - if (packageType == PackageType.HL_PACKAGE_NONE) - return null; - - // Create a new package from the file - var pkg = Package.CreatePackage(packageType); - FileModeFlags mode = FileModeFlags.HL_MODE_READ | FileModeFlags.HL_MODE_WRITE | FileModeFlags.HL_MODE_NO_FILEMAPPING | FileModeFlags.HL_MODE_VOLATILE; - bool opened = pkg.Open(file, mode, overwriteFiles: true); - if (!opened) - return null; - - // Create the root directory - var rootDirectory = pkg.GetRoot(); - - // Extract all files - rootDirectory.Extract(tempPath, readEncrypted: true, overwrite: true); - - // Close the package explicitly - pkg.Close(); - - // 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; - } - } -} diff --git a/BurnOutSharp/Tools/Utilities.cs b/BurnOutSharp/Tools/Utilities.cs index a731317a..bab01b92 100644 --- a/BurnOutSharp/Tools/Utilities.cs +++ b/BurnOutSharp/Tools/Utilities.cs @@ -640,7 +640,6 @@ 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.Valve(); case SupportedFileType.TapeArchive: return new FileType.TapeArchive(); case SupportedFileType.Textfile: return new FileType.Textfile(); case SupportedFileType.VBSP: return new FileType.VBSP();