rafalh / rust-fatfs

A FAT filesystem library implemented in Rust.
MIT License
302 stars 53 forks source link
fat fat12 fat16 fat32 filesystem-library rust

Rust FAT FS

CI Status MIT licensed crates.io Documentation Minimum rustc version

A FAT filesystem library implemented in Rust.

Features:

Usage

Add this to your Cargo.toml:

[dependencies]
fatfs = "0.4"

You can start using the fatfs library now:

let img_file = File::open("fat.img")?;
let fs = fatfs::FileSystem::new(img_file, fatfs::FsOptions::new())?;
let root_dir = fs.root_dir();
let mut file = root_dir.create_file("hello.txt")?;
file.write_all(b"Hello World!")?;

Note: it is recommended to wrap the underlying file struct in a buffering/caching object like BufStream from fscommon crate. For example:

let buf_stream = BufStream::new(img_file);
let fs = fatfs::FileSystem::new(buf_stream, fatfs::FsOptions::new())?;

See more examples in the examples subdirectory.

no_std usage

Add this to your Cargo.toml:

[dependencies]
fatfs = { version = "0.4", default-features = false }

Additional features:

Note: above features are enabled by default and were designed primarily for no_std usage.

License

The MIT license. See LICENSE.txt.