View Source Idmlx.Utils.Unzip behaviour (idmlx v0.2.1)
A utility module for unzipping files.
Summary
Callbacks
Unzips the specified ZIP file to the given destination path.
Callbacks
@callback unzip_file(zip_path :: String.t(), destination_path :: String.t()) :: {:ok, [String.t()]} | {:error, term()}
Unzips the specified ZIP file to the given destination path.
Parameters
zip_path
(string): The path to the ZIP file to be extracted.destination_path
(string): The path where the contents of the ZIP file should be extracted.
Returns
{:ok, files}
: A tuple containing:ok
and a list of extracted files if the operation is successful.{:error, reason}
: A tuple containing:error
and the reason for failure if the operation fails.
Examples
iex> Idmlx.Utils.Unzip.unzip_file("path/to/zipfile.zip", "path/to/destination")
{:ok, ["file1.txt", "file2.txt"]}
iex> Idmlx.Utils.Unzip.unzip_file("invalid/path.zip", "path/to/destination")
{:error, :enoent}