NLdoc.Conversion.Docx.Zip (NLdoc.Conversion.Reader.Docx v1.1.2)

View Source

This module implements some helper functions for handling .zip files.

Summary

Functions

Create a .zip file from a list of files.

Extract a .zip file to a directory. The first argument should be the path to the .zip file to extract. The second argument should be the path to the directory where the contents of the .zip file will be extracted to. If this directory does not yet exist, it will be created.

Functions

create(files, output_zip_path)

@spec create([String.t()], String.t()) ::
  {:ok, :done} | {:error, atom() | String.t() | Exception.t()}

create!(files, output_zip_path)

@spec create!([String.t()], String.t()) :: :ok

Create a .zip file from a list of files.

The first argument should be a list of paths to the files that should be included in the .zip file. It is highly recommended to use absolute paths, though paths relative to the application's CWD will work as well.

The second argument should be the path to the .zip file that should be created.

extract(archive_path, extraction_path)

@spec extract(String.t(), String.t()) ::
  :ok | {:error, atom() | String.t() | Exception.t()}

extract!(archive_path, extraction_path)

@spec extract!(String.t(), String.t()) :: :ok

Extract a .zip file to a directory. The first argument should be the path to the .zip file to extract. The second argument should be the path to the directory where the contents of the .zip file will be extracted to. If this directory does not yet exist, it will be created.

This function will raise an error if the .zip file does not exist, if the extraction path cannot be created, or if the extraction fails. If you prefer an error tuple instead, use extract/2.