diff --git a/examples/cat.rs b/examples/cat.rs index dba0411..375996f 100644 --- a/examples/cat.rs +++ b/examples/cat.rs @@ -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)); diff --git a/examples/mkfatfs.rs b/examples/mkfatfs.rs new file mode 100644 index 0000000..cd0d40a --- /dev/null +++ b/examples/mkfatfs.rs @@ -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(()) +}