glebdmitriew / node-unzip-2

node.js cross-platform unzip using streams
MIT License
44 stars 39 forks source link

Preserve file permissions via external attributes #10

Open fasterthanlime opened 9 years ago

fasterthanlime commented 9 years ago

Hey there - first off, thanks for the unzip fork, definitely appreciated!

My only concern is that I'm trying to extract .zip files containing applications, on OSX & Linux. For those to work, the executables need to have the right permissions (notably, the executable bit must be set).

In the original ZIP format, there was no way to do that - but later on, OSX & Linux versions of zip & unzip added support for it by (ab)using the 'external attribute' field in the ZIP entry table.

See for reference:

Do you have any pointers on how I would go about retrieving the external file attributes for a zip entry? It doesn't seem to be included in the 'entry' event of unzip.Parse().

fasterthanlime commented 9 years ago

After further investigation, it seems parser.js already has that information! Here's how I was able to display permissions: https://github.com/fasterthanlime/node-unzip-2/commit/5a21d60af3b4e603bff73c6275f85a1072762211

Any idea how to integrate it into the current API? it seems 'file' and 'central directory header' entries are distinct, so perhaps a different event would make sense?

fasterthanlime commented 9 years ago

Following up on this, we're currently successfully using the quick-hack branch of our fork (cf. comparison with node-unzip-2 master).

It's probably not the best interface though, so I'm looking forward to get feedback from you on how this could be integrated in the main repo. I'd prefer not to keep our fork around for too long!