[whatwg] Archive API - proposal
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.name == "file.txt"
zipFile.files.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.
More information about the whatwg