On Sat, Dec 15, 2007 at 12:04:36AM +0100, Abdelrazak Younes wrote: > Enrico Forestieri wrote: > > On Fri, Dec 14, 2007 at 11:17:35PM +0100, Abdelrazak Younes wrote: > > >>> This is wrong. Simply try to remove the file without checking for its > >>> existence and then fall through to directly trying to rename. In case > >>> the file the could not be removed, the rename fails and you get the > >>> warning. Otherwise, sometimes you are warned and sometimes not. > >> Well, I don't want a warning if the file does not exist. If it exists > >> and its removal fails I will get the true warning from > >> FileName::removeFile(). > > > > And this is wrong because you should get the warning about the > > impossibility to move the file, not to delete the destination. > > OK, that's a point of view. I guess I agree, even if the real error is > the impossiblity to remove a file.
Yes, but you are trying to move a file and it is misleading that you get an error about deleting something. If you want the real reason for the failure, then you should check errno. Actually, it would suffice something like: perror("Unable to move xxx to yyy"); and you would get the above string followed by a colon and the reason for the failure. But perror() is an ISO C function and I would not be called heretic here ;-) I also think that QFile::error() could be used. > >> If I do like you advice I will get two warning. > > > > You do not when using the attached patch. > > OK, please commit then. Will do. > >> But I see that the check for existence is already there in > >> FileName::removeFile() (you introduced it right?). > > > > Wrong, you did. I simply introduced the existence check because I > > find stupid being warned about the impossibility to remove a > > non-existent file. > > Year, that's what I meant ;-) I simply misread what you typed. Time to go to bed ;-) -- Enrico