std::experimental::filesystem::path::relative_path
來自 cppreference.com
< cpp | experimental | fs | path
path relative_path() const; |
(檔案系統 TS) | |
返回相對於 根路徑 的路徑。如果 *this 是空路徑,則返回空路徑。
目錄 |
[編輯] 引數
(無)
[編輯] 返回值
相對於 根路徑 的路徑。
[編輯] 異常
可能丟擲實現定義的異常。
[編輯] 示例
執行此程式碼
#include <experimental/filesystem> #include <iostream> namespace fs = std::experimental::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"
[編輯] 參閱
返回路徑的根名(如果存在) (public member function) | |
返回路徑的根目錄(如果存在) (public member function) | |
返回路徑的根路徑(如果存在) (public member function) |