fatfsparse.py: enable automatic detection of lfn

This commit is contained in:
Martin Gaňo 2022-09-06 16:08:18 +02:00
parent 892437d829
commit 72acbeb921
4 changed files with 6 additions and 7 deletions

View File

@ -55,9 +55,8 @@ def traverse_folder_tree(directory_bytes_: bytes,
try: try:
obj_: dict = Entry.ENTRY_FORMAT_SHORT_NAME.parse( obj_: dict = Entry.ENTRY_FORMAT_SHORT_NAME.parse(
directory_bytes_[obj_address_: obj_address_ + FATDefaults.ENTRY_SIZE]) directory_bytes_[obj_address_: obj_address_ + FATDefaults.ENTRY_SIZE])
except (construct.core.ConstError, UnicodeDecodeError) as e: except (construct.core.ConstError, UnicodeDecodeError):
if not args.long_name_support: args.long_name_support = True
raise e
continue continue
if obj_['DIR_Attr'] == 0: # empty entry if obj_['DIR_Attr'] == 0: # empty entry
@ -90,7 +89,7 @@ if __name__ == '__main__':
help='Path to the image that will be parsed and extracted.') help='Path to the image that will be parsed and extracted.')
argument_parser.add_argument('--long-name-support', argument_parser.add_argument('--long-name-support',
action='store_true', action='store_true',
help='Set flag to enable long names support.') help=argparse.SUPPRESS)
argument_parser.add_argument('--wear-leveling', argument_parser.add_argument('--wear-leveling',
action='store_true', action='store_true',

View File

@ -320,7 +320,7 @@ class FatFSGen(unittest.TestCase):
f'{os.path.join(os.path.dirname(__file__), "..", "fatfsgen.py")}', f'{os.path.join(os.path.dirname(__file__), "..", "fatfsgen.py")}',
'testf', '--long_name_support' 'testf', '--long_name_support'
], stderr=STDOUT) ], stderr=STDOUT)
run(['python', '../fatfsparse.py', 'fatfs_image.img', '--long-name-support'], stderr=STDOUT) run(['python', '../fatfsparse.py', 'fatfs_image.img'], stderr=STDOUT)
assert compare_folders('testf', 'Espressif') assert compare_folders('testf', 'Espressif')

View File

@ -144,4 +144,4 @@ It is a reverse tool of (:component_file:`fatfsgen.py<fatfs/fatfsgen.py>`), i.e.
Usage:: Usage::
./fatfsparse.py [-h] [--long-name-support] [--wear-leveling] fatfs_image.img ./fatfsparse.py [-h] [--wear-leveling] fatfs_image.img

View File

@ -144,4 +144,4 @@ FatFs 分区分析器
您可以使用:: 您可以使用::
./fatfsparse.py [-h] [--long-name-support] [--wear-leveling] fatfs_image.img ./fatfsparse.py [-h] [--wear-leveling] fatfs_image.img