pub struct ShortFileName(/* private fields */);Expand description
A type representing a short filename (8.3 format)
Implementations§
Source§impl ShortFileName
impl ShortFileName
Sourcepub const ALLOWED_SYMBOLS: &'static [u8] = b"$%'-_@~`!(){}^#&"
pub const ALLOWED_SYMBOLS: &'static [u8] = b"$%'-_@~`!(){}^#&"
Punctuation permitted in a FAT short filename.
Sourcepub fn new(bytes: [u8; 11]) -> Result<Self, CreateShortFileNameError>
pub fn new(bytes: [u8; 11]) -> Result<Self, CreateShortFileNameError>
Creates a short filename from its space-padded 11-byte directory form.
Sourcepub fn raw_bytes(&self) -> [u8; 11]
pub fn raw_bytes(&self) -> [u8; 11]
Get the raw 11-byte name for checksum calculation.
Operates on the underlying byte buffer directly — does NOT go through
Self::as_str, which would panic on non-ASCII OEM bytes (e.g.
CP437 0x82 for é). The 11-byte form is what’s stored in the FAT
directory entry, so byte-level access is the correct level here
regardless of encoding.
Sourcepub fn with_nt_case(&self, flags: NtCaseFlags) -> ShortFileName
pub fn with_nt_case(&self, flags: NtCaseFlags) -> ShortFileName
Returns a copy of this 8.3 name with the base and/or extension
lowercased according to the Windows NT DIR_NTRes case flags.
FAT stores 8.3 names uppercase on disk; the case flags (see
NtCaseFlags) record that the name was
originally entered lowercase so it can be presented that way without a
long-file-name entry. Only ASCII letters are re-cased; any other bytes
(OEM high bytes, digits, symbols, the . separator) pass through
unchanged.
Sourcepub fn matches(&self, name: &str) -> bool
pub fn matches(&self, name: &str) -> bool
Check if this short filename matches a given name (case-insensitive). Handles both padded (“TEST .TXT”) and unpadded (“TEST.TXT”) formats.
Sourcepub fn lfn_checksum(&self) -> u8
pub fn lfn_checksum(&self) -> u8
Calculate the LFN checksum for this short filename. This is used to validate that LFN entries belong to this short name entry.
Sourcepub fn to_raw_bytes(&self) -> [u8; 11]
pub fn to_raw_bytes(&self) -> [u8; 11]
Convert back to the raw 11-byte format for directory entries.
Sourcepub fn from_long_name(
name: &str,
suffix: u8,
) -> Result<Self, CreateShortFileNameError>
pub fn from_long_name( name: &str, suffix: u8, ) -> Result<Self, CreateShortFileNameError>
Generate an 8.3 short filename from a long name.
Rules:
- Uppercase all ASCII letters
- Strip invalid characters, replace with
_ - Base name max 8 chars, extension max 3 chars
- Add
~Nsuffix for collisions (caller should increment suffix)
Non-ASCII characters always become _. To preserve OEM-encoded Latin
characters (e.g. é → CP437 0x82), use from_long_name_with.
Sourcepub fn from_long_name_with(
name: &str,
suffix: u8,
oem: &dyn OemCpConverter,
) -> Result<Self, CreateShortFileNameError>
pub fn from_long_name_with( name: &str, suffix: u8, oem: &dyn OemCpConverter, ) -> Result<Self, CreateShortFileNameError>
Like from_long_name, but routes non-ASCII
characters through the supplied OemCpConverter rather than
dropping them to _.
Characters the converter cannot encode still become _.
Trait Implementations§
Source§impl Clone for ShortFileName
impl Clone for ShortFileName
Source§fn clone(&self) -> ShortFileName
fn clone(&self) -> ShortFileName
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more