platomav/MEAnalyzer

Error with option -unp86 on Windows python with [fix]

cooltronicpl opened this issue · 3 comments

The error with unpacked folder filenames with new option -unp86

Error: MEA just crashed, please report the following:

Traceback (most recent call last):
  File "D:\Pliki\Drivery\BIOSy\MEAnalyzer170\MEA.py", line 7325, in <module>
    cse_unpack(variant, fpt_part_all, bpdt_part_all, file_end, fpt_start if rgn_exist else -1, fpt_chk_fail)
  File "D:\Pliki\Drivery\BIOSy\MEAnalyzer170\MEA.py", line 3260, in cse_unpack
    os.mkdir(os.path.join(mea_dir, fw_name, ''))
FileExistsError: [WinError 183] Cannot create a file when that file already exists: 'd:\\pliki\\drivery\\biosy\\meanalyzer170\\A40_DUMP\\'

My fix:

def cse_unpack(variant, fpt_part_all, bpdt_part_all, file_end, fpt_start, fpt_chk_fail) :
	print()
	fpt_hdr_0_print = None
	cpd_match_ranges = []
	len_fpt_part_all = len(fpt_part_all)
	len_bpdt_part_all = len(bpdt_part_all)
	ansi_escape = re.compile(r'\x1b[^m]*m') # Generate ANSI Color and Font Escape Character Sequences
	
	# Create main Firmware Extraction Directory
	fw_name = os.path.basename(file_in)
	if os.path.isdir(os.path.join(mea_dir, fw_name, '')) : shutil.rmtree(os.path.join(mea_dir, fw_name, ''))
	fw_name = fw_name.__add__('_UNP86') // this create folder with other name than file @cooltronicyoutube 
	os.mkdir(os.path.join(mea_dir, fw_name, ''))

Please attach or upload somewhere the image which causes this error so that I can take a look.

This happens because your input file is at the same directory as MEA and the OS cannot tell the difference between a file and a folder. I just pushed a fix similar to yours. Thank you for the bug report. :)