Path.withSuffix
Path withSuffix(string newSuffix) const @safeReturn a new Path with the last suffix (extension) replaced.
Modeled after pathlib's with_suffix:
newSuffixmust be empty (to remove the last suffix) or start with a dot (e.g., ".md").- If there is no suffix and
newSuffixis non-empty, it is appended to the name. - Only the last suffix is affected; earlier suffixes (e.g., ".tar" in "archive.tar.gz")
remain part of the stem.
- Dotfiles without additional dots (e.g., ".bashrc") are treated as having no suffix;
in that case withSuffix(".txt") yields ".bashrc.txt".
Parameters
newSuffix | The new file suffix. Must start with a dot or be empty. |
Returns
A new Path with the last suffix replaced accordingly.