title: How to get file descriptor from ofstream
body: <p>I need to call fsync() to secure my data. Can you please help me to get file descriptor from ofstream.  </p>
  
  <pre><code>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 &lt;&lt; "Failed to write the main configuration file: " &lt;&lt; topconfig &lt;&lt; endl;
      return false;
  }
  REPORT_INFO("Syncing the file: " &lt;&lt; topconfig);
  // TODO I need to call fsync() here to secure my data.
  //tcfg.pubsync();
  tcfg.close();
  }
  </code></pre>