gpt4 book ai didi

c++ - Windows c++ 的 Fsync 替代方案

转载 作者:可可西里 更新时间:2023-11-01 13:40:27 26 4
gpt4 key购买 nike

Windows 有 fsync 的替代方法吗? (C++ 构建器)

Fsync 需要包含 unistd.h 且仅适用于 unix 系统

谢谢!

最佳答案

来自手册页:

fflush() forces a write of all user-space buffered data for the given output or update stream via the stream's underlying write function.

提到的写函数告诉操作系统文件的内容应该是什么。此时,所有更改都将在实际提交到磁盘之前保存在文件系统缓存中。

POSIX 函数 fsync() 告诉操作系统将缓存中的所有更改同步到磁盘。正如其他人所说,您可以在 Windows 平台上使用 FlushFileBuffers

关于c++ - Windows c++ 的 Fsync 替代方案,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33133222/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com