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

Folder file entries do not have 'dir' set to true? #198

Closed
chrisrickard opened this issue Jan 20, 2015 · 2 comments
Closed

Folder file entries do not have 'dir' set to true? #198

chrisrickard opened this issue Jan 20, 2015 · 2 comments
Labels

Comments

@chrisrickard
Copy link

Hi,

When I download and iterate the fileEntries in this zip --> https://dl.dropboxusercontent.com/u/3120684/folder.zip - It seems to be trating folders as files?

E.g, neither entry.dir or entry.options.dir are 'true' for the internal folder.

I am trying to extract the contents exactly as it appears in the zip (keeping the folder structure), any advice?

Cheers,

Chris.

@dduponchel
Copy link
Collaborator

When parsing a zip file, JSZip only reads the DOS attribute to know if it's a folder (see here). This file has no DOS flags, only UNIX ones (in this zip file, a folder entry has the external file attributes 41FD4000, meaning "folder, rights 775").
This will be fixed with #194. Maybe looking for trailing '/' too will harden this.

You can't easily fix this without modifying the JSZip code, but in the meantime you can check if the file name ends with a slash instead of checking entry.dir.

@dduponchel dduponchel added the bug label Jan 20, 2015
@chrisrickard
Copy link
Author

Ok great, the slash-check will be fine for now (as I am in control of my zip contents). Thanks for the reply @dduponchel.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants