在这个例子中
#include <iostream>
#include <experimental/filesystem>
namespace fs = std::experimental::filesystem;
int main()
{
fs::path p = fs::path("..") / ".." / "AppData";//What is it?
std::cout << "Current path is " << fs::current_path() << '\n'
<< "Canonical path for " << p << " is " << fs::canonical(p) << '\n';
}
什么是".."
,它是如何运作的?
答案 0 :(得分:0)
..是父目录,如果你在/ home / user / kat并转到..你将在/ home / user。
例如这样的代码:
fs::path parentPath = fs::current_path() / "..";
std::cout << parentPath << " → " << fs::canonical(parentPath) << std::endl;
将产生此输出(在我的电脑上):
"/home/kamil/Pulpit/build/.." → "/home/kamil/Pulpit"