ps3dev / ps3libraries

A script to automatically build various open source libraries for use on the PS3.
86 stars 74 forks source link

Error when creating .zip files with libzip #36

Closed bucanero closed 4 years ago

bucanero commented 4 years ago

I found a problem while using the ported libzip 0.9.3 when creating a .zip file from within a ps3 homebrew app: When you try to create an archive.zip, libzip ends up creating archive.zip.XXXXX (where XXXXX is a random extension)

I tracked down the issue back to the libzip source code, and fixed it. The libzip code creates a temp file and when it finishes, it tries to rename it to the desired filename, e.g. archive.zip.

The fix I made was to re-define the _zip_rename() to sysLv2FsRename() in ./libzip-0.9.3/lib/zipint.h:

#ifdef HAVE_MOVEFILEEXA
#include <windows.h>
#define _zip_rename(s, t)                       \
    (!MoveFileExA((s), (t),                     \
             MOVEFILE_COPY_ALLOWED|MOVEFILE_REPLACE_EXISTING))
#else
#include <sys/file.h>
#define _zip_rename sysLv2FsRename
#endif

I don't know how to properly share this patch, so I'm attaching the whole zipint.h file to this issue: zipint.h.zip

zeldin commented 4 years ago

This begs the question why simply calling rename() does not work. Surely this should be a wrapper for sysLv2FsRename() so that you don't need to do this in every lib or app?