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?
â 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).
Made by MHonArc.