文件读:到 file_contents 里面
std::ifstream file_read_ins(file_name);
strcpy(file_name_, file_name);
pr_dbg("file_name_ is %s\n", file_name_);
if (!file_read_ins.is_open())
{
pr_dbg("file_name open failed\n");
return;
}
while(file_read_ins.get(file_char))
file_contents.push_back(file_char);
file_read_ins.close();
文件写:入 settings 字符串的内容
std::ofstream file;
file.open(file_name_, std::ios::out | std::ios::trunc);
if (!file.is_open())
{
std::cout << "open file failed" << std::endl;
}
file << settings;
file.close();