mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-05 05:34:32 +02:00
Merge branch 'bugfix/fatfsgen-enable-multiple-dots' into 'master'
fatfsgen.py: Enable multiple dots in lfn filename Closes IDF-5969 See merge request espressif/esp-idf!20153
This commit is contained in:
@@ -12,8 +12,8 @@ from .fatfs_state import FATFSState
|
|||||||
from .long_filename_utils import (build_lfn_full_name, build_lfn_unique_entry_name_order,
|
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,
|
get_required_lfn_entries_count, split_name_to_lfn_entries,
|
||||||
split_name_to_lfn_entry_blocks)
|
split_name_to_lfn_entry_blocks)
|
||||||
from .utils import (DATETIME, MAX_EXT_SIZE, MAX_NAME_SIZE, FATDefaults, build_lfn_short_entry_name, lfn_checksum,
|
from .utils import (DATETIME, MAX_EXT_SIZE, MAX_NAME_SIZE, FATDefaults, build_lfn_short_entry_name, build_name,
|
||||||
required_clusters_count, split_content_into_sectors, split_to_name_and_extension)
|
lfn_checksum, required_clusters_count, split_content_into_sectors, split_to_name_and_extension)
|
||||||
|
|
||||||
|
|
||||||
class File:
|
class File:
|
||||||
@@ -45,7 +45,8 @@ class File:
|
|||||||
self._first_cluster = value
|
self._first_cluster = value
|
||||||
|
|
||||||
def name_equals(self, name: str, extension: str) -> bool:
|
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:
|
def write(self, content: bytes) -> None:
|
||||||
self.entry.update_content_size(len(content))
|
self.entry.update_content_size(len(content))
|
||||||
@@ -112,7 +113,8 @@ class Directory:
|
|||||||
self._first_cluster = value
|
self._first_cluster = value
|
||||||
|
|
||||||
def name_equals(self, name: str, extension: str) -> bool:
|
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
|
@property
|
||||||
def entries_count(self) -> int:
|
def entries_count(self) -> int:
|
||||||
@@ -141,7 +143,7 @@ class Directory:
|
|||||||
|
|
||||||
def lookup_entity(self, object_name: str, extension: str): # type: ignore
|
def lookup_entity(self, object_name: str, extension: str): # type: ignore
|
||||||
for entity in self.entities:
|
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 entity
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
@@ -3,7 +3,7 @@
|
|||||||
from typing import List
|
from typing import List
|
||||||
|
|
||||||
from .entry import Entry
|
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
|
# 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).
|
# 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,
|
The extension is optional, and the long filename entry explicitly specifies it,
|
||||||
on the opposite as for short file names.
|
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
|
# the name must be terminated with NULL terminator
|
||||||
# if it doesn't fit into the set of long name directory entries
|
# if it doesn't fit into the set of long name directory entries
|
||||||
if len(lfn_record) % Entry.CHARS_PER_ENTRY != 0:
|
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:
|
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
|
:param year: denotes year starting from 1980 (0 ~ 1980, 1 ~ 1981, etc), valid values are 1980 + 0..127 inclusive
|
||||||
|
Reference in New Issue
Block a user