[Mono-dev] [PATCH]System.IO.File.Replace

Bill Holmes billholmes54 at gmail.com
Wed Aug 15 19:16:57 EDT 2007


Rodrigo,

I thought the ()'s around the return was a bit odd myself.  But since
I did not understand why they were in the existing code I kept the
pattern going.  I will remove them from my changes.

As for the alloca, that too is something I refactored out of the
CopyFile method.  I agree that can cause problems so I will look for
an alternative.

do you think I could get away with
int buf_size = st_src->st_blksize;
if (buf_size > 1024)
        buf_size = 1024;
 char *buf = (char *) alloca (buf_size);

Or should I switch to dynamic allocation (malloc)?  Or should I use
dynamic allocation and cap the max?

I'll see what I can do to cleanup my messy whitespace.

sendfile could be a good solution for this method but as Leszek points
out this is probably not a reliable cross platform solution.  What I
am actually doing here is opening the backup file for read.  Then in
the event of an error I need to simply restore that file.  If I had
something like linkFile (int in_fd, const char *path) I would be
better off.

Thanks so much for you comments.  I will make improvements and re-submit.

-bill



More information about the Mono-devel-list mailing list