Returns: root-directory, if pathstring includes root-directory, otherwise path().
Returns: root_name() / root_directory().
Returns: A path composed from pathstring, if !empty(), beginning with the first filename after root-path. Otherwise, path().
Returns: (empty() || begin() == --end()) ? path() : pp, where pp is constructed as if by starting with an empty path and successively applying operator/= for each element in the range [begin(), --end()).
Returns: empty() ? path() : *--end().
[ Example:
std::cout << path("/foo/bar.txt").filename(); // outputs "bar.txt" std::cout << path("/").filename(); // outputs "/" std::cout << path(".").filename(); // outputs "." std::cout << path("..").filename(); // outputs ".."
— end example ]
Returns: if filename() contains a period but does not consist solely of one or two periods, returns the substring of filename() starting at its beginning and ending with the character before the last period. Otherwise, returns filename().
[ Example:
std::cout << path("/foo/bar.txt").stem(); // outputs "bar" path p = "foo.bar.baz.tar"; for (; !p.extension().empty(); p = p.stem()) std::cout << p.extension() << '\n'; // outputs: .tar // .baz // .bar
— end example ]
Returns: if filename() contains a period but does not consist solely of one or two periods, returns the substring of filename() starting at the rightmost period and for the remainder of the path. Otherwise, returns an empty path object.
Remarks: Implementations are permitted to define additional behavior for file systems which append additional elements to extensions, such as alternate data streams or partitioned dataset names.
[ Example:
std::cout << path("/foo/bar.txt").extension(); // outputs ".txt"
— end example ]
[ Note: The period is included in the return value so that it is possible to distinguish between no extension and an empty extension. Also note that for a path p, p.stem()+p.extension() == p.filename(). — end note ]