(filePath: string, size: number)
| 58 | } |
| 59 | |
| 60 | async function readFileSample(filePath: string, size: number): Promise<Uint8Array> { |
| 61 | if (size <= 0) return new Uint8Array() |
| 62 | const handle = await fs.open(filePath, "r") |
| 63 | try { |
| 64 | const buffer = Buffer.alloc(Math.min(size, FILE_SIGNATURE_SAMPLE_BYTES)) |
| 65 | const { bytesRead } = await handle.read(buffer, 0, buffer.length, 0) |
| 66 | return buffer.subarray(0, bytesRead) |
| 67 | } finally { |
| 68 | await handle.close() |
| 69 | } |
| 70 | } |
| 71 | |
| 72 | async function walk(root: string, options: { includeDirs?: boolean; showHidden?: boolean } = {}): Promise<Array<{ relativePath: string; fullPath: string; isDir: boolean }>> { |
| 73 | const result: Array<{ relativePath: string; fullPath: string; isDir: boolean }> = [] |
no test coverage detected