1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
//! A FAT filesystem library implemented in Rust.
//!
//! # Usage
//!
//! This crate is [on crates.io](https://crates.io/crates/fatfs) and can be
//! used by adding `fatfs` to the dependencies in your project's `Cargo.toml`.
//!
//! ```toml
//! [dependencies]
//! fatfs = "0.3"
//! ```
//!
//! And this in your crate root:
//!
//! ```rust
//! extern crate fatfs;
//! ```
//!
//! # Examples
//!
//! ```rust
//! // Declare external crates
//! // Note: `fscommon` crate is used to speedup IO operations
//! extern crate fatfs;
//! extern crate fscommon;
//!
//! use std::io::prelude::*;
//!
//! fn main() -> std::io::Result<()> {
//! # std::fs::copy("resources/fat16.img", "tmp/fat.img")?;
//! // Initialize a filesystem object
//! let img_file = std::fs::OpenOptions::new().read(true).write(true)
//! .open("tmp/fat.img")?;
//! let buf_stream = fscommon::BufStream::new(img_file);
//! let fs = fatfs::FileSystem::new(buf_stream, fatfs::FsOptions::new())?;
//! let root_dir = fs.root_dir();
//!
//! // Write a file
//! root_dir.create_dir("foo")?;
//! 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(())
//! }
//! ```
// Disable warnings to not clutter code with cfg too much
// Inclusive ranges requires Rust 1.26.0
// `dyn` syntax requires Rust 1.27.0
// `alloc` compiler feature is needed in Rust before 1.36
extern crate byteorder;
extern crate bitflags;
extern crate log;
extern crate chrono;
extern crate core_io;
extern crate alloc;
use byteorder as byteorder_ext;
use byteorder_core_io as byteorder_ext;
use core_io as io;
use std as core;
use io;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;