Crate filearco [] [src]

This crate creates and reads FileArco archives.

Example

This example creates a FileArco v1 archive file containing 3 text files. It then opens the newly created file and outputs the text of all 3 stored files.

extern crate filearco;

use std::fs::File;
use std::path::Path;

// Retrieve metadata on files to archive.
let base_path = Path::new("testarchives/simple");
let file_data = filearco::get_file_data(base_path).ok().unwrap();

// Create FileArco v1 archive file.
// Make sure parent directory exists first.
let archive_path = Path::new("tmptest/doctest_simple_v1.fac");
let archive_file = File::create(archive_path).ok().unwrap();
filearco::v1::FileArco::make(file_data, archive_file).ok().unwrap();

// Map archive file into memory.
let archive = filearco::v1::FileArco::new(archive_path).ok().unwrap();

// Retrieve and print contents of archive.
let cargo_toml = archive.get("Cargo.toml").unwrap();
println!("{}", cargo_toml.as_str().ok().unwrap());
let license_mit = archive.get("LICENSE-MIT").unwrap();
println!("{}", license_mit.as_str().ok().unwrap());
let license_apache = archive.get("LICENSE-APACHE").unwrap();
println!("{}", license_apache.as_str().ok().unwrap());

Modules

v1

This module creates and manages a FileArco v1 archive file.

Structs

FileData

This struct contains information on all the normal files in a given location.

Enums

Error

This is the top level Error for this crate.

FileDataError

Errors retrieving information on files

Functions

get_file_data

This function retrieves basic information (i.e. path, length and checksum) of all files under a specific base_path.

Type Definitions

Result

This is the result type.