Skip to content

Commit

Permalink
Fix filenames with ".."
Browse files Browse the repository at this point in the history
  • Loading branch information
TesterTesterov authored Feb 1, 2022
1 parent b3fe035 commit e7301f1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

cx_Freeze.setup(
name="mesScriptAsseAndDisassembler",
version="1.2",
version="1.3",
description="Dual languaged (rus+eng) tool for packing and unpacking mes scripts of Silky Engine.\n"
"Двухязычное средство (рус+англ) для распаковки и запаковки скриптов mes Silky Engine.",
options={"build_exe": {"packages": []}},
Expand Down
6 changes: 3 additions & 3 deletions silky_mes.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class SilkyMesScript:

# [Opcode, struct, name].
command_library = (
(0x00, '', 'NULL'),
(0x00, '', 'RETURN'),
(0x01, 'I', ''), # Found only in LIBLARY.LIB
(0x02, '', ''),
(0x03, '', ''), # Found only in LIBLARY.LIB
Expand All @@ -36,8 +36,8 @@ class SilkyMesScript:
(0x1B, '>I', ''),
(0x1C, 'B', 'TO_NEW_STRING'),

(0x32, '>hh', ''),
(0x33, 'S', 'STR_RAW'),
(0x32, 'i', 'PUSH'),
(0x33, 'S', 'PUSH_STR'),
(0x34, '', ''),
(0x35, '', ''),
(0x36, 'B', 'JUMP_2'),
Expand Down
12 changes: 10 additions & 2 deletions silky_mes_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -455,11 +455,16 @@ def _disassemble(self) -> bool:
else: # Dir mode.
files_to_manage = []
os.makedirs(txt_file, exist_ok=True)
falkeze = len(mes_file.split(os.sep))
for root, dirs, files in os.walk(mes_file):
for file_name in files:
new_file_array = [] # mes_file, txt_file

basic_path = os.sep.join(os.path.join(root, file_name).split(os.sep)[1:])
basic_path = os.sep.join(os.path.join(root, file_name).split(os.sep)[falkeze:])
print(basic_path)
print(mes_file)
print(os.path.join(mes_file, basic_path))
print(os.path.normpath(os.path.join(mes_file, basic_path)))
rel_mes_name = os.path.normpath(os.path.join(mes_file, basic_path))
rel_txt_name = os.path.normpath(os.path.join(txt_file, os.path.splitext(basic_path)[0] + ".txt"))

Expand Down Expand Up @@ -528,11 +533,12 @@ def _assemble(self) -> bool:
else: # Dir mode.
files_to_manage = []
os.makedirs(txt_file, exist_ok=True)
falkeze = len(txt_file.split(os.sep))
for root, dirs, files in os.walk(txt_file):
for file_name in files:
new_file_array = [] # mes_file, txt_file

basic_path = os.sep.join(os.path.join(root, file_name).split(os.sep)[1:])
basic_path = os.sep.join(os.path.join(root, file_name).split(os.sep)[falkeze:])
rel_mes_name = os.path.normpath(os.path.join(mes_file, os.path.splitext(basic_path)[0] + ".MES"))
rel_txt_name = os.path.normpath(os.path.join(txt_file, basic_path))

Expand Down Expand Up @@ -605,6 +611,8 @@ def _get_mes_and_txt(self) -> tuple:
status = False
showwarning(title=self._strings_lib[self._language][22],
message=self._strings_lib[self._language][24])
mes_file = os.path.abspath(mes_file)
txt_file = os.path.abspath(txt_file)
return mes_file, txt_file, status

# Language technical methods.
Expand Down

0 comments on commit e7301f1

Please sign in to comment.