List Archive

Thread

Thread Index

Message

From: Qifei Wang <qfwang%google.com@localhost>
To: Thomas Klausner <tk%giga.or.at@localhost>
Subject: Re: Failed to unzip file by zip_fdopen with the error code ZIP_ER_OPNOTSUPP
Date: Sat, 7 Sep 2019 18:09:17 -0700

Hi Thomas,

  Thanks for your reply. I figured out the problem was SEEK (https://github.com/nih-at/libzip/blob/master/lib/zip_source_filep.c#L188) is not added as the supported operator for the zip file opened from the file descriptor. That is because the file sb.st_mode (https://github.com/nih-at/libzip/blob/master/lib/zip_source_filep.c#L187) is not recognized as a regular file. That might be caused since the file descriptor is obtained from a content URI on Android.

  To open a zip archive from a memory buffer, should I use zip_source_buffer or zip_source_buffer_create methods?

Cheers,

Qifei Wang


On Sat, Sep 7, 2019 at 1:52 PM Thomas Klausner <tk%giga.or.at@localhost> wrote:
On Fri, Sep 06, 2019 at 06:03:06PM -0700, Qifei Wang wrote:
>   I am trying to unzip a zip file from file descriptor by the following
> code snippet. It reports the error ZIP_ER_OPNOTSUPP. The file descriptor is
> valid. The error seems reported by zip_open_from_source() method. See
> https://github.com/nih-at/libzip/blob/master/lib/zip_open.c#L106. Any idea
> about this?

I see one location that actually does set that error:

    if ((st.valid & ZIP_STAT_SIZE) == 0) {
        zip_error_set(error, ZIP_ER_SEEK, EOPNOTSUPP);
        return NULL;
    }

For reading an archive, libzip starts at the end and parses the
EOCD(64) marker and then the central directory. Perhaps the stat() to
find out the filesize failed?

You could read the file from the server into a memory buffer and open
the zip archive from there.
 Thomas

Made by MHonArc.