Re: [widgets] Zip vs GZip Tar

On Wed, Apr 28, 2010 at 2:28 PM, timeless <timeless@gmail.com> wrote:

> On Wed, Apr 28, 2010 at 7:48 PM, Gregg Tavares <gman@google.com> wrote:
> > I'm sorry if I'm not familiar with all the details of how the widgets
> spec
> > is going but the specs encourage comment so I'm commenting :-)
> >
> > It seems like widgets have 2 uses
> >
> > #1) As a way to package an HTML5 app that can be downloaded similar to a
> > native
> >     executable
> >
> > #2) As a way to package an HTML5 app that can be embedded in a page but
> > easily
> >     distributed as a single file (ie, do what Flash / Silverlight /
> Unity3D
> >     currently do except based in HTML5 / EMCAScript)
> >
> > Use #2 would benefit tremendously if like Flash / Sliverlight / Unity3D
> the
> > application could start as soon as it has enough info to start as
> supposed
> > to
> > having to wait for the entire package to download.
> >
> > To accomplish that goal requires using a format that can be streamed.
> > Zip is not such a format. Zip files store their table of contents at the
> end
> > of
> > the file. They can have multiple table of contents but only the last one
> > found is valid. That means the entire file has to be downloaded before a
> UA
> > can
> > correctly figure out what's in the file.
> >
>
> That's incorrect. Zip is streamable. Go read the format.
>


In more detail:

A zip file is allowed to look like this

offset : content
0100 : [fileheader: "foo.txt"]
0180 : [content for "foo.txt"]
0400 : [fileheader: "foo.txt"]
0480 : [content for "foo.txt"]
0900 : [table of contents: "foo.txt": location 0400]

Only the table of contents is the authority of what files
are valid inside a zip file, not the headers on the file.

This is so you can both safely append new versions
of files to the end of a zip file and just write a new
table of contents and to avoids false positives from
other content in the file.

The only the last table of contents
is valid and only the files it points to are valid.

Therefore, unless you are implementing some kind of
hack, hoping that reading the file headers will work
you aren't actually reading zip files. You're reading some
subset that happen to work with your hack.

Zip files are not streamable.

Received on Wednesday, 28 April 2010 22:27:03 UTC