简体   繁体   English

Windows上的os.replace()是原子的吗?

[英]Is os.replace() atomic on Windows?

In the docs it says that replacing files are guaranteed to be atomic on POSIX systems. 在文档中,它表示替换文件在POSIX系统上保证是原子的。 Does this mean that it's not atomic on Windows? 这是否意味着它在Windows上不是原子的?

As visible in this thread the atomic replace functionality for windows has been added for version 3.3. 此线程中可见,已为版本3.3添加了Windows的原子替换功能。

The patch is visible here . 补丁在这里可见。

In the background MoveFileEx with when nessesary the MOVEFILE_REPLACE_EXISTING flag added is called. 在后台使用MoveFileEx时,调用添加的MOVEFILE_REPLACE_EXISTING标志。

MoveFileEx is the same method as the openjdk calls . MoveFileExopenjdk调用的方法相同。 I can't find any documentation stating it is atomic, but the community seems to rely on it. 我找不到任何文件说它是原子的,但社区似乎依赖它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM