Simplify examples using new FileSystem struct definition
This commit is contained in:
parent
217b6046f1
commit
5574c2af73
@ -8,8 +8,8 @@ use fatfs::{FileSystem, FsOptions, BufStream};
|
||||
|
||||
fn main() -> io::Result<()> {
|
||||
let file = File::open("resources/fat32.img")?;
|
||||
let mut buf_rdr = BufStream::new(file);
|
||||
let fs = FileSystem::new(&mut buf_rdr, FsOptions::new())?;
|
||||
let buf_rdr = BufStream::new(file);
|
||||
let fs = FileSystem::new(buf_rdr, FsOptions::new())?;
|
||||
let root_dir = fs.root_dir();
|
||||
let mut file = root_dir.open_file(&env::args().nth(1).unwrap())?;
|
||||
let mut buf = vec![];
|
||||
|
@ -25,8 +25,8 @@ fn format_file_size(size: u64) -> String {
|
||||
|
||||
fn main() -> io::Result<()> {
|
||||
let file = File::open("resources/fat32.img")?;
|
||||
let mut buf_rdr = BufStream::new(file);
|
||||
let fs = FileSystem::new(&mut buf_rdr, FsOptions::new())?;
|
||||
let buf_rdr = BufStream::new(file);
|
||||
let fs = FileSystem::new(buf_rdr, FsOptions::new())?;
|
||||
let root_dir = fs.root_dir();
|
||||
let dir = match env::args().nth(1) {
|
||||
None => root_dir,
|
||||
|
@ -74,9 +74,9 @@ fn main() -> io::Result<()> {
|
||||
// Create partition using provided start address and size in bytes
|
||||
let partition = Partition::<fs::File>::new(file, first_lba, last_lba - first_lba + 1)?;
|
||||
// Create buffered stream to optimize file access
|
||||
let mut buf_rdr = BufStream::new(partition);
|
||||
let buf_rdr = BufStream::new(partition);
|
||||
// Finally initialize filesystem struct using provided partition
|
||||
let fs = FileSystem::new(&mut buf_rdr, FsOptions::new())?;
|
||||
let fs = FileSystem::new(buf_rdr, FsOptions::new())?;
|
||||
// Read and display volume label
|
||||
println!("Volume Label: {}", fs.volume_label());
|
||||
// other operations...
|
||||
|
@ -13,9 +13,9 @@ fn main() -> io::Result<()> {
|
||||
return Err(err);
|
||||
}
|
||||
};
|
||||
let mut buf_stream = BufStream::new(img_file);
|
||||
let buf_stream = BufStream::new(img_file);
|
||||
let options = FsOptions::new().update_accessed_date(true);
|
||||
let fs = FileSystem::new(&mut buf_stream, options)?;
|
||||
let fs = FileSystem::new(buf_stream, options)?;
|
||||
let mut file = fs.root_dir().create_file("hello.txt")?;
|
||||
file.write_all(b"Hello World!")?;
|
||||
Ok(())
|
||||
|
Loading…
Reference in New Issue
Block a user