Skip to main content

create_archive

Function create_archive 

Source
pub fn create_archive(
    files: &[PathBuf],
    archive_path: &Path,
    format: ArchiveFormat,
) -> ArchiveResult<()>
Expand description

Create an archive from a list of files and/or directories.

Creates a new archive containing the specified files and directories. Directories are added recursively with all their contents.

§Arguments

  • files - Paths to files and directories to include in the archive
  • archive_path - Path where the archive will be created
  • format - The archive format to use

§Errors

Returns an error if:

§Note

Symlinks in source directories are currently skipped (not followed or stored).

§Example

use std::path::PathBuf;
use gravityfile_ops::{create_archive, ArchiveFormat};

create_archive(
    &[PathBuf::from("src/"), PathBuf::from("Cargo.toml")],
    &PathBuf::from("backup.tar.gz"),
    ArchiveFormat::TarGz,
)?;