(relPath: string, maxBytes: number)
| 358 | } |
| 359 | |
| 360 | async readFilePrefix(relPath: string, maxBytes: number): Promise<string> { |
| 361 | const handle = await fsPromises.open(this.abs(relPath), "r"); |
| 362 | try { |
| 363 | const buffer = Buffer.alloc(maxBytes); |
| 364 | const { bytesRead } = await handle.read(buffer, 0, maxBytes, 0); |
| 365 | return buffer.subarray(0, bytesRead).toString("utf-8"); |
| 366 | } finally { |
| 367 | await handle.close(); |
| 368 | } |
| 369 | } |
| 370 | |
| 371 | async writeFile(relPath: string, content: string): Promise<void> { |
| 372 | const absPath = this.abs(relPath); |