Expand description
§simple-fatfs
An easy-to-use FAT filesystem library designed for usage in embedded systems
§Features
no_std
support- FAT12/16/32 support
- VFAT/LFN (long filenames) support
- Auto-
impl
s forstd::io
traits and structs - Easy-to-implement
io
traits
§Examples
extern crate simple_fatfs;
use simple_fatfs::*;
use simple_fatfs::io::prelude::*;
const FAT_IMG: &[u8] = include_bytes!("../imgs/fat12.img");
fn main() {
let mut cursor = std::io::Cursor::new(FAT_IMG.to_owned());
// We can either pass by value of by (mutable) reference
let mut fs = FileSystem::from_storage(&mut cursor).unwrap();
// Let's see what entries are in the root directory
for entry in fs.read_dir(PathBuf::from("/")).unwrap() {
if entry.path().is_dir() {
println!("Directory: {}", entry.path())
} else if entry.path().is_file() {
println!("File: {}", entry.path())
} else {
unreachable!()
}
}
// the image we currently use has a file named "root.txt"
// in the root directory. Let's read it
// please keep in mind that opening a `File` borrows
// the parent `FileSystem` until that `File` is dropped
let mut file = fs.get_file(PathBuf::from("/root.txt")).unwrap();
let mut string = String::new();
file.read_to_string(&mut string);
println!("root.txt contents:\n{}", string);
}
Modules§
- io
- This module contains all the IO-related objects of the crate
Structs§
- Attributes
- A list of the various attributes specified for a file/directory
- DirEntry
- A thin wrapper for
Properties
represing a directory entry - File
- A file within the FAT filesystem
- File
System - An API to process a FAT filesystem
- PathBuf
- Represents an owned, mutable path
- Properties
- A container for file/directory properties
Enums§
- FATType
- An enum representing different versions of the FAT filesystem
- FSError
- An error indicating that a filesystem-related operation has failed
- InternalFS
Error - An error type that denotes that there is something wrong with the filesystem’s structure itself (perhaps the FS itself is malformed/corrupted)
Constants§
- FORBIDDEN_
CHARS - A list of all the characters that are forbidden to exist in a filename
- RESERVED_
FILENAMES - A list of all filenames that are reserved in Windows (and should probably also not be used by FAT)
Traits§
- Error
- Base error type
- IOError
- Base IO error type
- IOError
Kind - The kind of an
IOError