1

Closed

expose CountingStream as a public type

description

The developer is experiencing problem with a self extracting archive that uses a custom SFX stub, saved directly to Response.OutputStream.
 
Here's the thing. Suppose you open a filesystem file (getting a FileStream), save
a custom sfx stub into it, and then call ZipFile.Save() into that FileStream. ZipFile.Save() does the right thing for the zipentry offsets, by inquiring the Position of the FileStream before writing any data, and then adding that initial offset into
any ZipEntry offsets in the zip directory.
 
This does not work for HttpResponse.OutputStream, because it is not possible to inquire the Position on that stream. Position is not defined for that stream type. Therefore the writes that happen within the context of ZipFile.Save() cannot do
the fixup arithmetic.
 
The workaround is for the application to wrap HttpResponse.OutputStream in a wrapper stream that supports the Position property; then write the SFX stub and the ZipFile into that wrapper stream. Because ZipFile.Save() can inquire the Position, it will then do the right thing with the offsets. In the source for DotNetZip, there is a wrapper stream class called CountingStream that does exactly what you want; unfortunately it is limited to internal use.
 
This workitem is a request to expose that class publicly, and document it.
Closed Jun 14, 2011 at 2:53 AM by Cheeso
implemented in changeset 79079. First binary: v1.9.1.6

comments