Expand description
§exFAT-fs
exFAT filesystem implementation in Rust.
§Features
- exFAT formatting
no-stdsupport- reading
§Usage
§Formatting
use exfat_fs::{
MB,
Label,
format::{Exfat, FormatVolumeOptionsBuilder},
};
use std::{io::Cursor, time::SystemTime};
let size: u64 = 32 * MB as u64;
let hello_label = Label::new("Hello".to_string()).unwrap();
let format_options = FormatVolumeOptionsBuilder::default()
.pack_bitmap(false)
.full_format(false)
.dev_size(size)
.label(hello_label)
.bytes_per_sector(512)
.build()
.unwrap();
let mut formatter = Exfat::try_from::<SystemTime>(format_options).unwrap();
let mut file = Cursor::new(vec![0u8; size as usize]);
formatter.write::<SystemTime, Cursor<Vec<u8>>>(&mut file).unwrap();§Reading
use exfat_fs::dir::{Root, entry::fs::FsElement};
use std::{fs::OpenOptions, io::Read};
// Load root directory
let mut root = Root::open(file).unwrap();
// Get contents of first element (file)
if let FsElement::F(ref mut file) = root.items()[0] {
let mut buffer = String::default();
file.read_to_string(&mut buffer).unwrap();
println!("Contents of file: {buffer}");
}§Limitations
Writing is currently not supported (WIP).
Modules§
- dir
- Directory abstractions
- disk
- Disk utility functions
- error
- format
- Filesystem formatting capabilities
- timestamp
Structs§
- Label
- A UTF16 encoded volume label. The length must not exceed 11 characters.