C++ 实验文件系统库不完整?
C++ experimental filesystem library incomplete?
我在 <experimental/filesystem>
include 中找到了一个巧妙的方法,它告诉我路径是文件还是目录,但是当我尝试在 g++ v 7.4.0 上使用它时它给我一个错误。我尝试使用的方法是:.is_regular_file()
.
它甚至在 cppref 上,https://en.cppreference.com/w/cpp/experimental/fs/is_regular_file。
但是在编译时出现“...没有名为 'is_regular_file' 的成员”错误。我无法使用常规文件系统,因为我的目标系统 (Ubuntu 18.04 LTS) 预装了 g++ 7.4.0,无法更改。
知道我做错了什么吗?有谁知道 is_regular_file 的替代方法,这样我就可以检查文件是目录还是文件?
我的包括:
#include <string>
#include <vector>
#include <experimental/filesystem>
我正在使用以下标志:-std=c++17 -lstdc++fs -O3 -Wall -Wextra -Wpedantic -Werror
您感到困惑,因为 std::experimental::filesystem
(<experimental/filesystem>
) 包含文件系统 TS,而不是 std::filesystem
(<filesystem>
) 如果你的标准库实现了它们(尽管后者基于前者)。
在TS中有一个std::experimental::filesystem::is_regular_file
free function (which you link to in the question). This free std::filesystem::is_regular_file
也存在于C++17中
但是在 C++17 中 std::filesystem::directory_entry
class also has a member function is_regular_file
.
TS版本中没有该成员函数std::experimental::filesystem::directory_entry
。
TS 与后来添加到 C++17 标准库中的内容并不完全相同。
我在 <experimental/filesystem>
include 中找到了一个巧妙的方法,它告诉我路径是文件还是目录,但是当我尝试在 g++ v 7.4.0 上使用它时它给我一个错误。我尝试使用的方法是:.is_regular_file()
.
它甚至在 cppref 上,https://en.cppreference.com/w/cpp/experimental/fs/is_regular_file。
但是在编译时出现“...没有名为 'is_regular_file' 的成员”错误。我无法使用常规文件系统,因为我的目标系统 (Ubuntu 18.04 LTS) 预装了 g++ 7.4.0,无法更改。
知道我做错了什么吗?有谁知道 is_regular_file 的替代方法,这样我就可以检查文件是目录还是文件?
我的包括:
#include <string>
#include <vector>
#include <experimental/filesystem>
我正在使用以下标志:-std=c++17 -lstdc++fs -O3 -Wall -Wextra -Wpedantic -Werror
您感到困惑,因为 std::experimental::filesystem
(<experimental/filesystem>
) 包含文件系统 TS,而不是 std::filesystem
(<filesystem>
) 如果你的标准库实现了它们(尽管后者基于前者)。
在TS中有一个std::experimental::filesystem::is_regular_file
free function (which you link to in the question). This free std::filesystem::is_regular_file
也存在于C++17中
但是在 C++17 中 std::filesystem::directory_entry
class also has a member function is_regular_file
.
TS版本中没有该成员函数std::experimental::filesystem::directory_entry
。
TS 与后来添加到 C++17 标准库中的内容并不完全相同。