Function apply_zip

Source
pub fn apply_zip(
    path_base: &str,
    delta: PatchSet,
    path_after: String,
) -> Result<(), Error>
Expand description

Applies a patch set to transform a zip archive into a new version.

Takes a source zip archive and a patch set, and creates a new zip archive that represents the target version. Validates all operations and maintains the integrity of the archive structure.

ยงExample

use files_diff::{diff_zip, apply_zip, DiffAlgorithm, CompressAlgorithm};

// First generate a patch set
let patch_set = diff_zip(
    "source.zip".to_string(),
    "target.zip".to_string(),
    DiffAlgorithm::Rsync020,
    CompressAlgorithm::Zstd
)?;

// Apply the patches to create a new version
apply_zip(
    "source.zip",
    patch_set,
    "result.zip".to_string()
)?;

The function:

  • Preserves directory structure
  • Handles file additions, deletions, and modifications
  • Maintains file metadata
  • Validates all operations during application