FIY: libzip and UTF-8 on Win32

Lubomir I. Ivanov neolit123 at gmail.com
Fri Feb 20 15:14:00 PST 2015


On 20 February 2015 at 22:13, Lubomir I. Ivanov <neolit123 at gmail.com> wrote:
> but...after building Subsurface with the new libzip it gives me
> "Archive cannot be opened. Bad file descriptor" when download from
> divelogs.de.
> i need to investigate.
>

spent a couple of hours on this one.

CCing Thiago - the QTemporaryFile file locks in a way that the new
libzip WINAPI support cannot use zip_open()
on said file. could this be a LockFile / UnlockFile() API related
semantic in Qt 5.3.0? or am i missing something else?

i had to rename() the file to fix the error before calling zip_open(),
which is strange (patch attached).

the new libzip itself works. but i also sent an email to the libzip
ML, as this could be on their end for
some odd reason.

i'm pretty sure it used to work at some point with my Qt 5.3.0 setup,
but that was with the old libzip.dll.
trying to figure out what is happening.

commit message:
-----------------------
Subject: [PATCH] Divelogs.de: fix broken download due to an exclusive access
 lock

The current divelogs.de download doesn't work for Win7, Qt5.2
(or at least for a particular test setup).

When a divelogs.de download happens 'zipFile' (which is a
QTemporaryFile) is written to with full permissions in the
TEMP folder. The location and random file name are OK.

Once DivelogsDeWebServices::downloadFinished() is reached
'zipFile' can be closed, it can be renamed and copied from the
process. External processes cannot read it which is understandable
as it may be locked by the process (for QTemporaryFile to delete it
later), but libzip.dll also can't read it via zip_open().

Doing a close() doesn't unlock the file, but a rename() does.

By prefixing the filename with a "_" the lock is gone and
we can read the file via zip_open().

The file is later deleted once the process ends.
-----------------------

lubomir
--
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Divelogs.de-fix-broken-download-due-to-an-exclusive-.patch
Type: application/octet-stream
Size: 2504 bytes
Desc: not available
URL: <http://lists.subsurface-divelog.org/pipermail/subsurface/attachments/20150221/eebbe128/attachment.obj>


More information about the subsurface mailing list