Skip to content

Commit

Permalink
Fix deep-dir archives
Browse files Browse the repository at this point in the history
Packing and unpacking of the archives with more rooted directories.
  • Loading branch information
TesterTesterov committed Mar 8, 2023
1 parent 5d0a88a commit d890f41
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
5 changes: 3 additions & 2 deletions ai6win_arc.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,9 @@ def _pack_names_and_files(self) -> tuple:

rel_name = os.path.normpath(os.path.join(root, filename))
end_name = rel_name
if rel_name.startswith(root + os.sep):
end_name = rel_name[len(root + os.sep):]
if rel_name.startswith(self._dir_name + os.sep):
end_name = rel_name[len(self._dir_name + os.sep):]
end_name = end_name.replace(os.sep, '/')
encrypted_name = self.encrypt_name(end_name)

with open(rel_name, 'rb') as this_file:
Expand Down
4 changes: 2 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ def test(mode: str):
from ai6win_arc import AI6WINArc
"""modes: unpack, pack,"""
if mode == "unpack":
test_arc = AI6WINArc("Data.arc", "Data", integrity_check=True)
test_arc = AI6WINArc("mes.arc", "mes", integrity_check=True)
test_arc.unpack()
elif mode == "pack":
test_arc = AI6WINArc("Data.arc", "Data", integrity_check=True)
test_arc = AI6WINArc("mes.arc", "mes", integrity_check=True)
test_arc.pack()


Expand Down
12 changes: 6 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@


executables = [cx_Freeze.Executable("main.py",
shortcut_name="SilkyArcTool",
shortcut_dir="SilkyArcTool",
#base="Win32GUI")
]
shortcut_name="AI6WINArcTool",
shortcut_dir="AI6WINArcTool",
#base="Win32GUI"
)]

cx_Freeze.setup(
name="SilkyArcTool",
version="1.0",
name="AI6WINArcTool",
version="1.1",
description="Dual languaged (rus+eng) tool for packing and unpacking archives of Silky Engine.\n"
"Двуязычное средство (рус+англ) для распаковки и запаковки архивов Silky Engine.",
options={"build_exe": {"packages": []}},
Expand Down
1 change: 1 addition & 0 deletions silky_arc.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ def _unpack_files(self) -> None:
except AssertionError:
print("!!! File {0} true size is incorrect!/Истинный размер файла {0} некорректен!".
format(i[1]))
os.makedirs(os.path.dirname(this_file_name), exist_ok=True)
with open(this_file_name, 'wb') as this_file:
this_file.write(new_file_bytes)
if self._verbose:
Expand Down

0 comments on commit d890f41

Please sign in to comment.