List Archive


Thread Index


From: Dieter Baron <>
To: Andreas Falkenhahn <>
Subject: Re: Why should I return the size in ZIP_SOURCE_STAT?
Date: Wed, 1 Nov 2017 10:10:10 +0100


> On 31.10.2017, at 16:44 , Andreas Falkenhahn 
> <> wrote:
> I'm using a custom source to feed data into zip_file_add(). According to the
> docs, I have to implement ZIP_SOURCE_STAT for that. I use ZIP_SOURCE_STAT
> to tell zip_file_add() the datestamp for my file but I don't see why I
> should ever set ZIP_STAT_SIZE? Isn't that completely gratuitous because
> the size can be automatically computed from the number of bytes fed by
> I've just done some tests and it seems that passing a size in ZIP_SOURCE_STAT
> isn't necessary at all. Still, the docs sound like it needs to be set:
>       Information only available after the source has been read (e.g. size) 
> can
>       be omitted in an earlier call.
> To me this sounds like I don't have to submit a size when ZIP_SOURCE_STAT
> is first called but I should submit it in the ZIP_SOURCE_STAT call that
> comes in after all data has been read. But apparently that isn't necessary.

The only information you have to report accurately is ZIP_STAT_COMP_METHOD, and 
compressed or encrypted). libzip can’t figure those out on its own.

All other data is optional, but libzip uses it if present. So you should 
generally report all information that is readily available, but needn’t go out 
of your way to obtain any of it. (For instance, zip_source_file reports 
ZIP_STAT_SIZE and ZIP_STAT_MTIME obtained via calling stat(3).

> So I think the docs should be updated to mention that passing the size
> in ZIP_SOURCE_STAT isn't really necessary... (unless I'm missing something
> here)

Yes, we’ll update the man page to make this clearer.


> -- 
> Best regards,
> Andreas Falkenhahn                          

Made by MHonArc.