I am using libzip in order to move files in a zip from another zip. So firstly I use zip_source_zip to create a zip_source from a file in my zip, and then zip_add to finally add the file to the zip.
But there is an argument that I don’t understand what it stands for. The first argument of zip_source_zip. Here is its prototype:
struct zip_source * zip_source_zip(struct zip *archive, struct zip *srcarchive, zip_uint64_t srcidx, int flags, zip_uint64_t start, zip_int64_t len)
srcarchive is the zip where I take my file, srcidx is the position in the zip of the file that I want, flags are flags :P, start is the first byte where I want to take the file and len is the number of bytes from start.
But I don’t understand what the first argument archive stands for. I put the pointer of the destination zip but it didn’t work.
Do you know what this first argument stands for? Thank you!
PS: Here is the page where the function is described: http://www.nih.at/libzip/zip_source_zip.html
Each
zip_sourceshould be associated with a ZIP archive that it will operate on (for example, thezip_add()function can be used to add the contents of the source to that particular zip archive). It doesn’t matter whether you create thezip_sourcefrom a memory buffer (usingzip_source_buffer()), from another ZIP archive opened for reading (what you are doing) or using any other method. Basically, the first ZIP archive is the target that will be modified when adding the contents of thezip_sourceobject, and the second ZIP archive argument is the one of which the contents are copied to the source.