Expand description
A FAT filesystem library implemented in Rust.
§Usage
This crate is on crates.io and can be
used by adding fatfs
to the dependencies in your project’s Cargo.toml
.
[dependencies]
fatfs = "0.3"
And this in your crate root:
extern crate fatfs;
§Examples
// 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<()> {
// 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());
}
}
Structs§
- Chrono
Time Provider TimeProvider
implementation that returns current local time retrieved fromchrono
crate.- Date
- A DOS compatible date.
- Date
Time - A DOS compatible date and time.
- Dir
- A FAT filesystem directory.
- DirEntry
- A FAT directory entry.
- DirIter
- An iterator over the directory entries.
- File
- A FAT filesystem file object used for reading and writing data.
- File
Attributes - A FAT file attributes.
- File
System - A FAT filesystem object.
- File
System Stats - A FAT volume statistics.
- Format
Volume Options - A FAT filesystem formatting options
- FsOptions
- A FAT filesystem mount options.
- FsStatus
Flags - A FAT volume status flags retrived from the Boot Sector and the allocation table second entry.
- Lossy
OemCp Converter - Default implementation of
OemCpConverter
that changes all non-ASCII characters to the replacement character (U+FFFD). - Null
Time Provider TimeProvider
implementation that always returns DOS minimal date-time (1980-01-01 00:00:00).- Time
- A DOS compatible time.
Enums§
- FatType
- A type of FAT filesystem.
- Fatfs
Error - Error type returned as the inner error for errors with ErrorKind::Other.
- Fatfs
Numeric Error
Constants§
Traits§
- OemCp
Converter - An OEM code page encoder/decoder.
- Read
Seek - A sum of
Read
andSeek
traits. - Read
Write Seek - A sum of
Read
,Write
andSeek
traits. - Time
Provider - A current time and date provider.
Functions§
- format_
volume - Create FAT filesystem on a disk or partition (format a volume)
- validate_
filename - Ensures the filename has no trailing spaces or dots.
Type Aliases§
- Default
Time Provider - Default time provider implementation.