Module util

Module util 

Source

Functions§

make_relative_symlink
Create a relative symbolic link from linkname pointing to target. Convenience wrapper around make_symlink(target, linkname, true).
make_symlink
Create a symbolic link pointing to target. If relative is true, computes and uses a relative path from link to target. Removes any existing file at the link path before creating.
output_stderr_to_string
Extract stderr from a command output as a trimmed string
output_to_string
Extract stdout from a command output as a trimmed string
parse_hex
Parse a hexadecimal string prefixed with “0x” or “0X” into a u32. Returns None if the string is not a valid hex number or lacks the prefix.
relative_path
Calculate a relative path from one directory to another. Both paths are canonicalized before computation. Returns None if either path cannot be canonicalized.
shell_quote
Quote a string for safe use in shell commands. Returns the string unchanged if it contains only safe characters, otherwise wraps it in single quotes with proper escaping.
walk_dir_files_with_ext
Recursively walk a directory and collect all files with the given extension. Skips symlinks to avoid infinite loops. Extension should not include the dot.
which
Search PATH for an executable by name. Returns the full path to the first matching executable found, or None.