forked from M-Labs/rust-fatfs
2304b13ec4
Dir methods do not change Dir object itself. They usually clone inner stream so no change really happens self struct. Underlying partition is modified but it does not have to affect API. For example see std::fs::File::set_len. This change greatly simplifies rename API usage.
20 lines
549 B
Rust
20 lines
549 B
Rust
extern crate fatfs;
|
|
|
|
use std::env;
|
|
use std::fs::File;
|
|
use std::io::{self, prelude::*};
|
|
|
|
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 root_dir = fs.root_dir();
|
|
let mut file = root_dir.open_file(&env::args().nth(1).unwrap())?;
|
|
let mut buf = vec![];
|
|
file.read_to_end(&mut buf)?;
|
|
print!("{}", String::from_utf8_lossy(&buf));
|
|
Ok(())
|
|
}
|