Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feature request] generate UNIX extra fields #194

Closed
dduponchel opened this issue Jan 8, 2015 · 1 comment · Fixed by #200
Closed

[feature request] generate UNIX extra fields #194

dduponchel opened this issue Jan 8, 2015 · 1 comment · Fixed by #200
Labels

Comments

@dduponchel
Copy link
Collaborator

Keeping the "version made by" flag in the directory record to "DOS" sounds good, but we lack a way to change it to "UNIX" for example and add extra fields to set the unix permissions. Setting executable files will be useful, see sindresorhus/gulp-zip#38.
The field "external file attributes" will also need some investigations (when generating or parsing) as it depends on the "version made by" field.

@dduponchel
Copy link
Collaborator Author

The unix permissions are stored in the "external file attributes" (this link was really useful). Generating / parsing this field is easy but we need to be careful with what we allow in the API.

I though that a field permissions with a string ("644" or "755") or the nodejs stats.mode field would be enough. On nodejs/windows, a folder will get "444" or "666" from stats.mode (after conversion) and this permissions on a folder will render it unusable on linux/mac. Not good.

Moreover the DOS files attributes are still used (I'm still investigating the windows ACL support) : we could support them too. If I follow wikipedia, Info-ZIP does a mapping between the two which can lead to broken things so I'd rather not try to mix them together.

I suggest the follow API :

  • generate() gains a new option : platform ("DOS", "UNIX" or nodejs process.platform)
  • ZipObject gains two new objects : dosPermissions and unixPermissions. They are null unless defined when adding a file with specific permissions (manually or when parsing a zip file). They contains platform specific fields :
    • hidden, readOnly for dos
    • executable, readOnly for unix

The other solution I see is to completely expose the "external file attributes" : easier for us but the user will need to know exactly how to generate it.

dduponchel added a commit to dduponchel/jszip that referenced this issue Feb 18, 2015
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 Stuk#194 and Stuk#198.
@Stuk Stuk closed this as completed in #200 Feb 19, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant