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

Function readFileSyncWithMetadata

source code/utils/fileRead.ts:77–100  ·  view source on GitHub ↗
(filePath: string)

Source from the content-addressed store, hash-verified

75 * readSync(4KB).
76 */
77export function readFileSyncWithMetadata(filePath: string): {
78 content: string
79 encoding: BufferEncoding
80 lineEndings: LineEndingType
81} {
82 const fs = getFsImplementation()
83 const { resolvedPath, isSymlink } = safeResolvePath(fs, filePath)
84
85 if (isSymlink) {
86 logForDebugging(`Reading through symlink: ${filePath} -> ${resolvedPath}`)
87 }
88
89 const encoding = detectEncodingForResolvedPath(resolvedPath)
90 const raw = fs.readFileSync(resolvedPath, { encoding })
91 // Detect line endings from the raw head before CRLF normalization erases
92 // the distinction. 4096 code units is ≥ detectLineEndings's 4096-byte
93 // readSync sample (line endings are ASCII, so the unit mismatch is moot).
94 const lineEndings = detectLineEndingsForString(raw.slice(0, 4096))
95 return {
96 content: raw.replaceAll('\r\n', '\n'),
97 encoding,
98 lineEndings,
99 }
100}
101
102export function readFileSync(filePath: string): string {
103 return readFileSyncWithMetadata(filePath).content

Callers 6

validateInputFunction · 0.85
callFunction · 0.85
readFileForEditFunction · 0.85
callFunction · 0.85
readFileSyncFunction · 0.85

Calls 5

getFsImplementationFunction · 0.85
safeResolvePathFunction · 0.85
logForDebuggingFunction · 0.85

Tested by

no test coverage detected