ARTICLE AD BOX
I'd like to copy files and directories while preserving all their attributes, so I use CopyFileEx and CreateDirectoryEx, but they don't preserve file times, so I need to get the file handle and call SetFileTime on it.
CopyFileEx passes the destination file handle through a callback, so I can SetFileTime there, but the documentation doesn't say if the callback is guaranteed to be invoked. Preferably I'd set the file times at the end of the copy, but the callback doesn't indicate if it's the last, so I'm left with setting them on the first invocation. But if CopyFileEx subsequently writes more data, wouldn't the last write time be overwritten? (I tried on small files and all three file times are preserved).
CreateDirectoryEx doesn't provide access to the destination directory handle at all. While I can open it right after the call, that's a race condition and seems a little silly when CreateDirectoryEx already has it open.
A similar problem arises when the destination already exists and is read only: CopyFileEx/MoveFileEx/DeleteFile/RemoveDirectory all fail with access denied. But if I call SetFileAttributes and retry, that's a race condition.
