Skip to main content

ShortFileName

Struct ShortFileName 

Source
pub struct ShortFileName(/* private fields */);
Expand description

A type representing a short filename (8.3 format)

Implementations§

Source§

impl ShortFileName

Source

pub const ALLOWED_SYMBOLS: &'static [u8] = b"$%'-_@~`!(){}^#&"

Punctuation permitted in a FAT short filename.

Source

pub fn new(bytes: [u8; 11]) -> Result<Self, CreateShortFileNameError>

Creates a short filename from its space-padded 11-byte directory form.

Source

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.

Source

pub fn as_str(&self) -> &str

Returns the formatted short filename as a string.

Source

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.

Source

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.

Source

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.

Source

pub fn to_raw_bytes(&self) -> [u8; 11]

Convert back to the raw 11-byte format for directory entries.

Source

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 ~N suffix 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.

Source

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

Source§

fn clone(&self) -> ShortFileName

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for ShortFileName

Source§

impl Debug for ShortFileName

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for ShortFileName

Source§

impl PartialEq for ShortFileName

Source§

fn eq(&self, other: &ShortFileName) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for ShortFileName

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> MaybePod for T

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.