这里记录下如何使用boost创建文件夹的方法。
主要步骤
- 包含filesystem头文件
#include <boost/filesystem.hpp>
- 检测传入的文件目录(log_path)是否存在,目录不存在的话会新建一个目录
boost::filesystem::path dir = log_path;
boost::system::error_code error;
auto file_status = boost::filesystem::status(dir, error);
if(error){
std::cout << "file status error" << std::endl;
}
if(!boost::filesystem::exists(file_status)){
std::cout << "file exist error" << std::endl;
boost::filesystem::create_directories(dir);
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)