Atomicity of file-copying/moving

Per Nordlöw via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed May 17 12:56:52 PDT 2017


On Tuesday, 16 May 2017 at 10:57:08 UTC, FreeSlave wrote:
>
> Not sure about renaming but copying is not atomic on Posix 
> because it does not handle interruption by signal. I opened 
> issue about that https://issues.dlang.org/show_bug.cgi?id=17296

The standard way is to copy the source to a temporary file on the 
same file system as the target file followed by hardlinking the 
temporary to the target file. If an error occurs during copying 
you either retry or abort. That should be atomic.


More information about the Digitalmars-d-learn mailing list