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

Function detectFileEncoding

source code/utils/file.ts:102–120  ·  view source on GitHub ↗
(filePath: string)

Source from the content-addressed store, hash-verified

100}
101
102export function detectFileEncoding(filePath: string): BufferEncoding {
103 try {
104 const fs = getFsImplementation()
105 const { resolvedPath } = safeResolvePath(fs, filePath)
106 return detectEncodingForResolvedPath(resolvedPath)
107 } catch (error) {
108 if (isFsInaccessible(error)) {
109 logForDebugging(
110 `detectFileEncoding failed for expected reason: ${error.code}`,
111 {
112 level: 'debug',
113 },
114 )
115 } else {
116 logError(error)
117 }
118 return 'utf8'
119 }
120}
121
122export function detectLineEndings(
123 filePath: string,

Callers 2

applySedEditFunction · 0.85
readFileMethod · 0.85

Calls 6

getFsImplementationFunction · 0.85
safeResolvePathFunction · 0.85
isFsInaccessibleFunction · 0.85
logForDebuggingFunction · 0.85
logErrorFunction · 0.70

Tested by

no test coverage detected