From 2424088dd1449492628cd3dc0ec9885e02827180 Mon Sep 17 00:00:00 2001 From: xpamych Date: Sun, 14 May 2023 15:18:39 +0300 Subject: [PATCH] 1 --- hlna.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/hlna.py b/hlna.py index 188c394..e768cc4 100755 --- a/hlna.py +++ b/hlna.py @@ -427,12 +427,13 @@ def modextract(id_mod, id_game_workshop): pos = pos + 4 + mapfilelen modfile_bytes += b'\x33\xFF\x22\xFF\x02\x00\x00\x00\x01' - with open(f"{modextractdir}/modmeta.info", 'ab') as f: - if os.path.isfile(f"{modextractdir}/modmeta.info"): - f.write(open(f"{modextractdir}/{id_mod}.mod", 'rb').read()) - f.close() - else: - f.write(b'\x01\x00\x00\x00\x08\x00\x00\x00ModType\x00\x02\x00\x00\x001\x00') + if os.path.isfile(os.path.join(modextractdir, "modmeta.info")): + with open(os.path.join(modextractdir, "modmeta.info"), "rb") as f: + with open(f"{modextractdir}.mod", "ab") as f_out: + f_out.write(f.read()) + else: + with open(f"{modextractdir}.mod", "wb") as f_out: + f_out.write(b'\x01\x00\x00\x00\x08\x00\x00\x00ModType\x00\x02\x00\x00\x001\x00') with open(modextractdir + '.mod', 'wb') as f: f.write(modfile_bytes)