MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / readFileRange

Function readFileRange

packages/agent-core/src/services/fs/fsService.ts:597–612  ·  view source on GitHub ↗
(
  absPath: string,
  start: number,
  end: number,
)

Source from the content-addressed store, hash-verified

595}
596
597async function readFileRange(
598 absPath: string,
599 start: number,
600 end: number,
601): Promise<Buffer> {
602 if (end <= start) return Buffer.alloc(0);
603 const fh = await fs.open(absPath, 'r');
604 try {
605 const length = end - start;
606 const buf = Buffer.allocUnsafe(length);
607 const { bytesRead } = await fh.read(buf, 0, length, start);
608 return bytesRead === length ? buf : buf.subarray(0, bytesRead);
609 } finally {
610 await fh.close();
611 }
612}
613
614const EXT_TO_MIME: Readonly<Record<string, string>> = {
615 '.ts': 'text/typescript',

Callers 2

readMethod · 0.85
resolveDownloadMethod · 0.85

Calls 3

readMethod · 0.65
closeMethod · 0.65
openMethod · 0.45

Tested by

no test coverage detected