MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / readFileBytes

Function readFileBytes

source code/utils/fsOperations.ts:580–604  ·  view source on GitHub ↗
(fsPath: string, maxBytes?: number)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 3

openFunction · 0.85
readMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected