Improved 7-Zip decompressor

Removed --static argument

Small fixes at variable names and f-strings
This commit is contained in:
platomav 2022-06-01 02:22:59 +03:00
parent aea54aeaad
commit 7111757764
7 changed files with 25 additions and 28 deletions

View file

@ -30,7 +30,7 @@ def is_efi_compressed(data, strict=True):
# Get TianoCompress path
def get_tiano_path():
exec_name = 'TianoCompress' + ('.exe' if get_os_ver()[1] else '')
exec_name = f'TianoCompress{".exe" if get_os_ver()[1] else ""}'
return safe_path(project_root(), ['external',exec_name])

View file

@ -12,16 +12,16 @@ from common.path_ops import project_root, safe_path
from common.system import get_os_ver
from common.system import printer
# Get 7z path
def get_7z_path(static=False):
exec_name = '7z.exe' if get_os_ver()[1] else ('7zzs' if static else '7zz')
# Get 7-Zip path
def get_szip_path():
exec_name = '7z.exe' if get_os_ver()[1] else '7zzs'
return safe_path(project_root(), ['external',exec_name])
# Check if file is 7z supported
def is_7z_supported(in_path, padding=0, static=False):
# Check if file is 7-Zip supported
def is_szip_supported(in_path, padding=0):
try:
subprocess.run([get_7z_path(static), 't', in_path, '-bso0', '-bse0', '-bsp0'], check=True)
subprocess.run([get_szip_path(), 't', in_path, '-bso0', '-bse0', '-bsp0'], check=True)
except:
printer(f'Error: 7-Zip could not check support for file {in_path}!', padding)
@ -30,11 +30,11 @@ def is_7z_supported(in_path, padding=0, static=False):
return True
# Archive decompression via 7-Zip
def a7z_decompress(in_path, out_path, in_name, padding=0, static=False):
def szip_decompress(in_path, out_path, in_name, padding=0):
if not in_name: in_name = 'archive'
try:
subprocess.run([get_7z_path(static), 'x', '-aou', '-bso0', '-bse0', '-bsp0', '-o' + out_path, in_path], check=True)
subprocess.run([get_szip_path(), 'x', '-aou', '-bso0', '-bse0', '-bsp0', '-o' + out_path, in_path], check=True)
if not os.path.isdir(out_path): raise Exception('EXTRACT_DIR_MISSING')
except:

View file

@ -13,7 +13,11 @@ PAT_DELL_FTR = re.compile(br'\xEE\xAA\xEE\x8F\x49\x1B\xE8\xAE\x14\x37\x90')
PAT_DELL_HDR = re.compile(br'\xEE\xAA\x76\x1B\xEC\xBB\x20\xF1\xE6\x51.\x78\x9C', re.DOTALL)
PAT_DELL_PKG = re.compile(br'\x72\x13\x55\x00.{45}7zXZ', re.DOTALL)
PAT_INTEL_ENG = re.compile(br'\x04\x00{3}[\xA1\xE1]\x00{3}.{8}\x86\x80.{9}\x00\$((MN2)|(MAN))', re.DOTALL)
PAT_MICROSOFT_CAB_FF = re.compile(br'\xB2\xAC\xBC\xB9\xFF{4}.{4}\xFF{4}.{4}\xFF{4}\xFC\xFE', re.DOTALL)
PAT_MICROSOFT_MZ = re.compile(br'MZ')
PAT_MICROSOFT_PE = re.compile(br'PE\x00{2}')
PAT_PHOENIX_TDK = re.compile(br'\$PACK\x00{3}..\x00{2}.\x00{3}', re.DOTALL)
PAT_PORTWELL_EFI = re.compile(br'<U{2}>')
PAT_VAIO_CFG = re.compile(br'\[Setting]\x0D\x0A')
PAT_VAIO_CHK = re.compile(br'\x0AUseVAIOCheck=')
PAT_VAIO_EXT = re.compile(br'\x0AExtractPathByUser=')

View file

@ -67,7 +67,6 @@ def argparse_init():
argparser.add_argument('-v', '--version', help='show utility name and version', action='store_true')
argparser.add_argument('-o', '--output-dir', help='extract in given output directory')
argparser.add_argument('-i', '--input-dir', help='extract from given input directory')
argparser.add_argument('--static', help='use static-built dependencies', action='store_true')
return argparser