2017-10-06 23:00:38 +08:00
|
|
|
extern crate fatfs;
|
2018-06-16 23:57:29 +08:00
|
|
|
extern crate fscommon;
|
2017-09-23 05:20:06 +08:00
|
|
|
|
2017-09-24 20:34:23 +08:00
|
|
|
use std::env;
|
2017-09-23 05:20:06 +08:00
|
|
|
use std::fs::File;
|
2018-06-01 03:40:40 +08:00
|
|
|
use std::io::{self, prelude::*};
|
2017-09-23 05:20:06 +08:00
|
|
|
|
2018-06-16 23:57:29 +08:00
|
|
|
use fatfs::{FileSystem, FsOptions};
|
|
|
|
use fscommon::BufStream;
|
2017-09-23 05:20:06 +08:00
|
|
|
|
2018-06-01 03:40:40 +08:00
|
|
|
fn main() -> io::Result<()> {
|
|
|
|
let file = File::open("resources/fat32.img")?;
|
2018-06-14 05:26:13 +08:00
|
|
|
let buf_rdr = BufStream::new(file);
|
|
|
|
let fs = FileSystem::new(buf_rdr, FsOptions::new())?;
|
2018-06-12 06:07:30 +08:00
|
|
|
let root_dir = fs.root_dir();
|
2018-06-01 03:40:40 +08:00
|
|
|
let mut file = root_dir.open_file(&env::args().nth(1).unwrap())?;
|
2017-09-24 20:34:23 +08:00
|
|
|
let mut buf = vec![];
|
2018-06-01 03:40:40 +08:00
|
|
|
file.read_to_end(&mut buf)?;
|
|
|
|
print!("{}", String::from_utf8_lossy(&buf));
|
|
|
|
Ok(())
|
2017-09-23 05:20:06 +08:00
|
|
|
}
|