std::filesystem::path::replace_filename
From cppreference.com
< cpp | filesystem | path
| 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) |