| 747 | } |
| 748 | |
| 749 | function makeStats(node: TreeNode): unknown { |
| 750 | const isDir = node.type === 'dir'; |
| 751 | // Either include type bits (0o040000/0o100000) or strip them to force |
| 752 | // the buildStMode helper to derive them via isDirectory()/isFile(). |
| 753 | const baseMode = isDir ? 0o040755 : 0o100644; |
| 754 | const mode = node.stripTypeBits === true ? baseMode & 0o7777 : baseMode; |
| 755 | return { |
| 756 | mode, |
| 757 | size: node.content ? node.content.length : 0, |
| 758 | uid: 1000, |
| 759 | gid: 1000, |
| 760 | atime: 100, |
| 761 | mtime: 200, |
| 762 | isDirectory: () => isDir, |
| 763 | isFile: () => !isDir, |
| 764 | isSymbolicLink: () => false, |
| 765 | isSocket: () => false, |
| 766 | isCharacterDevice: () => false, |
| 767 | isBlockDevice: () => false, |
| 768 | isFIFO: () => false, |
| 769 | }; |
| 770 | } |
| 771 | |
| 772 | function lookup(root: TreeNode, path: string): TreeNode | undefined { |
| 773 | if (path === '/') return root; |