Explorar el Código

BufferedFile: Flush content on close

Tatsuhiro Tsujikawa hace 7 años
padre
commit
431fcde29a
Se han modificado 1 ficheros con 6 adiciones y 0 borrados
  1. 6 0
      src/BufferedFile.cc

+ 6 - 0
src/BufferedFile.cc

@@ -80,6 +80,12 @@ int BufferedFile::onClose()
 {
   int rv = 0;
   if (fp_) {
+    fflush(fp_);
+#ifndef __MINGW32__
+    fsync(fileno(fp_));
+#else  // __MINGW32__
+    _commit(fileno(fp_));
+#endif // __MINGW32__
     rv = fclose(fp_);
     fp_ = nullptr;
   }