11// based on https://crates.io/crates/mini_fat by https://github.com/gridbugs
22
33use crate :: disk:: { AlignedBuffer , Read , Seek , SeekFrom } ;
4- use core:: { char:: DecodeUtf16Error , fmt :: Write as _ } ;
4+ use core:: char:: DecodeUtf16Error ;
55
66const DIRECTORY_ENTRY_BYTES : usize = 32 ;
77const UNUSED_ENTRY_PREFIX : u8 = 0xE5 ;
@@ -312,6 +312,7 @@ impl FatType {
312312 }
313313}
314314
315+ #[ allow( dead_code) ]
315316#[ derive( Clone ) ]
316317pub struct DirectoryEntry < ' a > {
317318 short_name : & ' a str ,
@@ -325,37 +326,6 @@ pub struct DirectoryEntry<'a> {
325326}
326327
327328impl < ' a > DirectoryEntry < ' a > {
328- pub fn name ( & self ) -> impl Iterator < Item = Result < char , DecodeUtf16Error > > + ' a {
329- let mut long_name = {
330- let iter = self
331- . long_name_1
332- . chunks ( 2 )
333- . chain ( self . long_name_2 . chunks ( 2 ) )
334- . chain ( self . long_name_3 . chunks ( 2 ) )
335- . map ( |c| u16:: from_le_bytes ( c. try_into ( ) . unwrap ( ) ) )
336- . take_while ( |& c| c != 0 ) ;
337- char:: decode_utf16 ( iter) . peekable ( )
338- } ;
339- let short_name = {
340- let iter = self . short_name . chars ( ) ;
341- let extension_iter = {
342- let raw = "." . chars ( ) . chain ( self . short_name_extension . chars ( ) ) ;
343- raw. take ( if self . short_name_extension . is_empty ( ) {
344- 0
345- } else {
346- self . short_name_extension . len ( ) + 1
347- } )
348- } ;
349- iter. chain ( extension_iter) . map ( Ok )
350- } ;
351-
352- if long_name. peek ( ) . is_some ( ) {
353- long_name. chain ( short_name. take ( 0 ) )
354- } else {
355- long_name. chain ( short_name. take ( usize:: MAX ) )
356- }
357- }
358-
359329 pub fn is_directory ( & self ) -> bool {
360330 self . attributes & directory_attributes:: DIRECTORY != 0
361331 }
@@ -370,6 +340,7 @@ struct RawDirectoryEntryNormal<'a> {
370340 file_size : u32 ,
371341}
372342
343+ #[ allow( dead_code) ]
373344#[ derive( Debug ) ]
374345struct RawDirectoryEntryLongName < ' a > {
375346 order : u8 ,
0 commit comments