MCPcopy Index your code
hub / github.com/ChatLab/ChatLab / readFileHead

Function readFileHead

packages/parser/src/sniffer.ts:16–22  ·  view source on GitHub ↗

* 读取文件头部内容

(filePath: string, size: number = HEAD_SIZE)

Source from the content-addressed store, hash-verified

14 * 读取文件头部内容
15 */
16function readFileHead(filePath: string, size: number = HEAD_SIZE): string {
17 const fd = fs.openSync(filePath, 'r')
18 const buffer = Buffer.alloc(size)
19 const bytesRead = fs.readSync(fd, buffer, 0, size, 0)
20 fs.closeSync(fd)
21 return buffer.slice(0, bytesRead).toString('utf-8')
22}
23
24/**
25 * 获取文件扩展名(小写)

Callers 4

sniffMethod · 0.85
getParserMethod · 0.85
sniffAllMethod · 0.85
getParserCandidatesMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected