Fix doc-tests

This commit is contained in:
Rafał Harabień 2018-06-20 19:52:18 +02:00
parent 00b5ee52d3
commit fe90d952bf

View File

@ -18,27 +18,37 @@
//! //!
//! # Examples //! # Examples
//! //!
//! Initialize a filesystem object (note: `fscommon` crate is used to speedup IO operations):
//! ```rust //! ```rust
//! let img_file = File::open("fat.img")?; //! // Declare external crates
//! let buf_stream = fscommon::BufStream::new(img_file); //! // Note: `fscommon` crate is used to speedup IO operations
//! let fs = fatfs::FileSystem::new(buf_stream, fatfs::FsOptions::new())?; //! extern crate fatfs;
//! ``` //! extern crate fscommon;
//! Write a file: //!
//! ```rust //! use std::io::prelude::*;
//! let root_dir = fs.root_dir(); //!
//! root_dir.create_dir("foo/bar")?; //! fn main() -> std::io::Result<()> {
//! let mut file = root_dir.create_file("foo/bar/hello.txt")?; //! # std::fs::copy("resources/fat16.img", "tmp/fat.img")?;
//! file.truncate()?; //! // Initialize a filesystem object
//! file.write_all(b"Hello World!")?; //! let img_file = std::fs::OpenOptions::new().read(true).write(true)
//! ``` //! .open("tmp/fat.img")?;
//! Read a directory: //! let buf_stream = fscommon::BufStream::new(img_file);
//! ```rust //! let fs = fatfs::FileSystem::new(buf_stream, fatfs::FsOptions::new())?;
//! let root_dir = fs.root_dir(); //! let root_dir = fs.root_dir();
//! let dir = root_dir.open_dir("foo/bar")?; //!
//! for r in dir.iter()? { //! // Write a file
//! let entry = r?; //! root_dir.create_dir("foo")?;
//! println!(entry.file_name()); //! let mut file = root_dir.create_file("foo/hello.txt")?;
//! file.truncate()?;
//! file.write_all(b"Hello World!")?;
//!
//! // Read a directory
//! let dir = root_dir.open_dir("foo")?;
//! for r in dir.iter() {
//! let entry = r?;
//! println!("{}", entry.file_name());
//! }
//! # std::fs::remove_file("tmp/fat.img")?;
//! # Ok(())
//! } //! }
//! ``` //! ```