MCPcopy Index your code
hub / github.com/nodejs/node / open

Function open

lib/fs.js:656–680  ·  view source on GitHub ↗

* Asynchronously opens a file. * @param {string | Buffer | URL} path * @param {string | number} [flags] * @param {string | number} [mode] * @param {( * err?: Error, * fd?: number * ) => any} callback * @returns {void}

(path, flags, mode, callback)

Source from the content-addressed store, hash-verified

654 * @returns {void}
655 */
656function open(path, flags, mode, callback) {
657 if (arguments.length < 3) {
658 callback = flags;
659 flags = 'r';
660 mode = 0o666;
661 } else if (typeof mode === 'function') {
662 callback = mode;
663 mode = 0o666;
664 } else {
665 mode = parseFileMode(mode, 'mode', 0o666);
666 }
667
668 const flagsNumber = stringToFlags(flags);
669
670 const h = vfsState.handlers;
671 if (h !== null && vfsResult(h.open(path, flagsNumber, mode), callback)) return;
672
673 path = getValidatedPath(path);
674 callback = makeCallback(callback);
675
676 const req = new FSReqCallback();
677 req.oncomplete = callback;
678
679 binding.open(path, flagsNumber, mode, req);
680}
681
682/**
683 * Synchronously opens a file.

Callers 3

inspectorOpenFunction · 0.70
mainFunction · 0.50
mainFunction · 0.50

Calls 5

parseFileModeFunction · 0.85
stringToFlagsFunction · 0.85
vfsResultFunction · 0.85
makeCallbackFunction · 0.70
openMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…