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

Function opendir

lib/internal/fs/dir.js:330–369  ·  view source on GitHub ↗
(path, options, callback)

Source from the content-addressed store, hash-verified

328});
329
330function opendir(path, options, callback) {
331 callback = typeof options === 'function' ? options : callback;
332 validateFunction(callback, 'callback');
333
334 const h = vfsState.handlers;
335 if (h !== null) {
336 try {
337 const result = h.opendirSync(path, options);
338 if (result !== undefined) {
339 process.nextTick(callback, null, result);
340 return;
341 }
342 } catch (err) {
343 process.nextTick(callback, err);
344 return;
345 }
346 }
347
348 path = getValidatedPath(path);
349 options = getOptions(options, {
350 encoding: 'utf8',
351 });
352
353 function opendirCallback(error, handle) {
354 if (error) {
355 callback(error);
356 } else {
357 callback(null, new Dir(handle, path, options));
358 }
359 }
360
361 const req = new FSReqCallback();
362 req.oncomplete = opendirCallback;
363
364 dirBinding.opendir(
365 path,
366 options.encoding,
367 req,
368 );
369}
370
371function opendirSync(path, options) {
372 const h = vfsState.handlers;

Callers 1

copyDirFunction · 0.50

Calls 3

opendirSyncMethod · 0.80
opendirMethod · 0.80
getOptionsFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…