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

Function detectBinary

packages/agent-core/src/services/fs/fsService.ts:582–595  ·  view source on GitHub ↗
(buf: Buffer)

Source from the content-addressed store, hash-verified

580}
581
582function detectBinary(buf: Buffer): boolean {
583 if (buf.length === 0) return false;
584 let nonPrintable = 0;
585 for (let i = 0; i < buf.length; i++) {
586 const b = buf[i]!;
587 if (b === 0) return true;
588
589 if (b === 9 || b === 10 || b === 13) continue;
590 if (b >= 32 && b <= 126) continue;
591
592 nonPrintable++;
593 }
594 return nonPrintable / buf.length > FS_BINARY_NONPRINTABLE_FRACTION;
595}
596
597async function readFileRange(
598 absPath: string,

Callers 2

readMethod · 0.85
resolveDownloadMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected