Skip to content

Commit

Permalink
Merge 5362e5d into 764c127
Browse files Browse the repository at this point in the history
  • Loading branch information
guileen committed Mar 27, 2014
2 parents 764c127 + 5362e5d commit a6459ef
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ function lookup (buffer, filepath, callback) {
function asyncFileToBuffer (filepath, buffer, callback) {
// open the file in read only mode
fs.open(filepath, 'r', function (err, descriptor) {
if (err) { throw err; }
if (err) { return callback(err); }
// read first buffer block from the file, asynchronously
fs.read(descriptor, buffer, 0, bufferSize, 0, function (err) {
if (err) { throw err; }
if (err) { return callback(err); }
// close the file, we are done
fs.close(descriptor, function (err) {
if (err) { throw err; }
if (err) { return callback(err); }
// no errors, return the buffer
callback();
});
Expand Down Expand Up @@ -89,7 +89,8 @@ module.exports = function (input, callback) {
var buffer = new Buffer(bufferSize);

if (typeof callback === 'function') {
asyncFileToBuffer(filepath, buffer, function () {
asyncFileToBuffer(filepath, buffer, function (err) {
if(err) { return callback(err); }
// return the dimensions
lookup(buffer, filepath, callback);
});
Expand Down

0 comments on commit a6459ef

Please sign in to comment.