Skip to main content

Crate lamfat

Crate lamfat 

Source
Expand description

A FAT filesystem library implemented in Rust.

§Usage

This crate is on crates.io and can be used by adding lamfat to the dependencies in your project’s Cargo.toml.

[dependencies]
lamfat = "0.4"

§Examples

use std::io::prelude::*;

fn main() -> std::io::Result<()> {
    // Initialize a filesystem object
    let img_file = std::fs::OpenOptions::new().read(true).write(true)
        .open("tmp/fat.img")?;
    let fs = lamfat::FileSystem::new(img_file, lamfat::FsOptions::new())?;
    let root_dir = fs.root_dir();

    // Write a file
    root_dir.create_dir("foo")?;
    let mut file = root_dir.create_file("foo/hello.txt")?;
    file.truncate()?;
    file.write_all(b"Hello World!")?;

    // Read a directory
    let dir = root_dir.open_dir("foo")?;
    for r in dir.iter() {
        let entry = r?;
        println!("{}", entry.file_name());
    }
}

Macros§

debug
error
info
log
trace
warn

Structs§

ChronoTimeProviderchrono
TimeProvider implementation that returns current local time retrieved from chrono crate.
Date
A DOS compatible date.
DateTime
A DOS compatible date and time.
Dir
A FAT filesystem directory.
DirEntry
A FAT directory entry.
DirIter
An iterator over the directory entries.
Extent
An extent containing a file’s data on disk.
File
A FAT filesystem file object used for reading and writing data.
FileAttributes
A FAT file attributes.
FileSystem
A FAT filesystem object.
FileSystemStats
A FAT volume statistics.
FormatVolumeOptions
A FAT filesystem formatting options
FsOptions
A FAT filesystem mount options.
FsStatusFlags
A FAT volume status flags retrived from the Boot Sector and the allocation table second entry.
LossyOemCpConverter
Default implementation of OemCpConverter that changes all non-ASCII characters to the replacement character (U+FFFD).
NullTimeProvider
TimeProvider implementation that always returns DOS minimal date-time (1980-01-01 00:00:00).
StdIoWrapperstd
A wrapper struct for types that have implementations for std::io traits.
Time
A DOS compatible time.

Enums§

Error
Error enum with all errors that can be returned by functions from this crate
FatType
A type of FAT filesystem.
SeekFrom
Enumeration of possible methods to seek within an I/O object.

Traits§

IntoStorage
IoBase
Provides IO error as an associated type.
IoError
Trait that should be implemented by errors returned from the user supplied storage.
OemCpConverter
An OEM code page encoder/decoder.
Read
The Read trait allows for reading bytes from a source.
ReadSeek
A sum of Read and Seek traits.
ReadWriteSeek
A sum of Read, Write and Seek traits.
Seek
The Seek trait provides a cursor which can be moved within a stream of bytes.
TimeProvider
A current time and date provider.
Write
The Write trait allows for writing bytes into the sink.

Functions§

format_volume
Create FAT filesystem on a disk or partition (format a volume)

Type Aliases§

DefaultTimeProviderchrono
Default time provider implementation.