pub struct LongFileName { /* private fields */ }Expand description
A Long File Name stored as UTF-16.
LFN entries on disk encode the filename in UTF-16LE. Storing the data in its native form avoids two classes of bugs that previously lived here (see issue #28): the buffer never holds invalid UTF-8, and surrogate pairs (characters outside the Basic Multilingual Plane, e.g. emoji) are preserved correctly regardless of how the pair lands across LFN entry boundaries — the conversion to scalar values happens once, at access time.
Implementations§
Source§impl LongFileName
impl LongFileName
Sourcepub const CHARS_PER_ENTRY: usize = 13
pub const CHARS_PER_ENTRY: usize = 13
Number of UTF-16 code units stored per LFN directory entry
Sourcepub fn prepend_lfn_entry(
&mut self,
name1: &[u8; 10],
name2: &[u8; 12],
name3: &[u8; 4],
)
pub fn prepend_lfn_entry( &mut self, name1: &[u8; 10], name2: &[u8; 12], name3: &[u8; 4], )
Prepend UTF-16LE characters from an LFN entry. LFN entries are stored in reverse order, so we prepend. Characters are: 5 from name1, 6 from name2, 2 from name3.
Sourcepub fn chars(&self) -> impl Iterator<Item = char> + '_
pub fn chars(&self) -> impl Iterator<Item = char> + '_
Iterate over the decoded scalar values of the filename.
Lone surrogates (which the spec disallows but a malformed image could
contain) are reported as char::REPLACEMENT_CHARACTER (U+FFFD).
Sourcepub fn from_str_utf16(name: &str) -> Option<Self>
pub fn from_str_utf16(name: &str) -> Option<Self>
Encode name as UTF-16LE into the buffer. Returns None if the name
exceeds LFN_MAX_UTF16_UNITS (the FAT spec cap for LFN names).
Used by the write path to remember the name in-memory after creating
a file; the chars stay in UTF-16 so the disk-side LFN write can pull
them out without a second UTF-8 conversion.
Trait Implementations§
Source§impl Clone for LongFileName
impl Clone for LongFileName
Source§fn clone(&self) -> LongFileName
fn clone(&self) -> LongFileName
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for LongFileName
Available on crate feature lfn only.
impl Debug for LongFileName
lfn only.Source§impl Default for LongFileName
Available on crate feature lfn only.
impl Default for LongFileName
lfn only.Source§impl Display for LongFileName
Available on crate feature lfn only.
impl Display for LongFileName
lfn only.