MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / readFileWall

Function readFileWall

packages/agent-core/src/tools/cron/clock.ts:110–136  ·  view source on GitHub ↗
(filePath: string)

Source from the content-addressed store, hash-verified

108const MAX_CLOCK_FILE_BYTES = 64;
109
110function readFileWall(filePath: string): number {
111 let bytesRead = 0;
112 const buf = Buffer.alloc(MAX_CLOCK_FILE_BYTES);
113 let fd: number;
114 try {
115 fd = openSync(filePath, 'r');
116 } catch {
117 return Date.now();
118 }
119 try {
120 bytesRead = readSync(fd, buf, 0, MAX_CLOCK_FILE_BYTES, 0);
121 } catch {
122 return Date.now();
123 } finally {
124 try {
125 closeSync(fd);
126 } catch {
127 /* swallow close errors */
128 }
129 }
130 const raw = buf.subarray(0, bytesRead).toString('utf8');
131 const firstLine = raw.split('\n', 1)[0]?.trim() ?? '';
132 if (firstLine === '') return Date.now();
133 const parsed = Number(firstLine);
134 if (!Number.isFinite(parsed)) return Date.now();
135 return parsed;
136}
137
138function debugInvalidSpec(spec: string, reason: string): void {
139 // We do not pull in a logger here — `clock.ts` is the lowest layer of

Callers 1

resolveClockSourcesFunction · 0.85

Calls 2

nowMethod · 0.65
toStringMethod · 0.65

Tested by

no test coverage detected