diff --git a/src/bpb.rs b/src/bpb.rs index a1e42cf..1b0a561 100644 --- a/src/bpb.rs +++ b/src/bpb.rs @@ -250,8 +250,12 @@ impl Bpb { /// first data sector pub fn first_data_sector(&self) -> u32 { + println!("reserved sectors: {}", self.reserved_sector_count()); + println!("fat sectors: {}", self.num_fats() as u32 * self.fat_size()); + println!("root dir sectors: {}", self.root_dir_sectors()); + self.reserved_sector_count() as u32 - + (self.num_fats() as u32 * self.fat_size()) + + (self.num_fats() as u32 + self.fat_size()) + self.root_dir_sectors() as u32 } diff --git a/src/dir.rs b/src/dir.rs index 03564a3..9f3160c 100644 --- a/src/dir.rs +++ b/src/dir.rs @@ -24,27 +24,6 @@ bitflags! { } } -impl Display for Attr { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - let mut if_has_attr = |attr: Attr, c: char| { - if self.contains(attr) { - write!(f, "{}", c) - } else { - write!(f, "-") - } - }; - - if_has_attr(Attr::ReadOnly, 'R')?; - if_has_attr(Attr::Hidden, 'H')?; - if_has_attr(Attr::System, 'S')?; - if_has_attr(Attr::VolumeId, 'V')?; - if_has_attr(Attr::Directory, 'D')?; - if_has_attr(Attr::Archive, 'A')?; - - Ok(()) - } -} - #[derive(Debug)] pub struct RegularDirEntry { name: [u8; 11], @@ -76,11 +55,10 @@ impl Display for RegularDirEntry { write!( f, - "DirEntry {{ {} {: <16} created: {} modified: {} }}", - self.attr, + "DirEntry {{ {: <16} created: {} modified: {} }}", name, - self.create_time().format("%a %b %d %H:%M:%S%.3f %Y"), - self.write_time().format("%a %b %d %H:%M:%S%.3f %Y") + self.create_time(), + self.write_time() )?; Ok(()) @@ -157,16 +135,6 @@ impl RegularDirEntry { self.name[0] == 0x00 } - pub fn is_file(&self) -> bool { - !self - .attr - .intersects(Attr::Directory | Attr::System | Attr::VolumeId) - } - - pub fn is_dir(&self) -> bool { - self.attr.contains(Attr::Directory) && !self.attr.intersects(Attr::System | Attr::VolumeId) - } - pub fn name(&self) -> &[u8] { &self.name } diff --git a/src/subslice.rs b/src/subslice.rs index 4dbb43c..25063e8 100644 --- a/src/subslice.rs +++ b/src/subslice.rs @@ -1,4 +1,3 @@ -use std::fmt::Debug; use std::io::{Read, Write}; use crate::{FatFs, SliceLike}; @@ -10,15 +9,6 @@ pub struct SubSliceMut<'a, S: SliceLike> { len: usize, } -impl Debug for SubSliceMut<'_, S> { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - f.debug_struct("SubSliceMut") - .field("offset", &self.offset) - .field("len", &self.len) - .finish() - } -} - impl SubSliceMut<'_, S> { pub fn new(fat_fs: &mut FatFs, offset: u64, len: usize) -> SubSliceMut<'_, S> { SubSliceMut { @@ -80,15 +70,6 @@ pub struct SubSlice<'a, S: SliceLike> { len: usize, } -impl Debug for SubSlice<'_, S> { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - f.debug_struct("SubSliceMut") - .field("offset", &self.offset) - .field("len", &self.len) - .finish() - } -} - impl SubSlice<'_, S> { pub fn new(fat_fs: &mut FatFs, offset: u64, len: usize) -> SubSlice<'_, S> { SubSlice {