forked from M-Labs/rust-fatfs
892c3974d3
BufStream is universal and can be used with any filesystem so its place is in different crate. Also moved Partition struct from examples to fscommon::StreamSlice struct (please note constructor arguments has changed).
22 lines
577 B
Rust
22 lines
577 B
Rust
extern crate fatfs;
|
|
extern crate fscommon;
|
|
|
|
use std::env;
|
|
use std::fs::File;
|
|
use std::io::{self, prelude::*};
|
|
|
|
use fatfs::{FileSystem, FsOptions};
|
|
use fscommon::BufStream;
|
|
|
|
fn main() -> io::Result<()> {
|
|
let file = File::open("resources/fat32.img")?;
|
|
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![];
|
|
file.read_to_end(&mut buf)?;
|
|
print!("{}", String::from_utf8_lossy(&buf));
|
|
Ok(())
|
|
}
|