rust-fatfs/README.md

67 lines
2.2 KiB
Markdown
Raw Normal View History

Rust FAT FS
===========
2017-09-23 04:36:51 +08:00
[![Travis Build Status](https://travis-ci.org/rafalh/rust-fatfs.svg?branch=master)](https://travis-ci.org/rafalh/rust-fatfs)
2017-10-11 06:57:31 +08:00
[![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE.txt)
[![crates.io](http://meritbadge.herokuapp.com/fatfs)](https://crates.io/crates/fatfs)
[![Documentation](https://docs.rs/fatfs/badge.svg)](https://docs.rs/fatfs)
[![Minimum rustc version](https://img.shields.io/badge/rustc-1.24+-yellow.svg)](https://blog.rust-lang.org/2018/02/15/Rust-1.24.html)
2017-09-27 20:21:01 +08:00
2018-06-20 23:55:46 +08:00
A FAT filesystem library implemented in Rust.
Features:
2018-06-20 23:55:46 +08:00
* read/write file using standard Read/Write traits,
* read directory contents,
* create/remove file or directory,
* rename/move file or directory,
2018-05-10 21:05:44 +08:00
* read/write file timestamps (updated automatically if `chrono` feature is enabled),
* FAT12, FAT16, FAT32 compatibility,
2018-06-20 23:55:46 +08:00
* LFN (Long File Names) extension is supported,
2018-05-10 21:05:44 +08:00
* Basic no_std environment support.
Usage
-----
2017-11-08 08:35:47 +08:00
2018-06-20 23:55:46 +08:00
Add this to your `Cargo.toml`:
[dependencies]
2018-06-20 23:56:03 +08:00
fatfs = "0.3"
2018-06-20 23:55:46 +08:00
and this to your crate root:
extern crate fatfs;
2018-06-20 23:58:45 +08:00
You can start using the `fatfs` library now:
let img_file = File::open("fat.img")?;
2018-06-21 01:08:50 +08:00
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!")?;
2017-11-08 08:35:47 +08:00
2018-06-21 01:08:50 +08:00
Note: it is recommended to wrap the underlying file struct in a buffering/caching object like `BufStream` from `fscommon` crate. For example:
extern crate fscommon;
let buf_stream = BufStream::new(img_file);
let fs = fatfs::FileSystem::new(img_file, fatfs::FsOptions::new())?;
2018-06-20 23:58:45 +08:00
See more examples in the `examples` subdirectory.
2017-09-23 04:36:51 +08:00
2018-05-10 07:00:24 +08:00
no_std usage
------------
2018-06-20 23:55:46 +08:00
Add this to your `Cargo.toml`:
2018-05-10 07:00:24 +08:00
[dependencies]
2018-06-20 23:56:03 +08:00
fatfs = { version = "0.3", features = ["core_io"], default-features = false }
2018-05-10 07:00:24 +08:00
2018-05-10 21:14:09 +08:00
Note: LFN support requires `alloc` and `core_io/collections` features and makes use of `alloc` crate.
2018-05-10 21:00:59 +08:00
You may have to provide a memory allocator implementation.
2018-06-20 23:55:46 +08:00
For building in `no_std` mode a nightly Rust compiler version compatible with the current `core_io` crate is required.
See a date string in the `core_io` dependency version.
2018-05-10 07:00:24 +08:00
2017-09-23 04:36:51 +08:00
License
-------
The MIT license. See LICENSE.txt.