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

Method open

lib/internal/vfs/file_system.js:780–796  ·  view source on GitHub ↗

* Opens a file asynchronously. * @param {string} filePath The path to open * @param {string|Function} [flags] Open flags or callback * @param {number|Function} [mode] File mode or callback * @param {Function} [callback] Callback (err, fd)

(filePath, flags, mode, callback)

Source from the content-addressed store, hash-verified

778 * @param {Function} [callback] Callback (err, fd)
779 */
780 open(filePath, flags, mode, callback) {
781 if (typeof flags === 'function') {
782 callback = flags;
783 flags = 'r';
784 mode = undefined;
785 } else if (typeof mode === 'function') {
786 callback = mode;
787 mode = undefined;
788 }
789
790 const providerPath = this.#toProviderPath(filePath);
791 this[kProvider].open(providerPath, flags, mode)
792 .then((handle) => {
793 const fd = openVirtualFd(handle);
794 callback(null, fd);
795 }, (err) => callback(err));
796 }
797
798 /**
799 * Closes a file descriptor asynchronously.

Callers

nothing calls this directly

Calls 6

#toProviderPathMethod · 0.95
openVirtualFdFunction · 0.85
openMethod · 0.65
callbackFunction · 0.50
thenMethod · 0.45
openSyncMethod · 0.45

Tested by

no test coverage detected