List Archive

Thread

Thread Index

Message

From: Thomas Klausner <tk%giga.or.at@localhost>
To: Lisa Matias <lisa.matias%gmail.com@localhost>
Subject: Re: ZIP_CREATE flag for zip_fdopen issues
Date: Tue, 3 Jan 2017 17:38:35 +0100

On Tue, Jan 03, 2017 at 08:35:50AM -0800, Lisa Matias wrote:
> I have a web server CGI application which needs to dynamically create a
> unique ZIP archive which is sent via the web socket (file descriptor) to
> the user's browser for download.
> 
> Since the web server is running on Debian Linux, the goal is to avoid
> having to create and use temporary files, especially since the ZIP archive
> will only contain 3 dynamic files that are specified in 3 unsigned
> character (UINT8_T) buffers.  Creating unnecessary temporary files will
> only result in causing significant flash aging on the web server's SSD.
> 
> However, there seems to be issues with using the ZIP_CREATE flag for
> zip_fdopen().
> 
> Looking at the man page: https://nih.at/libzip/zip_fdopen.html
> 
> The ZIP_CREATE is not even specified as flag for "zip_fdopen()" as it is
> for "zip_open()".

zip_fdopen is not for writing. The man page you point to mentions that:

"In contrast to zip_open(3), using zip_fdopen the archive can only be
opened in read-only mode."

> Any advice on how to do this properly with libzip?

Perhaps you want to create the zip file in memory instead?

See examples/in-memory.c for how to do that.

(Having /tmp on a memory file system would be another workaround.)

Cheers,
 Thomas

Made by MHonArc.