MCPcopy Create free account
hub / github.com/Kilo-Org/cloud / readFile

Method readFile

services/app-builder/src/git/memfs.ts:28–43  ·  view source on GitHub ↗
(path: string, options?: { encoding?: string })

Source from the content-addressed store, hash-verified

26 }
27
28 async readFile(path: string, options?: { encoding?: string }): Promise<Uint8Array | string> {
29 const normalized = path.startsWith('/') ? path.slice(1) : path;
30 const data = this.files.get(normalized);
31
32 if (!data) {
33 const error: ErrnoException = new Error(`ENOENT: no such file or directory, open '${path}'`);
34 error.code = 'ENOENT';
35 throw error;
36 }
37
38 if (options?.encoding === 'utf8') {
39 return new TextDecoder().decode(data);
40 }
41
42 return data;
43 }
44
45 async readdir(dirPath: string): Promise<string[]> {
46 const normalized = dirPath === '/' ? '' : dirPath.startsWith('/') ? dirPath.slice(1) : dirPath;

Callers 7

saveDbSnapshotFunction · 0.45
readWrapperLogsMethod · 0.45
needsDBFunction · 0.45
resolveHeadSymrefFunction · 0.45

Calls 2

getMethod · 0.65
decodeMethod · 0.45

Tested by

no test coverage detected