Maybe 7Zip extraction? I haven't tested it.
This commit is contained in:
parent
33130bc5f8
commit
471bb54fe0
@ -1,4 +1,6 @@
|
||||
global using Nerd_STF.Mathematics;
|
||||
global using SharpCompress.Archives.SevenZip;
|
||||
global using SharpCompress.Readers;
|
||||
global using SrcMod.Shell;
|
||||
global using SrcMod.Shell.Modules.ObjectModels;
|
||||
global using System;
|
||||
|
||||
@ -1,8 +1,9 @@
|
||||
using System.Reflection.Emit;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace SrcMod.Shell.Modules;
|
||||
namespace SrcMod.Shell.Modules;
|
||||
|
||||
// Some things that can be extracted can't be compressed by SharpCompress.
|
||||
// In the future I might replace it with my own, but that'll take a *really*
|
||||
// long time and I'm already planning to do that for the valve compression formats,
|
||||
// so I'll seethe for now.
|
||||
[Module("compress")]
|
||||
public static class CompressionModule
|
||||
{
|
||||
@ -228,4 +229,6 @@ public static class CompressionModule
|
||||
name = $"Compressed a file or folder into a zip archive located at \"{destination}\""
|
||||
});
|
||||
}
|
||||
|
||||
// 7z can't be compressed.
|
||||
}
|
||||
|
||||
@ -114,4 +114,32 @@ public static class ExtractionModule
|
||||
zip.Dispose();
|
||||
reader.Dispose();
|
||||
}
|
||||
|
||||
[Command("7z")]
|
||||
[Command("7zip")]
|
||||
[Command("sevenzip")]
|
||||
public static void Extract7Zip(string source, string? destination = null)
|
||||
{
|
||||
if (!File.Exists(source)) throw new($"No file exists at \"{source}\".");
|
||||
|
||||
if (destination is null)
|
||||
{
|
||||
string full = Path.GetFullPath(source);
|
||||
string folder = Program.Shell!.WorkingDirectory;
|
||||
string name = Path.GetFileNameWithoutExtension(full);
|
||||
|
||||
destination = $"{folder}\\{name}";
|
||||
}
|
||||
|
||||
if (!Directory.Exists(destination)) Directory.CreateDirectory(destination);
|
||||
|
||||
FileStream reader = new(source, FileMode.Open);
|
||||
SevenZipArchive zip = SevenZipArchive.Open(source);
|
||||
|
||||
IReader data = zip.ExtractAllEntries();
|
||||
data.WriteAllToDirectory(destination);
|
||||
|
||||
zip.Dispose();
|
||||
reader.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,7 +4,7 @@ public class Shell
|
||||
{
|
||||
public const string Author = "That_One_Nerd";
|
||||
public const string Name = "SrcMod";
|
||||
public const string Version = "Alpha 0.3";
|
||||
public const string Version = "Alpha 0.3.0";
|
||||
|
||||
public readonly string? ShellDirectory;
|
||||
|
||||
|
||||
@ -31,6 +31,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Nerd_STF" Version="2.3.2" />
|
||||
<PackageReference Include="SharpCompress" Version="0.33.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user