path filename() const;
(since C++17)Returns the generic-format filename component of the path.
Equivalent to relative_path().empty() ? path() : *--end().
[edit] Parameters(none)
[edit] Return valueThe filename identified by the path.
[edit] ExceptionsMay throw implementation-defined exceptions.
[edit] Example#include <filesystem> #include <iostream> namespace fs = std::filesystem; int main() { std::cout << fs::path("/foo/bar.txt").filename() << '\n' << fs::path("/foo/.bar").filename() << '\n' << fs::path("/foo/bar/").filename() << '\n' << fs::path("/foo/.").filename() << '\n' << fs::path("/foo/..").filename() << '\n' << fs::path(".").filename() << '\n' << fs::path("..").filename() << '\n' << fs::path("/").filename() << '\n' << fs::path("//host").filename() << '\n'; }
Output:
"bar.txt" ".bar" "" "." ".." "." ".." "" "host"[edit] See also returns the file extension path component
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4