From 098964120838f0af8fca6cae416e345e19e350e8 Mon Sep 17 00:00:00 2001 From: Osyotr Date: Sun, 31 Mar 2024 15:13:15 +0300 Subject: [PATCH] Always seek to end of file when opening in append mode C standard does not guarantee that file opened in append mode is seeked to the end. In particular, MSVC CRT does not do that, so ftell64 always returns 0. Fixes some tests on Windows. Signed-off-by: Osyotr --- coding/internal/file_data.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/coding/internal/file_data.cpp b/coding/internal/file_data.cpp index 41838c04a6..0d1414e310 100644 --- a/coding/internal/file_data.cpp +++ b/coding/internal/file_data.cpp @@ -35,7 +35,11 @@ FileData::FileData(string const & fileName, Op op) m_File = fopen(fileName.c_str(), modes[op]); if (m_File) + { + if (op == OP_APPEND) + fseek64(m_File, 0, SEEK_END); return; + } if (op == OP_WRITE_EXISTING) {