[Mono-dev] Making Open more atomic/consistent

Rodrigo Kumpera kumpera at gmail.com
Fri Feb 27 16:26:12 EST 2009


On Tue, Feb 24, 2009 at 7:04 AM, LCID Fire <lcid-fire at gmx.net> wrote:

> 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.
>

Yes, open should be more atomic, feel free to contribute a patch that fixes
this issue.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20090227/2c5a689e/attachment.html 


More information about the Mono-devel-list mailing list