Crate cfb [−] [src]
A library for reading/writing Compound File Binary (structured storage) files. See MS-CFB for the format specification.
A Compound File Binary (CFB) file, also called a structured storage file or simply a compound file, is a bit like a simple file system within a file. A compound file contains a tree of storage objects (i.e. directories), each of which can contain stream objects (i.e. files) or other storage objects. The format is designed to allow reasonably efficient in-place mutation and resizing of these stream and storage objects, without having to completely rewrite the CFB file on disk.
Example usage
use cfb; use std::io::{Read, Seek, SeekFrom, Write}; // Open an existing compound file in read-write mode. let mut comp = cfb::open_rw("path/to/cfb/file").unwrap(); // Read in all the data from one of the streams in that compound file. let data = { let mut stream = comp.open_stream("/foo/bar").unwrap(); let mut buffer = Vec::new(); stream.read_to_end(&mut buffer).unwrap(); buffer }; // Append that data to the end of another stream in the same file. { let mut stream = comp.open_stream("/baz").unwrap(); stream.seek(SeekFrom::End(0)).unwrap(); stream.write_all(&data).unwrap(); } // Now create a new compound file, and create a new stream with the data. let mut comp2 = cfb::create("some/other/path").unwrap(); comp2.create_storage("/spam/").unwrap(); let mut stream = comp2.create_stream("/spam/eggs").unwrap(); stream.write_all(&data).unwrap();
Structs
CompoundFile |
A compound file, backed by an underlying reader/writer (such as a
|
Entries |
An iterator over the entries in a storage object. |
Entry |
Metadata about a single object (storage or stream) in a compound file. |
Stream |
A stream entry in a compound file, much like a filesystem file. |
Enums
Version |
The CFB format version to use. |
Functions
create |
Creates a new compound file with no contents at the given path. |
open |
Opens an existing compound file at the given path in read-only mode. |
open_rw |
Opens an existing compound file at the given path in read-write mode. |