ZIP contents as a Gray stream?
Asked Answered
P

1

6

I'm writing a CL library to read MS Excel(tm) spreadsheets called "xlmanip" (not ready for prime time yet -- only reads "xlsx" spreadsheets, works for the 80% use case of "I want to operate on cell contents"... but I digress.)

One thing that worries me when reading "xlsx" (ZIP archives in XML format) is that the current ZIP handling library, Common Lisp ZIP, unpacks the compressed contents as a (vector (unsigned-byte 8)). For a large spreadsheet, that'll cause an issue for the end user.

One alternative I've thought about is delayed loading -- let-over-lambda a closure that effectively demand-loads the worksheet when needed. However, that's just delaying the inevitable.

Are there any ZIP file CL libraries out there that return a Gray stream to a ZIP component's contents as opposed to a (potentially large) (vector (unsigned-byte 8))?

Edit: Clarification

I'm looking for a ZIP component function that returns a stream, not one that takes a stream. The functions that take a stream write the ZIP component's contents directly to the file associated with the stream. I'd rather that xlmanip reads from a stream directly as if the ZIP component were (implicitly, virtually) a file.

Paige answered 16/1, 2016 at 0:57 Comment(1)
Irrelevant comment, but someone is going to ask: xlmanip's code is on gitlab.Paige
D
1

Chipz can decompress a ZIP to a stream. It provides a decompress functions where you give it an output stream and a input stream to decompress and it returns the output stream where the decompressed contents can be read.

Drops answered 16/1, 2016 at 2:29 Comment(5)
From reading the code, it writes directly to a stream, but doesn't look like it creates a stream that can be read. It also doesn't fit the requirement: ZIP is an archive format with a table of contents, not a gzip file.Paige
@ScottM: I think that chipz:make-decompressing-stream can do what you want when given the zip::zipfile-entry-stream as input stream.Cryolite
@Svante: zip::zipfile-entry-stream is not exported. (My bad... it is, part of the zipfile structure.) I'll give it a shot.Paige
@Svante: Nope. zipfile-entry-stream is not exported. The zipfile structure is not exported... it's supposed to be opaque for some unknown reason. But it was a good idea.Paige
@Svante: Even if I tell SBCL or CCL to use the internal zipfile-entry-stream name, there's an issue with Chipz's deflate.Paige

© 2022 - 2024 — McMap. All rights reserved.