Thread

Thread Index

Message

From: Benjamin Eikel <libzip-mailing-list%eikel.org@localhost>
To: libzip-discuss%nih.at@localhost
Subject: Re: Error message on Windows: Renaming temporary file failed: File exists
Date: Thu, 7 Oct 2010 10:18:54 +0200

Hello Thomas,

Am Mittwoch, 6. Oktober 2010, 22:06:33 schrieb Thomas Klausner:
> On Wed, Oct 06, 2010 at 09:49:12PM +0200, Benjamin Eikel wrote:
> > I have a problem while using libzip 0.9.3 on Windows. I open a ZIP
> > archive, write a text file to it using zip_add and then close the
> > archive. Then I open the archive again and change the content of the
> > file with zip_replace. When calling zip_close now, zip_strerror gives me
> > the message "Renaming temporary file failed: File exists".
> > The same code works without problems on Debian GNU/Linux.
> > Can you give me a hint what I might be doing wrong? The code is embedded
> > into a larger system. If required, I am willing to set up a little
> > sample application provoking this behaviour.
> 
> The rename() function call on the Windows systems I have seen doesn't
> like existing target files. This is why lib/zipint.h includes the
> following statement:
> 
> #ifdef HAVE_MOVEFILEEXA
> #include <windows.h>
> #define _zip_rename(s, t) \
>         (!MoveFileExA((s), (t), \
>                      MOVEFILE_COPY_ALLOWED|MOVEFILE_REPLACE_EXISTING))
> #else
> #define _zip_rename     rename
> #endif
> 
> Please find out why MoveFileExA is not used for you, or, if it is, why
> it doesn't work.
thank you for that hint. Somehow CMake did not find that function. I tried a 
little bit to change the CMakeLists.txt. For example I tried to use 
"CHECK_LIBRARY_EXISTS(kernel32 MoveFileEx "" HAVE_MOVEFILEEX)" but that did 
not work.
Another way could be to check for the header file "windows.h" and if found 
assume that the function is defined.
Furthermore I recognized that the CMake variable and define in "cmake-
config.h.in" is missing the trailing "A".
In the end I added "#define HAVE_MOVEFILEEXA" to the header "config.h" by 
hand. Now the bug and the error message is gone and the application is working 
as expected.

Kind regards,
Benjamin

Made by MHonArc.