- Path("file").withStem("readme") → "readme"
- Path(".env.local").withStem("config") → "config.local"
- Path(".bashrc").withStem("profile") → "profile"
Parameters
newStemThe new stem (must be non-empty). It is treated as a literal fragment and may contain dots. No filesystem checks are performed. Returns
A new Path with its final component's stem replaced bynewStem.Throws
IfnewStemis empty.
Path.withStem
Path withStem(string newStem) const @safeReturn a new Path with the stem (base name without its last suffix) replaced, preserving the original suffixes.
Examples
- Path("archive.tar.gz").withStem("pkg") → "pkg.tar.gz"