On Fri, Dec 14, 2007 at 06:16:28PM -0000, [EMAIL PROTECTED] wrote:

> Author: younes
> Date: Fri Dec 14 19:16:25 2007
> New Revision: 22149
> 
> URL: http://www.lyx.org/trac/changeset/22149
> Log:
> The rename() function removed in rev had in fact move() functionality. So we 
> replace all uses of renameTo() with the new FileName::moveTo() method.
> 
> Modified:
>     lyx-devel/trunk/src/Buffer.cpp
>     lyx-devel/trunk/src/Mover.cpp
>     lyx-devel/trunk/src/insets/InsetGraphics.cpp
>     lyx-devel/trunk/src/support/FileName.cpp
>     lyx-devel/trunk/src/support/FileName.h
...
> Modified: lyx-devel/trunk/src/support/FileName.cpp
> URL: 
> http://www.lyx.org/trac/file/lyx-devel/trunk/src/support/FileName.cpp?rev=22149
> ==============================================================================
> --- lyx-devel/trunk/src/support/FileName.cpp (original)
> +++ lyx-devel/trunk/src/support/FileName.cpp Fri Dec 14 19:16:25 2007
> @@ -146,6 +146,19 @@
>       bool success = QFile::rename(d->fi.absoluteFilePath(), 
> name.d->fi.absoluteFilePath());
>       if (!success)
>               LYXERR0("Could not rename file " << *this << " to " << name);
> +     return success;
> +}
> +
> +
> +bool FileName::moveTo(FileName const & name) const
> +{
> +     if (name.exists() && !name.removeFile())
> +             return false;

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.

> +     bool success = QFile::rename(d->fi.absoluteFilePath(),
> +             name.d->fi.absoluteFilePath());
> +     if (!success)
> +             LYXERR0("Could not move file " << *this << " to " << name);
>       return success;
>  }

-- 
Enrico

Reply via email to