#ifdef _WIN32
#include
namespace fs = std::filesystem;
#else
#include <experimental/filesystem>
namespace fs = std::experimental::filesystem;
#endif
#include
int main()
{
auto path = fs::path(“root/test.txt”);
//后面会追加
fs::resize_file(path, 1024 * 1024 * 1);
}
int main()
{
std::string str = “测试 C++11 宽字符转换。”;
std::string ssss =fs::path(str).u8string();
std::cout << ssss << std::endl;
}
编译命令:g++ test.cpp -o test --std=c++17 -lstdc++fs