MCPcopy Create free account
hub / github.com/freecodexyz/free-code / readFileSafe

Function readFileSafe

src/utils/file.ts:50–58  ·  view source on GitHub ↗
(filepath: string)

Source from the content-addressed store, hash-verified

48export const MAX_OUTPUT_SIZE = 0.25 * 1024 * 1024 // 0.25MB in bytes
49
50export function readFileSafe(filepath: string): string | null {
51 try {
52 const fs = getFsImplementation()
53 return fs.readFileSync(filepath, { encoding: 'utf8' })
54 } catch (error) {
55 logError(error)
56 return null
57 }
58}
59
60/**
61 * Get the normalized modification time of a file in milliseconds.

Callers 1

DiffDetailViewFunction · 0.85

Calls 2

getFsImplementationFunction · 0.85
logErrorFunction · 0.70

Tested by

no test coverage detected