From d299d5531ff234d4a9c986126b872aac4ffc4dd8 Mon Sep 17 00:00:00 2001 From: Morph <39850852+Morph1984@users.noreply.github.com> Date: Mon, 5 Jul 2021 12:05:35 -0400 Subject: common: fs: file: Flush the file in GetSize This ensures that GetSize always retrieves the correct file size after a write operation. --- src/common/fs/file.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/common/fs/file.cpp') diff --git a/src/common/fs/file.cpp b/src/common/fs/file.cpp index 077f34995..022780e4e 100644 --- a/src/common/fs/file.cpp +++ b/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); -- cgit v1.2.3