(path, options)
| 567 | } |
| 568 | |
| 569 | readdirSync(path, options) { |
| 570 | const entry = this.#getEntry(path, 'scandir', true); |
| 571 | if (!entry.isDirectory()) { |
| 572 | throw createENOTDIR('scandir', path); |
| 573 | } |
| 574 | |
| 575 | // Ensure directory is populated (for lazy population) |
| 576 | this.#ensurePopulated(entry, path); |
| 577 | |
| 578 | const normalized = this.#normalizePath(path); |
| 579 | const withFileTypes = options?.withFileTypes === true; |
| 580 | const recursive = options?.recursive === true; |
| 581 | |
| 582 | if (recursive) { |
| 583 | return this.#readdirRecursive(entry, normalized, withFileTypes); |
| 584 | } |
| 585 | |
| 586 | if (withFileTypes) { |
| 587 | const dirents = []; |
| 588 | for (const { 0: name, 1: childEntry } of entry.children) { |
| 589 | let type; |
| 590 | if (childEntry.isSymbolicLink()) { |
| 591 | type = UV_DIRENT_LINK; |
| 592 | } else if (childEntry.isDirectory()) { |
| 593 | type = UV_DIRENT_DIR; |
| 594 | } else { |
| 595 | type = UV_DIRENT_FILE; |
| 596 | } |
| 597 | ArrayPrototypePush(dirents, new Dirent(name, type, normalized)); |
| 598 | } |
| 599 | return dirents; |
| 600 | } |
| 601 | |
| 602 | return ArrayFrom(entry.children.keys()); |
| 603 | } |
| 604 | |
| 605 | /** |
| 606 | * Recursively reads directory contents. |
no test coverage detected