std::filesystem::path:: filename
From cppreference.net
<
cpp
|
filesystem
|
path
C++
std::filesystem::path
| Member types | ||||||||||||||||||||||||||
| Member constants | ||||||||||||||||||||||||||
| Member functions | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
| Path decomposition | ||||||||||||||||||||||||||
| Non-member functions | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
| Helper classes | ||||||||||||||||||||||||||
|
path filename
(
)
const
;
|
(C++17부터) | |
경로의 일반 형식 파일 이름 구성 요소를 반환합니다.
다음 코드와 동일합니다: relative_path ( ) . empty ( ) ? path ( ) : *-- end ( ) .
목차 |
매개변수
(없음)
반환값
경로로 식별된 파일 이름.
예외
구현에서 정의된 예외를 던질 수 있습니다.
예제
이 코드 실행
#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'; }
출력:
"bar.txt" ".bar" "" "." ".." "." ".." "" "host"
참고 항목
|
파일 확장자 경로 구성 요소를 반환합니다
(public member function) |
|
|
스템 경로 구성 요소를 반환합니다 (최종 확장자를 제외한 파일명)
(public member function) |
|
|
마지막 경로 구성 요소를 다른 경로로 교체합니다
(public member function) |
|
|
해당 경로 요소가 비어 있지 않은지 확인합니다
(public member function) |