forked from M-Labs/rust-fatfs
Add mkfatfs example
This commit is contained in:
parent
a63458b150
commit
3628ec9825
@ -13,7 +13,7 @@ fn main() -> io::Result<()> {
|
||||
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 file = root_dir.open_file(&env::args().nth(1).expect("filename expected"))?;
|
||||
let mut buf = vec![];
|
||||
file.read_to_end(&mut buf)?;
|
||||
print!("{}", String::from_utf8_lossy(&buf));
|
||||
|
16
examples/mkfatfs.rs
Normal file
16
examples/mkfatfs.rs
Normal file
@ -0,0 +1,16 @@
|
||||
extern crate fatfs;
|
||||
extern crate fscommon;
|
||||
|
||||
use std::env;
|
||||
use std::fs;
|
||||
use std::io;
|
||||
|
||||
use fscommon::BufStream;
|
||||
|
||||
fn main() -> io::Result<()> {
|
||||
let filename = env::args().nth(1).expect("image path expected");
|
||||
let file = fs::OpenOptions::new().read(true).write(true).open(&filename)?;
|
||||
let buf_file = BufStream::new(file);
|
||||
fatfs::format_volume(buf_file, fatfs::FormatVolumeOptions::new())?;
|
||||
Ok(())
|
||||
}
|
Loading…
Reference in New Issue
Block a user