| Crates.io | fat32-raw |
| lib.rs | fat32-raw |
| version | 1.0.1 |
| created_at | 2025-06-20 20:36:07.512984+00 |
| updated_at | 2025-11-14 14:08:50.798108+00 |
| description | Cross-platform Rust library for direct FAT32 partition manipulation with ESP support |
| homepage | https://github.com/meowrch/fat32-raw |
| repository | https://github.com/meowrch/fat32-raw |
| max_upload_size | |
| id | 1720191 |
| size | 214,519 |
A fully featured Rust library for direct work with FAT32 partitions and images. Provides low-level access to the FAT32 file system with support for reading, writing, creating and deleting files and directories.
unsafe code, strong typinguse fat32_raw::Fat32Volume;
fn main() -> std::io::Result<()> {
// Open a FAT32 image
let mut volume = Fat32Volume::open_esp(Some("esp.img"))?
.expect("Failed to open FAT32 image");
// Create directories
volume.create_dir_lfn("config")?;
// Create and write a file
volume.create_file_lfn("test.txt")?;
let content = b"Hello from fat32-raw!";
volume.write_file("test.txt", content)?;
// Read the file back
if let Some(data) = volume.read_file("test.txt")? {
println!("Content: {}", String::from_utf8_lossy(&data));
}
// Delete the file
volume.delete_file_lfn("test.txt")?;
Ok(())
}
use fat32_raw::Fat32Volume;
fn main() -> std::io::Result<()> {
// Automatic search and opening of the ESP partition
// On Windows, administrator rights are required
// On Linux, sudo may be required
let mut volume = Fat32Volume::open_esp(None::<&str>)?
.expect("ESP partition not found");
// Work with the partition the same way as with an image
volume.create_dir_lfn("MyApp")?;
volume.create_file_lfn("MyApp_config.txt")?;
volume.write_file("MyApp_config.txt", b"Configuration")?;
// List files in the root
let entries = volume.list_root()?;
for entry in entries {
println!("{} - {}",
entry.name,
if entry.is_directory { "DIR" } else { "FILE" }
);
}
Ok(())
}
Add to Cargo.toml:
[dependencies]
fat32-raw = "1.0"
The project includes a test suite that covers all operations:
# Run regular tests
cargo test
# Run tests on a real ESP (requires sudo/Administrator)
# WARNING: this test works with a real ESP partition!
sudo cargo test --test real_esp_test
fat32-raw/
βββ src/
β βββ lib.rs # Main library module
β βββ error.rs # Error handling
β βββ fat32/
β β βββ mod.rs # FAT32 module
β β βββ volume.rs # Core volume logic
β β βββ directory.rs # Directory operations
β β βββ file.rs # File operations
β β βββ fat_table.rs # FAT table handling
β β βββ lfn.rs # Long file name support
β β βββ utils.rs # Helper functions
β βββ platform/
β βββ mod.rs # Platform abstractions
β βββ windows/ # Windowsβspecific code
β βββ unix/ # Unix/Linuxβspecific code
βββ tests/
βββ real_esp_test.rs # Integration tests with real ESP
Contributions are welcome! Please:
This project is distributed under the GPLv3 license.