[Mono-dev] Making Open more atomic/consistent
LCID Fire
lcid-fire at gmx.net
Tue Feb 24 05:04:03 EST 2009
Looking at the System.IO.File.Open/System.IO.MonoIO.Copy method I
noticed some oddities in the implementation.
First off it does a File.Exists check on the destination file which is
IMO too early since the destination file is created far later on - there
is the possibility that the file could be deleted till the actual create
is attempted. In this case the method would have failed for no reason.
Furthermore should the file be created after the File.Exists check it
attempts a file creation via calling open. Open then fails - but looking
at System.IO.MonoIO.GetException the error message for
MonoIOError.ERROR_FILE_EXISTS differs from the one that is returned from
the earlier check ("Could not create file \"{0}\". File already exists."
vs "{0} already exists").
So for consistency and to get the actual check more atomic I'd propose
to just delete the first check in System.IO.MonoIO.Copy.
More information about the Mono-devel-list
mailing list