MCPcopy Create free account
hub / github.com/BlockRunAI/ClawRouter / readTextFile

Function readTextFile

src/fs-read.ts:12–27  ·  view source on GitHub ↗
(filePath: string)

Source from the content-addressed store, hash-verified

10
11/** Read file contents as UTF-8 string (async). */
12export async function readTextFile(filePath: string): Promise<string> {
13 const fh = await open(filePath, "r");
14 try {
15 const size = (await fh.stat()).size;
16 const buf = Buffer.alloc(size);
17 let offset = 0;
18 while (offset < size) {
19 const { bytesRead } = await fh.read(buf, offset, size - offset, offset);
20 if (bytesRead === 0) break;
21 offset += bytesRead;
22 }
23 return buf.subarray(0, offset).toString("utf-8");
24 } finally {
25 await fh.close();
26 }
27}
28
29/** Read file contents as UTF-8 string (sync). */
30export function readTextFileSync(filePath: string): string {

Callers 5

parseLogFileFunction · 0.85
loadSavedWalletFunction · 0.85
loadMnemonicFunction · 0.85
generateAndSaveWalletFunction · 0.85
loadPaymentChainFunction · 0.85

Calls 1

closeMethod · 0.80

Tested by

no test coverage detected