Update main with some new compression formats. #37
@ -1,4 +1,5 @@
|
|||||||
global using Nerd_STF.Mathematics;
|
global using Nerd_STF.Mathematics;
|
||||||
|
global using SharpCompress.Archives.Rar;
|
||||||
global using SharpCompress.Archives.SevenZip;
|
global using SharpCompress.Archives.SevenZip;
|
||||||
global using SharpCompress.Readers;
|
global using SharpCompress.Readers;
|
||||||
global using SrcMod.Shell;
|
global using SrcMod.Shell;
|
||||||
|
|||||||
@ -82,6 +82,8 @@ public static class CompressionModule
|
|||||||
else throw new("No file or directory located at \"source\"");
|
else throw new("No file or directory located at \"source\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Rar can't be compressed.
|
||||||
|
|
||||||
[Command("targz")]
|
[Command("targz")]
|
||||||
[Command("tar.gz")]
|
[Command("tar.gz")]
|
||||||
[Command("tar-gz")]
|
[Command("tar-gz")]
|
||||||
|
|||||||
@ -40,6 +40,37 @@ public static class ExtractionModule
|
|||||||
Write(new string(' ', message.Length), newLine: false);
|
Write(new string(' ', message.Length), newLine: false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Command("rar")]
|
||||||
|
public static void ExtractRar(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);
|
||||||
|
RarArchive rar = RarArchive.Open(reader);
|
||||||
|
|
||||||
|
IReader data = rar.ExtractAllEntries();
|
||||||
|
data.WriteAllToDirectory(destination, new()
|
||||||
|
{
|
||||||
|
ExtractFullPath = true,
|
||||||
|
Overwrite = true,
|
||||||
|
PreserveFileTime = true
|
||||||
|
});
|
||||||
|
|
||||||
|
rar.Dispose();
|
||||||
|
reader.Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
[Command("tar")]
|
[Command("tar")]
|
||||||
[Command("tarball")]
|
[Command("tarball")]
|
||||||
public static void ExtractTar(string source, string? destination = null)
|
public static void ExtractTar(string source, string? destination = null)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user