[whatwg] Archive API - proposal

Glenn Maynard glenn at zewt.org
Tue Aug 14 14:33:39 PDT 2012


(Please remember to trim quotes.)

On Tue, Aug 14, 2012 at 4:05 PM, Tobie Langel <tobie.langel at gmail.com>wrote:

> How are nested directories handled in your counter proposal?
>

The ZIP directory is simply a list of files anyway.  Just store the
complete path of the file in .name:

zipFile.files[0].name == "file.txt"
zipFile.files[1].name == "path/file.txt"

Don't expose an entry for "path" itself.

This doesn't give a way to expose the existance of empty directories, which
I suppose might be useful (the original proposal doesn't do that, either).
This could be handled if wanted, with a separate .directories array
containing just a list of DOMStrings ("path"), though I wouldn't bother
unless there was demand.

Oh, one other thing: sort .files by disk order, eg. by the "relative offset
of local header" field in the CD file entry.  (This is usually the order
files appear in the central directory itself, but this isn't guaranteed.)
This guarantees the order of .files is predictable.  Also, if the page
reads all files sequentially from the ZIP in this order, the actual file
will be traversed sequentially.  That's much faster than reading them out
of order, especially for lots of small files.

-- 
Glenn Maynard



More information about the whatwg mailing list