MCPcopy Create free account
hub / github.com/bearlyai/OpenADE / readFileSample

Function readFileSample

projects/runtime-node/src/localFiles.ts:60–70  ·  view source on GitHub ↗
(filePath: string, size: number)

Source from the content-addressed store, hash-verified

58}
59
60async 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
72async 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 }> = []

Callers 1

describePathFunction · 0.70

Calls 2

closeMethod · 0.65
openMethod · 0.45

Tested by

no test coverage detected