diff --git a/lib/tmp.js b/lib/tmp.js index e968214..aa13560 100644 --- a/lib/tmp.js +++ b/lib/tmp.js @@ -14,7 +14,7 @@ var path = require('path'), crypto = require('crypto'), tmpDir = require('os-tmpdir'), - _c = require('constants'); + _c = process.binding('constants'); /** @@ -31,7 +31,7 @@ var DEFAULT_TRIES = 3, - CREATE_FLAGS = _c.O_CREAT | _c.O_EXCL | _c.O_RDWR, + CREATE_FLAGS = (_c.O_CREAT || _c.fs.O_CREAT) | (_c.O_EXCL || _c.fs.O_EXCL) | (_c.O_RDWR || _c.fs.O_RDWR), DIR_MODE = 448 /* 0700 */, FILE_MODE = 384 /* 0600 */, @@ -351,7 +351,7 @@ function _prepareTmpFileRemoveCallback(name, fd, opts) { // under some node/windows related circumstances, a temporary file // may have not be created as expected or the file was already closed // by the user, in which case we will simply ignore the error - if (e.errno != -_c.EBADF && e.errno != -_c.ENOENT) { + if (e.errno != -(_c.EBADF || _c.os.errno.EBADF) && e.errno != -(_c.ENOENT || _c.os.errno.ENOENT)) { // reraise any unanticipated error throw e; } diff --git a/package.json b/package.json index dcb488a..71f5809 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "tmp", - "version": "0.0.29", + "version": "0.0.30", "description": "Temporary file and directory creator", "author": "KARASZI István (http://raszi.hu/)",