From 0f6bd65c6df21850348af3c4bb162c89a1d85bae Mon Sep 17 00:00:00 2001 From: bugdea1er Date: Sat, 18 Jan 2025 22:37:33 +0300 Subject: [PATCH] Add `fsync` for file writing --- src/file.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/file.cpp b/src/file.cpp index 925b72f..7888e0f 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -133,6 +133,12 @@ void write(entry::native_handle_type handle, std::string_view content, content = content.substr(written); } while (!content.empty()); + +#ifndef _WIN32 + if (fsync(handle) == -1) { + ec = std::error_code(errno, std::system_category()); + } +#endif ec.clear(); } } // namespace