[fs.path.decompose] (original) (raw)

31 Input/output library [input.output]

31.12 File systems [filesystems]

31.12.6 Class path [fs.class.path]

31.12.6.5 Members [fs.path.member]

31.12.6.5.9 Decomposition [fs.path.decompose]

Returns: root-name, if the pathname in the generic format includes root-name, otherwise path().

path root_directory() const;

Returns: root_name() / root_directory().

path relative_path() const;

Returns: A path composed from the pathname in the generic format, if empty() is false, beginning with the first filename after root_path().

Otherwise, path().

path parent_path() const;

Returns: *this if has_relative_path() is false, otherwise a path whose generic format pathname is the longest prefix of the generic format pathname of *thisthat produces one fewer element in its iteration.

Returns: relative_path().empty() ? path() : *--end().

[Example 1: path("/foo/bar.txt").filename(); path("/foo/bar").filename(); path("/foo/bar/").filename(); path("/").filename(); path("//host").filename(); path(".").filename(); path("..").filename(); — _end example_]

Returns: Let f be the generic format pathname of filename().

Returns a path whose pathname in the generic format is

[Example 2: std::cout << path("/foo/bar.txt").stem(); path p = "foo.bar.baz.tar";for (; !p.extension().empty(); p = p.stem()) std::cout << p.extension() << '\n'; — _end example_]

Returns: A path whose pathname in the generic format is the suffix of filename() not included in stem().

[Example 3: path("/foo/bar.txt").extension(); path("/foo/bar").extension(); path("/foo/.profile").extension(); path(".bar").extension(); path("..bar").extension(); — _end example_]

[Note 1:

The period is included in the return value so that it is possible to distinguish between no extension and an empty extension.

— _end note_]

[Note 2:

On non-POSIX operating systems, for a path p, it is possible that p.stem() + p.extension() == p.filename() is false, even though the generic format pathnames are the same.

— _end note_]