mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
fatfsgen.py: enable multiple dots in the long file name
This commit is contained in:
parent
952c0f7b23
commit
53c2ea2d08
@ -12,8 +12,8 @@ from .fatfs_state import FATFSState
|
||||
from .long_filename_utils import (build_lfn_full_name, build_lfn_unique_entry_name_order,
|
||||
get_required_lfn_entries_count, split_name_to_lfn_entries,
|
||||
split_name_to_lfn_entry_blocks)
|
||||
from .utils import (DATETIME, MAX_EXT_SIZE, MAX_NAME_SIZE, FATDefaults, build_lfn_short_entry_name, lfn_checksum,
|
||||
required_clusters_count, split_content_into_sectors, split_to_name_and_extension)
|
||||
from .utils import (DATETIME, MAX_EXT_SIZE, MAX_NAME_SIZE, FATDefaults, build_lfn_short_entry_name, build_name,
|
||||
lfn_checksum, required_clusters_count, split_content_into_sectors, split_to_name_and_extension)
|
||||
|
||||
|
||||
class File:
|
||||
@ -45,7 +45,8 @@ class File:
|
||||
self._first_cluster = value
|
||||
|
||||
def name_equals(self, name: str, extension: str) -> bool:
|
||||
return self.name == name and self.extension == extension
|
||||
equals_: bool = build_name(name, extension) == build_name(self.name, self.extension)
|
||||
return equals_
|
||||
|
||||
def write(self, content: bytes) -> None:
|
||||
self.entry.update_content_size(len(content))
|
||||
@ -112,7 +113,8 @@ class Directory:
|
||||
self._first_cluster = value
|
||||
|
||||
def name_equals(self, name: str, extension: str) -> bool:
|
||||
return self.name == name and self.extension == extension
|
||||
equals_: bool = build_name(name, extension) == build_name(self.name, self.extension)
|
||||
return equals_
|
||||
|
||||
@property
|
||||
def entries_count(self) -> int:
|
||||
@ -141,7 +143,7 @@ class Directory:
|
||||
|
||||
def lookup_entity(self, object_name: str, extension: str): # type: ignore
|
||||
for entity in self.entities:
|
||||
if entity.name == object_name and entity.extension == extension:
|
||||
if build_name(entity.name, entity.extension) == build_name(object_name, extension):
|
||||
return entity
|
||||
return None
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
from typing import List
|
||||
|
||||
from .entry import Entry
|
||||
from .utils import convert_to_utf16_and_pad
|
||||
from .utils import build_name, convert_to_utf16_and_pad
|
||||
|
||||
# File name with long filenames support can be as long as memory allows. It is split into entries
|
||||
# holding 13 characters of the filename, thus the number of required entries is ceil(len(long_name) / 13).
|
||||
@ -85,7 +85,7 @@ def build_lfn_full_name(name: str, extension: str) -> str:
|
||||
The extension is optional, and the long filename entry explicitly specifies it,
|
||||
on the opposite as for short file names.
|
||||
"""
|
||||
lfn_record: str = f'{name}.{extension}' if len(extension) > 0 else name
|
||||
lfn_record: str = build_name(name, extension)
|
||||
# the name must be terminated with NULL terminator
|
||||
# if it doesn't fit into the set of long name directory entries
|
||||
if len(lfn_record) % Entry.CHARS_PER_ENTRY != 0:
|
||||
|
@ -222,6 +222,10 @@ TIME_ENTRY = BitStruct(
|
||||
)
|
||||
|
||||
|
||||
def build_name(name: str, extension: str) -> str:
|
||||
return f'{name}.{extension}' if len(extension) > 0 else name
|
||||
|
||||
|
||||
def build_date_entry(year: int, mon: int, mday: int) -> int:
|
||||
"""
|
||||
:param year: denotes year starting from 1980 (0 ~ 1980, 1 ~ 1981, etc), valid values are 1980 + 0..127 inclusive
|
||||
|
Loading…
Reference in New Issue
Block a user