(path, options, callback)
| 328 | }); |
| 329 | |
| 330 | function 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 | |
| 371 | function opendirSync(path, options) { |
| 372 | const h = vfsState.handlers; |
no test coverage detected
searching dependent graphs…