MCPcopy Index your code
hub / github.com/codeaashu/claude-code / readFileBytes

Function readFileBytes

src/utils/fsOperations.ts:578–602  ·  view source on GitHub ↗
(fsPath: string, maxBytes?: number)

Source from the content-addressed store, hash-verified

576 },
577
578 async readFileBytes(fsPath: string, maxBytes?: number) {
579 if (maxBytes === undefined) {
580 return readFilePromise(fsPath)
581 }
582 const handle = await open(fsPath, 'r')
583 try {
584 const { size } = await handle.stat()
585 const readSize = Math.min(size, maxBytes)
586 const buffer = Buffer.allocUnsafe(readSize)
587 let offset = 0
588 while (offset < readSize) {
589 const { bytesRead } = await handle.read(
590 buffer,
591 offset,
592 readSize - offset,
593 offset,
594 )
595 if (bytesRead === 0) break
596 offset += bytesRead
597 }
598 return offset < readSize ? buffer.subarray(0, offset) : buffer
599 } finally {
600 await handle.close()
601 }
602 },
603}
604
605// The currently active filesystem implementation

Callers

nothing calls this directly

Calls 3

openFunction · 0.85
readMethod · 0.65
closeMethod · 0.45

Tested by

no test coverage detected