Namespaces
Variants

std::filesystem::path:: replace_filename

From cppreference.net
path & replace_filename ( const path & replacement ) ;
(C++17부터)

단일 파일명 구성 요소를 replacement 로 교체합니다.

다음 코드와 동일합니다: remove_filename ( ) ; return operator / = ( replacement ) ; .

목차

매개변수

replacement - path 파일명 구성 요소를 교체하는 데 사용되는 경로

반환값

* this

예외

구현에서 정의된 예외를 던질 수 있습니다.

예제

#include <filesystem>
#include <iostream>
namespace fs = std::filesystem;
int main()
{
    std::cout << fs::path("/foo").replace_filename("bar") << '\n'
              << fs::path("/").replace_filename("bar") << '\n'
              << fs::path("").replace_filename("pub") << '\n';
}

출력:

"/bar"
"/bar"
"pub"

참고 항목

확장자를 교체합니다
(public member function)
파일 이름 경로 구성 요소를 반환합니다
(public member function)
파일 이름 경로 구성 요소를 제거합니다
(public member function)
해당 경로 요소가 비어 있지 않은지 확인합니다
(public member function)