2017-11-08 09:08:07 +08:00
|
|
|
Rust FAT FS
|
|
|
|
===========
|
2017-09-23 04:36:51 +08:00
|
|
|
|
2017-11-09 06:00:30 +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)
|
2018-06-05 04:35:15 +08:00
|
|
|
[![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
|
|
|
|
2017-10-10 03:14:28 +08:00
|
|
|
FAT filesystem library implemented in Rust.
|
2017-09-24 20:34:07 +08:00
|
|
|
|
2017-09-25 04:12:38 +08:00
|
|
|
Features:
|
2017-11-08 08:35:47 +08:00
|
|
|
* read/write/create/remove file,
|
|
|
|
* enumerate directory children,
|
|
|
|
* create/remove directory,
|
2018-05-10 21:05:44 +08:00
|
|
|
* read/write file timestamps (updated automatically if `chrono` feature is enabled),
|
2017-10-21 22:25:04 +08:00
|
|
|
* FAT12, FAT16, FAT32 compatibility,
|
2018-05-10 21:05:44 +08:00
|
|
|
* LFN (Long File Names) extension supported,
|
|
|
|
* Basic no_std environment support.
|
2017-09-25 04:12:38 +08:00
|
|
|
|
2017-11-08 09:08:07 +08:00
|
|
|
Usage
|
|
|
|
-----
|
2017-11-08 08:35:47 +08:00
|
|
|
|
2017-11-08 09:08:07 +08:00
|
|
|
Put this in your `Cargo.toml`:
|
|
|
|
|
|
|
|
[dependencies]
|
2017-11-09 06:02:26 +08:00
|
|
|
fatfs = "0.2"
|
2017-11-08 09:08:07 +08:00
|
|
|
|
|
|
|
Put this in your crate root:
|
|
|
|
|
|
|
|
extern crate fatfs;
|
|
|
|
|
|
|
|
You can start using library now:
|
|
|
|
|
2018-06-01 03:40:40 +08:00
|
|
|
let img_file = File::open("fat.img")?;
|
2017-11-09 03:26:50 +08:00
|
|
|
let mut buf_stream = fatfs::BufStream::new(img_file);
|
2018-06-01 03:40:40 +08:00
|
|
|
let fs = fatfs::FileSystem::new(&mut buf_stream, fatfs::FsOptions::new())?;
|
2018-06-12 06:07:30 +08:00
|
|
|
let root_dir = fs.root_dir();
|
2018-06-01 03:40:40 +08:00
|
|
|
let mut file = root_dir.create_file("hello.txt")?;
|
|
|
|
file.write_all(b"Hello World!")?;
|
2017-11-08 08:35:47 +08:00
|
|
|
|
|
|
|
See more examples in `examples` subdirectory.
|
2017-09-23 04:36:51 +08:00
|
|
|
|
2018-05-10 07:00:24 +08:00
|
|
|
no_std usage
|
|
|
|
------------
|
|
|
|
|
|
|
|
Put this in your `Cargo.toml`:
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
fatfs = { version = "0.2", features = ["core_io"], default-features = false }
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
For building in `no_std` mode nightly Rust version compatible with current `core_io` crate is required.
|
|
|
|
See date string in `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.
|