|
29 | 29 |
|
30 | 30 | CREATE_FLAGS = (_c.O_CREAT || _c.fs.O_CREAT) | (_c.O_EXCL || _c.fs.O_EXCL) | (_c.O_RDWR || _c.fs.O_RDWR), |
31 | 31 |
|
| 32 | + // constants are off on the windows platform and will not match the actual errno codes |
| 33 | + IS_WIN32 = os.platform() === 'win32', |
32 | 34 | EBADF = _c.EBADF || _c.os.errno.EBADF, |
33 | 35 | ENOENT = _c.ENOENT || _c.os.errno.ENOENT, |
34 | 36 |
|
@@ -134,7 +136,7 @@ function file(options, callback) { |
134 | 136 |
|
135 | 137 | // create and open the file |
136 | 138 | fs.open(name, CREATE_FLAGS, opts.mode || FILE_MODE, function _fileCreated(err, fd) { |
137 | | - /* istanbul ignore else */ |
| 139 | + /* istanbu ignore else */ |
138 | 140 | if (err) return cb(err); |
139 | 141 |
|
140 | 142 | if (opts.discardDescriptor) { |
@@ -604,13 +606,18 @@ function _isENOENT(error) { |
604 | 606 | * error.code {string} |
605 | 607 | * error.errno {number} any numerical value will be negated |
606 | 608 | * |
| 609 | + * CAVEAT |
| 610 | + * |
| 611 | + * On windows, the errno for EBADF is -4083 but os.constants.errno.EBADF is different and we must assume that ENOENT |
| 612 | + * is no different here. |
| 613 | + * |
607 | 614 | * @param {SystemError} error |
608 | 615 | * @param {number} errno |
609 | 616 | * @param {string} code |
610 | 617 | * @private |
611 | 618 | */ |
612 | 619 | function _isExpectedError(error, errno, code) { |
613 | | - return error.code === code && error.errno === errno; |
| 620 | + return IS_WIN32 ? error.code === code : error.code === code && error.errno === errno; |
614 | 621 | } |
615 | 622 |
|
616 | 623 | /** |
|
0 commit comments