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

Function getDirents

lib/internal/fs/utils.js:252–295  ·  view source on GitHub ↗
(path, { 0: names, 1: types }, callback)

Source from the content-addressed store, hash-verified

250}
251
252function getDirents(path, { 0: names, 1: types }, callback) {
253 let i;
254 if (typeof callback === 'function') {
255 const len = names.length;
256 let toFinish = 0;
257 callback = once(callback);
258 for (i = 0; i < len; i++) {
259 const type = types[i];
260 if (type === UV_DIRENT_UNKNOWN) {
261 const name = names[i];
262 const idx = i;
263 toFinish++;
264 let filepath;
265 try {
266 filepath = join(path, name);
267 } catch (err) {
268 callback(err);
269 return;
270 }
271 lazyLoadFs().lstat(filepath, (err, stats) => {
272 if (err) {
273 callback(err);
274 return;
275 }
276 names[idx] = new DirentFromStats(name, stats, path);
277 if (--toFinish === 0) {
278 callback(null, names);
279 }
280 });
281 } else {
282 names[i] = new Dirent(names[i], types[i], path);
283 }
284 }
285 if (toFinish === 0) {
286 callback(null, names);
287 }
288 } else {
289 const len = names.length;
290 for (i = 0; i < len; i++) {
291 names[i] = getDirent(path, names[i], types[i]);
292 }
293 return names;
294 }
295}
296
297function getDirent(path, name, type, callback) {
298 if (typeof callback === 'function') {

Callers 4

readdirFunction · 0.85
readdirSyncFunction · 0.85
readdirRecursiveFunction · 0.85

Calls 6

lazyLoadFsFunction · 0.85
joinFunction · 0.70
getDirentFunction · 0.70
onceFunction · 0.50
callbackFunction · 0.50
lstatMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…