std::filesystem::path::relative_path
提供: cppreference.com
< cpp | filesystem | path
path relative_path() const; |
(C++17以上) | |
ルートパスからの相対パス、つまり、 *this のルートパスより後のすべての汎用形式要素を合成したパス名を返します。 *this が空であれば空のパスを返します。
目次 |
[編集] 引数
(なし)
[編集] 戻り値
root_path からの相対パス。
[編集] 例外
(なし)
[編集] 例
Run this code
#include <iostream> #include <filesystem> namespace fs = std::filesystem; int main() { fs::path p = fs::current_path(); std::cout << "The current path " << p << " decomposes into:\n" << "root-path " << p.root_path() << '\n' << "relative path " << p.relative_path() << '\n'; }
出力例:
The current path "C:\Users\abcdef\Local Settings\temp" decomposes into: root-path "C:\" relative path "Users\abcdef\Local Settings\temp"
[編集] 関連項目
もしあれば、パスのルート名を返します (パブリックメンバ関数) | |
もしあれば、パスのルートディレクトリを返します (パブリックメンバ関数) | |
もしあれば、パスのルートパスを返します (パブリックメンバ関数) |