Writes a file atomically.
The file is either written successfully or an IO exception is raised
and the original file is left unchanged.
On Unix:
- If the temp directory ($TMPDIR) is in a filesystem
different than the destination path, the renaming will be emulated via
copyFile then deleteFile.
On Windows:
- This operation is not guaranteed to be atomic, see
renameFile.
- It is not possible to delete a file that is open by a process.
This case will give an IO exception but the atomic property is not
affected.
- If the temp directory (TMPTEMP..., see
haddocks on getTemporaryDirectory) is in a different drive than
the destination path, the write will be emulated via copyFile,
then deleteFile.