From 5f751acabd027a369da1f2b92ef491c4cee0f269 Mon Sep 17 00:00:00 2001 From: NinjaCheetah <58050615+NinjaCheetah@users.noreply.github.com> Date: Thu, 23 Jan 2025 22:30:59 -0500 Subject: [PATCH] Added lz77 compress command --- commands/archive/lz77.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/commands/archive/lz77.py b/commands/archive/lz77.py index e797158..d658bc9 100644 --- a/commands/archive/lz77.py +++ b/commands/archive/lz77.py @@ -7,7 +7,20 @@ from modules.core import fatal_error def handle_lz77_compress(args): - print("Compression is not implemented yet.") + input_path = pathlib.Path(args.input) + if args.output is not None: + output_path = pathlib.Path(args.output) + else: + output_path = pathlib.Path(input_path.name + ".lz77") + + if not input_path.exists(): + fatal_error(f"The specified file \"{input_path}\" does not exist!") + + lz77_data = input_path.read_bytes() + data = libWiiPy.archive.compress_lz77(lz77_data) + output_path.write_bytes(data) + + print("LZ77 file compressed!") def handle_lz77_decompress(args):