所以我有一些基地boost::filesystem::path Base
我想創建文件夾,如果一個不存在,並從字符串創建一個二進制文件。目前我有這樣的功能:如何將文件保存到可能的新目錄中?
void file_service::save_string_into_file(std::string contents, std::string name)
{
std::ofstream datFile;
name = "./basePath/extraPath/" + name;
datFile.open(name.c_str(), std::ofstream::binary | std::ofstream::trunc | std::ofstream::out );
datFile.write(contents.c_str(), contents.length());
datFile.close();
}
它需要從目錄中存在。所以我想知道如何更新我的函數boost.filesystem APIs以達到所需的功能?