From ca672dfa0ffbc2d520427116d8c9c456e489943e Mon Sep 17 00:00:00 2001 From: zapan Date: Thu, 25 Apr 2024 13:27:46 +0200 Subject: [PATCH] Added allz-compressor command to compress Aqualead Files with Aqualead LZ compression algorithm (ALLZ). --- DgfTxmConvert/DgfTxmConvert.csproj | 11 +++++++++- DgfTxmConvert/Program.cs | 33 +++++++++++++++++++++++++++++- 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/DgfTxmConvert/DgfTxmConvert.csproj b/DgfTxmConvert/DgfTxmConvert.csproj index 3204f83..0935a49 100755 --- a/DgfTxmConvert/DgfTxmConvert.csproj +++ b/DgfTxmConvert/DgfTxmConvert.csproj @@ -2,7 +2,7 @@ Exe - netcoreapp3.1 + net6.0 @@ -18,7 +18,16 @@ ..\..\LibDgf\LibDgf.Graphics\bin\Debug\netstandard2.0\LibDgf.Graphics.dll + + + + + + + ..\..\AuroraLib.Compression\src\AuroraLib.Compression\bin\Debug\net6.0\AuroraLib.Compression.dll + + diff --git a/DgfTxmConvert/Program.cs b/DgfTxmConvert/Program.cs index c3c130b..efad372 100755 --- a/DgfTxmConvert/Program.cs +++ b/DgfTxmConvert/Program.cs @@ -16,8 +16,10 @@ using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; -using System.IO.Pipes; using System.Text; +using AuroraLib.Compression; +using AuroraLib.Compression.Algorithms; + using Path = System.IO.Path; namespace DgfTxmConvert @@ -77,6 +79,24 @@ namespace DgfTxmConvert DecompressDat(datPathArg.Value, outBaseArg.Value); }); }); + + app.Command("allz-compressor", config => + { + config.FullName = "Compress file with ALLZ"; + config.Description = "Converts flat file to compressed."; + + var datPathArg = config.Argument("datPath", "Path of the file to compress").IsRequired(); + datPathArg.Accepts().ExistingFile(); + var outPathArg = config.Argument("outBase", "Path of the output file"); + outPathArg.Accepts().LegalFilePath(); + + config.HelpOption(); + + config.OnExecute(() => + { + AllzCompressor(datPathArg.Value, outPathArg.Value); + }); + }); app.Command("convert-txm", config => { @@ -354,6 +374,17 @@ namespace DgfTxmConvert } } + + + static void AllzCompressor(string datPathArg, string outPathArg = null) + { + if (outPathArg == null) + outPathArg = Path.GetFullPath(datPathArg) + $"/output.dat"; + + using Stream sourceStr = File.OpenRead(datPathArg); + using var destStr = File.Create(outPathArg); + new ALLZ().Compress(sourceStr, destStr); + } static void ConvertDat(string path, string outBase = null) {