MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / readRegularFileSync

Function readRegularFileSync

src/file-limits.ts:76–84  ·  view source on GitHub ↗
(file: string, encoding?: BufferEncoding)

Source from the content-addressed store, hash-verified

74export function readRegularFileSync(file: string): Buffer;
75export function readRegularFileSync(file: string, encoding: BufferEncoding): string;
76export function readRegularFileSync(file: string, encoding?: BufferEncoding): string | Buffer {
77 const fd = fs.openSync(file, fs.constants.O_RDONLY | (fs.constants.O_NONBLOCK ?? 0));
78 try {
79 if (!fs.fstatSync(fd).isFile()) throw notRegularFile(file);
80 return encoding ? fs.readFileSync(fd, encoding) : fs.readFileSync(fd);
81 } finally {
82 fs.closeSync(fd);
83 }
84}
85
86/**
87 * `fs.writeFileSync` for the same kind of name: it replaces a regular file's

Callers 15

ensureGitignoreFunction · 0.90
makeGitignoreLocalOnlyFunction · 0.90
readHolderMethod · 0.90
releaseMethod · 0.90
parseConfigFunction · 0.90
readGitignorePatternsFunction · 0.90
sparseCheckoutStampFunction · 0.90
projectInfoFunction · 0.90
loadGoModuleFunction · 0.90
readPackageEntriesFunction · 0.90

Calls 2

notRegularFileFunction · 0.85
openSyncMethod · 0.45

Tested by

no test coverage detected