Syntactic Confectionery Delight | |
PerlMonks |
Re^7: Read in hostfile, modify, outputby eyepopslikeamosquito (Archbishop) |
on Dec 23, 2016 at 23:04 UTC ( [id://1178449]=note: print w/replies, xml ) | Need Help?? |
From the perl 5.24.0 C sources, file win32.c: we see that the Perl rename function on Windows is implemented using the Win32 MoveFileEx function. Here is a standalone C program using the Win32 MoveFileEx function: After compiling, you can run with: which overwrites the original file even if it already exists (if you have permission to do so). Well, it's pleasing to see that Perl is doing the rename via a single Win32 MoveFileEx function call in preference to a DeleteFile followed by a MoveFile (which would have no chance of being atomic). However, the jury seems to be out on how truly atomic Windows rename is. After reading this stackoverflow question I'm still confused. Alternatives to MoveFileEx appear to be ReplaceFile and MoveFileTransacted. Via brute force search of the perl 5.24.0 source code, I further noticed that MoveFileEx is also available to Perl code via the Win32API::File module. In the latest Perl distribution, Win32API::File::MoveFileEx is called by ExtUtils::Install.
In Section
Seekers of Perl Wisdom
|
|