我需要调用fsync()来保护我的数据。你能帮我从ofstream获取文件描述符吗?
string tmpconfig("config.tmp");
ofstream tcfg(tmpconfig.c_str());
if(tcfg)
{
tcfgNV.compactPrint(tcfg);
tcfg.flush();
if(!tcfg.good())
{
tcfg.close();
::remove(tmpconfig.c_str());
cout << "Failed to write the main configuration file: " << topconfig << endl;
return false;
}
REPORT_INFO("Syncing the file: " << topconfig);
// TODO I need to call fsync() here to secure my data.
//tcfg.pubsync();
tcfg.close();
}