Currently the lock logic is
- Create a temp file
- Create a symbolic link on unix or a hard link on windows
- Delete both when we are done with it
The problem is that CreateHardLink on windows will fail if the file has a DeleteFile disposition which I want to use in TempFile.
The solution I think is to use a single file for the lock. On windows that is simple as rename can be set to fail if the destination exists.
On posix we first create the link as we do now, but immediately rename the original file onto it.
I'm not a fan of this interface, with both From and FD. It's confusing and seems prone to being called erroneously. What if the caller accidentally specifies a From that doesn't correspond to FD?
And it appears that neither implementation currently uses FD. I see the FIXME that suggests it might be useful in the future. Can we remove FD for now and revisit it later?