kriskowal/zip — pull request #10 by steffenmllr (2013-08-09 11:49:21+00:00)
Title: Added getMode method to determine the chmod on unix systems

hey there,

I needed to access the chmod value from the central directory file header in order to get a mac app to unpack so I added a getMode to the Entry and the mode to the Entry constructor.

My sample file was https://s3.amazonaws.com/node-webkit/v0.6.3/node-webkit-v0.6.3-osx-ia32.zip

Here is the sample code to unpack:

```javascript
var ZIP = require('zip');
var fs = require('fs-extra');
var data = fs.readFileSync('node-webkit-v0.6.3-osx-ia32.zip');
var reader = ZIP.Reader(data);
var readFromBuffer = reader.toObject('utf-8');
reader.forEach(function (entry) {
var mode = entry.getMode(),
fileName = entry.getName();
if(entry.isDirectory()) {
fs.mkdirs(fileName, function(err){
if(mode) fs.chmodSync(fileName, mode);
});
} else {
fs.writeFileSync(fileName, entry.getData());
if(mode) fs.chmodSync(fileName, mode);
}
});
```