HfHub.Extract (HfHub v0.2.0)

Copy Markdown View Source

Archive detection and extraction utilities.

Summary

Functions

Returns the default extraction path for an archive.

Detects the archive type from a path.

Extracts an archive to the destination path.

Types

archive_type()

@type archive_type() :: :zip | :tar | :tar_gz | :tar_xz | :gz

Functions

default_extract_path(path)

@spec default_extract_path(Path.t()) :: Path.t()

Returns the default extraction path for an archive.

For gzip files, this is the target file path. For other archives, this is a directory path.

detect_archive_type(path)

@spec detect_archive_type(Path.t()) :: archive_type() | nil

Detects the archive type from a path.

extract(path, dest)

@spec extract(Path.t(), Path.t()) :: {:ok, Path.t()} | {:error, term()}

Extracts an archive to the destination path.

For gzip files, dest is the output file path. For other archive types, dest is the destination directory.