Signed-off-by: Filip Skokan <panva.ip@gmail.com> PR-URL: https://github.com/nodejs/node/pull/63556 Reviewed-By: Jordan Harband <ljharb@gmail.com> Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
33 lines
832 B
JavaScript
33 lines
832 B
JavaScript
'use strict';
|
|
|
|
require('../common');
|
|
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
const os = require('os');
|
|
|
|
const missing = path.join(
|
|
os.tmpdir(),
|
|
`node-fs-negative-zero-${process.pid}`,
|
|
'entry',
|
|
);
|
|
|
|
function ignoreExpectedError(fn) {
|
|
try {
|
|
fn();
|
|
} catch {
|
|
// Ignore expected file system errors from the missing path.
|
|
}
|
|
}
|
|
|
|
const fd = fs.openSync(process.execPath, -0);
|
|
fs.closeSync(fd);
|
|
|
|
ignoreExpectedError(() => fs.openSync(process.execPath, 'r', -0));
|
|
ignoreExpectedError(() => fs.readFileSync(process.execPath, { flag: -0 }));
|
|
ignoreExpectedError(() => fs.mkdirSync(missing, { mode: -0 }));
|
|
ignoreExpectedError(() => fs.chmodSync(missing, -0));
|
|
ignoreExpectedError(() => fs.writeFileSync(missing, '', { mode: -0 }));
|
|
|
|
fs.watchFile(missing, { interval: -0 }, () => {});
|
|
fs.unwatchFile(missing);
|