Thread

Thread Index

Message

From: Dieter Baron <dillo%danbala.tuwien.ac.at@localhost>
To: Jan Weià <jan%geheimwerk.de@localhost>
Subject: Re: Opening a memory buffer containing the data of a zip file
Date: Mon, 7 May 2012 10:32:56 +0200

On Monday, May 7, 2012 at 9:54, Jan Weià wrote:
I am using a library call that effectively results in me getting a buffer which contains the data of a zip file. (zip is used as the container format for OpenOffice documents.)

In my prototype I just save that data to disk and open it with zip_open(). This appears to be a silly and roundabout way of doing things. I could do something weird like this, of course:
How to get file descriptor of buffer in memory?
http://stackoverflow.com/questions/1558772/how-to-get-file-descriptor-of-buffer-in-memory

â and then use zip_fdopen(), but I donât like that either.

  That trick won't work with libzip, since libzip needs to seek on the input file, and you can't seek on a pipe.
 
Is there currently a way to do this cleanly?

  Unfortunately, no.  One of the bigger items on the TODO list is an I/O abstraction layer that would allow for this.  I can't make any promises on when we'll get to it, though.  For now, writing the data to a file is your best bet.  

  If you want to avoid leaving behind temp files, on Unix, you can use this trick: write it, open it, remove it, and then use zip_fdopen.  That way, it will be deleted once libzip closes the file (or your program exits).

yours,
dillo

Made by MHonArc.