diff --git a/Utilities/File.cpp b/Utilities/File.cpp index 4f0094d23d..4d1d9acd2a 100644 --- a/Utilities/File.cpp +++ b/Utilities/File.cpp @@ -1303,12 +1303,12 @@ fs::file::file(const std::string& path, bs_t mode) DWORD nwritten = 0; OVERLAPPED ovl{}; - const u64 pos = m_pos; + const u64 pos = m_pos.fetch_add(size); ovl.Offset = DWORD(pos); ovl.OffsetHigh = DWORD(pos >> 32); ensure(WriteFile(m_handle, data, size, &nwritten, &ovl)); // "file::write" + ensure(nwritten == size); nwritten_sum += nwritten; - m_pos += nwritten; if (nwritten < size) {