std::experimental::filesystem::path::stem

From cppreference.com
< cpp‎ | experimental‎ | fs‎ | path
path stem() const;
(filesystem TS)

Returns the filename identified by the path stripped of its extension.

If filename() is not equal to . or .., then returns the substring between its beginning and the last . character, if present. The . character is not included into the return value.

Contents

[edit] Parameters

(none)

[edit] Return value

The stem of the filename identified by the path.

[edit] Exceptions

(none)

[edit] Example

#include <filesystem>
#include <iostream>
 
int main()
{
    std::cout << std::fs::path("/foo/bar.txt").stem() << '\n';
    std::cout << std::fs::path("/foo/.bar").stem() << '\n';
    std::cout << std::fs::path("/foo/bar").extension() << '\n';
}

Output:

bar
 
bar

[edit] See also

returns the filename path component
(public member function)
returns the file extension path component
(public member function)