car-utils 0.1.0

This crate is the ipfs car file reader writer and utils.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use rust_car::utils::archive_local;
use std::path::Path;

use crate::error::UtilError;

/// archive the local file system to car file
/// `target` is the car file
/// `source` is the directory where the archive is prepared.
pub(crate) fn archive_local_fs(
    target: impl AsRef<Path>,
    source: impl AsRef<Path>,
) -> Result<(), UtilError> {
    let target = target.as_ref();
    let file = std::fs::File::create(target).unwrap();
    archive_local(source, file)?;
    Ok(())
}