This is an update for #200. If we don't keep the original unix/dos permissions, this will lead to hard-to-debug issues, where the permissions are not exactly like they were specified. This commit changes that and uses the exact file mode. It also updates the default umask from 022 to 002 (with unixPermissions == null, files will get 0664 and folders 0775). To put a folder with custom permissions, folder() is not a good candidate : its behavior is to re-use existing entries. Instead, this commit documents the existing dir attribute.
Check if the content is a truncated zip or complete garbage. A "LOCAL_FILE_HEADER" is not required at the beginning (auto extractible zip for example) but it can give a good hint. If an ajax request was used without responseType, we will also get unreadable data. Fix #182.
This commit adds a new option, `compressionOptions`. If it contains a field `level`, it is used by the DEFLATE compression to set the compression level : 6 by default or any level between 1 (best speed) and 9 (best compression). Fix #165.
Two new fields on ZipObject, `unixPermissions` and `dosPermissions`, hold the UNIX or DOS permissions of the file. A new option of `generate()`, `platform` (DOS or UNIX) controls the use of the permissions. The default behavior is to generate DOS archives, without any permissions, like before. Bonus side-effect : Finder on mac doesn't use the DOS directory flag, JSZip didn't properly recognize folders until now. Fix #194 and #198.
Signed-off-by: Manuel Nuñez <email@example.com>
The goal was to provide a faster utf8 encoding / decoding. This API is only available on Firefox and it doesn't work well in a Firefox addon context (the generated Uint8Array and the available Uint8Array class come from different contexts, leading to bugs and performance issues). Instead of adding more conditions to (try to) detect if the Uint8Array is from the same context or not, I think it's better to remove this optimization for now. Fix #151.