Преглед изворни кода

common: fs: file: Flush the file in GetSize

This ensures that GetSize always retrieves the correct file size after a write operation.
Morph пре 5 година
родитељ
комит
d299d5531f
1 измењених фајлова са 3 додато и 0 уклоњено
  1. 3 0
      src/common/fs/file.cpp

+ 3 - 0
src/common/fs/file.cpp

@@ -347,6 +347,9 @@ u64 IOFile::GetSize() const {
         return 0;
     }
 
+    // Flush any unwritten buffered data into the file prior to retrieving the file size.
+    std::fflush(file);
+
     std::error_code ec;
 
     const auto file_size = fs::file_size(file_path, ec);