summaryrefslogtreecommitdiffstats
path: root/gamechestcli
diff options
context:
space:
mode:
authorvg <vgm+dev@devys.org>2024-03-05 00:03:41 +0100
committervg <vgm+dev@devys.org>2024-03-05 00:03:41 +0100
commit54449a71321300566370bf3a5a67508e02f5a3c6 (patch)
treee7225563dea782cee8e21599a323e7f298a56636 /gamechestcli
parent860b46a5133bc398938cb53b42ff68b34eb2cd7b (diff)
downloadgamechest-54449a71321300566370bf3a5a67508e02f5a3c6.tar.gz
gamechest-54449a71321300566370bf3a5a67508e02f5a3c6.tar.bz2
gamechest-54449a71321300566370bf3a5a67508e02f5a3c6.zip
git-sync on dita
Diffstat (limited to 'gamechestcli')
-rw-r--r--gamechestcli/gamechest/runners/extract.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/gamechestcli/gamechest/runners/extract.py b/gamechestcli/gamechest/runners/extract.py
index cb8009a..8101e02 100644
--- a/gamechestcli/gamechest/runners/extract.py
+++ b/gamechestcli/gamechest/runners/extract.py
@@ -1,5 +1,6 @@
import os
import re
+import struct
import subprocess
import humanfriendly
@@ -13,6 +14,8 @@ class Extract(RunnerBase):
_progress_re = re.compile(r'^\s*(\S+)\s+\[([^]]+)/s\]\s+ETA\s+(\S+)\s*$')
def __init__(self, src, dst):
+ import sys
+ print('src', src, 'dst', dst, file=sys.stderr)
common_parameters = dict(
encoding='utf8',
env={**os.environ,
@@ -34,10 +37,13 @@ class Extract(RunnerBase):
lzip_command = '/usr/bin/lzip'
plzip_command = '/usr/bin/plzip'
uncompress_command_to_use = [lzip_command, '--decompress']
- if str(src).endswith('.tlz'):
+ first_word_magic = 0
+ with open(src, 'rb') as stream:
+ first_word_magic = struct.unpack('>L', stream.read(4))
+ if first_word_magic == 0x4c5a4950: # lzip magic
if os.path.exists(plzip_command):
uncompress_command_to_use = [plzip_command, '--decompress']
- elif str(src).endswith('.tzst'):
+ elif first_word_magic == 0x28B52FFD:
uncompress_command_to_use = ['zstd', '-T0', '-d', '--stdout']
self.zip_proc = subprocess.Popen(
uncompress_command_to_use,