Skip to main content

Module path_parse

Module path_parse 

Source
Expand description

Format-aware path parsing — replaces std::path::Path for cross-platform correctness.

std::path::Path uses the host OS’s path rules, which gives wrong results when parsing POSIX paths on Windows or vice versa. These functions use the path’s PathFormat to determine separator handling.

Functions§

extension
Get the extension (last “.ext” including the dot).
extension_no_dot
Get the extension without the dot (for compatibility with std::path).
file_name
Get the file name (last component after the last separator).
file_stem
Get the file stem (file_name without the last extension).
join_pathlib
Join path parts using Python pathlib constructor semantics.
parent
Get the parent (everything before the last separator). Returns the path itself if there’s no parent (like “/” returns “/”).
parts
Split a path into its components (like Python’s PurePath.parts).
pathlib_normalize
Canonicalize a filesystem path the same way Python’s pathlib does on construction.
sep
Get the canonical separator for the given format.
split
Split a path into (parent, file_name), matching pathlib behavior.
suffixes
Get all suffixes (like Python’s PurePath.suffixes). “file.tar.gz” → [“.tar”, “.gz”] Get all suffixes (extensions) of the file name.