24inline void fsync_file(
const std::string& path)
noexcept {
25#if defined(_WIN32) || defined(_WIN64)
26 HANDLE hFile = CreateFileA(path.c_str(), GENERIC_WRITE, FILE_SHARE_READ, NULL,
27 OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
28 if (hFile != INVALID_HANDLE_VALUE) { FlushFileBuffers(hFile); CloseHandle(hFile); }
29#elif defined(__unix__) || defined(__APPLE__)
30 int fd = open(path.c_str(), O_WRONLY);
31 if (fd >= 0) { fsync(fd); close(fd); }