On Wed, Oct 24, 2001 at 04:24:02PM +0200, Lars Gullik Bjønnes wrote:
> | >         if (::rename(from.c_str(), to.c_str()) == -1)
> | >                 if (lyx::copy(from, to)) {
> | >                         lyx::unlink(from);
> | >                         return true;
> | >                 } else
> | >                         return false;
> | >         return true;
>
> ::rename does not work that is ok... lyx::copy + lyx::unlink should
> ::always work. And if not Why?
> 
> Or are you saying that ::rename silently fails without returning -1?

Look at the source of lyx::copy. It does not copy directories (i.e. copy all
files in the directory).
When you call lyx::copy("from", "to"), the result is a file "to" of length 0.
Furthermore, lyx::copy returns true in that case, so lyx::rename returns
"true" which is wrong (since we didn't copied the directory).

Furthermore, lyx::unlink doesn't work on directories. 
To delete a directory we should do
   !DeleteAllFilesInDir(dir) && !lyx::rmdir(tmpdir)

Reply via email to