Skip to content

Instantly share code, notes, and snippets.

@tatat
Created May 29, 2017 13:06
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save tatat/054aa40596d3085c325ba2fb4cf131d5 to your computer and use it in GitHub Desktop.
function isZip(path, callback) {
fs.open(path, 'r', (error, fd) => {
if (error)
return callback(error)
fs.read(fd, Buffer.alloc(4), 0, 4, 0, (error, bytesRead, buffer) => {
if (error)
return callback(error)
callback(null, buffer.readUInt32LE(0) === 0x04034b50)
})
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment