Skip to main content

Module utils

Module utils 

Source
Expand description

Utility functions for KGet.

This module provides helper functions used throughout the library:

  • Console output management
  • URL filename extraction
  • Path resolution

§Example

use kget::get_filename_from_url_or_default;

let name = get_filename_from_url_or_default(
    "https://example.com/downloads/file.zip",
    "download"
);
assert_eq!(name, "file.zip");

Functions§

auto_extract
Extract an archive at path into its parent directory using the system tool (unzip, tar, or 7z). Returns Ok(()) if the path is not a recognised archive type (no-op) or if extraction succeeds.
get_filename_from_url_or_default
Extract the filename from a URL or return a default.
is_extractable
Returns true when the path’s extension is a supported archive format.
print
Print a message to the console if not in quiet mode.
resolve_output_path
Resolve the final output path for a download.