2017-10-06 23:00:38 +08:00
|
|
|
extern crate fatfs;
|
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;
|
2017-09-24 20:34:23 +08:00
|
|
|
use std::io::prelude::*;
|
2017-09-23 05:20:06 +08:00
|
|
|
use std::str;
|
|
|
|
|
2017-10-09 20:59:52 +08:00
|
|
|
use fatfs::{FileSystem, BufStream};
|
2017-09-23 05:20:06 +08:00
|
|
|
|
|
|
|
fn main() {
|
2017-09-24 03:53:32 +08:00
|
|
|
let file = File::open("resources/fat32.img").unwrap();
|
2017-10-09 20:59:52 +08:00
|
|
|
let mut buf_rdr = BufStream::new(file);
|
2017-10-07 20:56:50 +08:00
|
|
|
let fs = FileSystem::new(&mut buf_rdr).unwrap();
|
2017-09-23 05:20:06 +08:00
|
|
|
let mut root_dir = fs.root_dir();
|
2017-09-25 04:12:38 +08:00
|
|
|
let mut file = root_dir.open_file(&env::args().nth(1).unwrap()).unwrap();
|
2017-09-24 20:34:23 +08:00
|
|
|
let mut buf = vec![];
|
|
|
|
file.read_to_end(&mut buf).unwrap();
|
|
|
|
print!("{}", str::from_utf8(&buf).unwrap());
|
2017-09-23 05:20:06 +08:00
|
|
|
}
|