From 26f7f105c3bfa0a7a9ac461c484d472e9ba747a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ga=C5=88o?= Date: Wed, 14 Sep 2022 08:58:27 +0200 Subject: [PATCH] fatfsparse.py: Fixed ignoring first file in directory Closes IDF-5968 --- components/fatfs/fatfs_utils/entry.py | 2 ++ components/fatfs/fatfsparse.py | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/components/fatfs/fatfs_utils/entry.py b/components/fatfs/fatfs_utils/entry.py index 23d23044534..ec986a39c84 100644 --- a/components/fatfs/fatfs_utils/entry.py +++ b/components/fatfs/fatfs_utils/entry.py @@ -31,6 +31,8 @@ class Entry: LDIR_Name3_IDX: int = 28 LDIR_Name3_SIZE: int = 2 + # short entry in long file names + LDIR_DIR_NTRES: int = 0x18 # one entry can hold 13 characters with size 2 bytes distributed in three regions of the 32 bytes entry CHARS_PER_ENTRY: int = LDIR_Name1_SIZE + LDIR_Name2_SIZE + LDIR_Name3_SIZE diff --git a/components/fatfs/fatfsparse.py b/components/fatfs/fatfsparse.py index 72be656feb0..f9bc82bd392 100755 --- a/components/fatfs/fatfsparse.py +++ b/components/fatfs/fatfsparse.py @@ -24,7 +24,9 @@ def get_obj_name(obj_: dict, directory_bytes_: bytes, entry_position_: int, lfn_ ext_ = f'.{obj_ext_}' if len(obj_ext_) > 0 else '' obj_name_: str = obj_['DIR_Name'].rstrip(chr(PAD_CHAR)) + ext_ # short entry name - if not args.long_name_support: + # if LFN was detected, the record is considered as single SFN record only if DIR_NTRes == 0x18 (LDIR_DIR_NTRES) + # if LFN was not detected, the record cannot be part of the LFN, no matter the value of DIR_NTRes + if not args.long_name_support or obj_['DIR_NTRes'] == Entry.LDIR_DIR_NTRES: return obj_name_ full_name = {}