Compare commits
No commits in common. "b96805c1c40e486626887199e0c24f481c207981" and "99bb1e25c24b9ab3a4e8ad0b639ef39799c11aa2" have entirely different histories.
b96805c1c4
...
99bb1e25c2
3 changed files with 8 additions and 55 deletions
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
|||
38
src/dir.rs
38
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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<S: SliceLike> 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<S: SliceLike> SubSliceMut<'_, S> {
|
||||
pub fn new(fat_fs: &mut FatFs<S>, offset: u64, len: usize) -> SubSliceMut<'_, S> {
|
||||
SubSliceMut {
|
||||
|
|
@ -80,15 +70,6 @@ pub struct SubSlice<'a, S: SliceLike> {
|
|||
len: usize,
|
||||
}
|
||||
|
||||
impl<S: SliceLike> 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<S: SliceLike> SubSlice<'_, S> {
|
||||
pub fn new(fat_fs: &mut FatFs<S>, offset: u64, len: usize) -> SubSlice<'_, S> {
|
||||
SubSlice {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue