MCPcopy
hub / github.com/claude-code-best/claude-code / appendFileSync

Function appendFileSync

src/utils/fsOperations.ts:468–487  ·  view source on GitHub ↗
(path, data, options)

Source from the content-addressed store, hash-verified

466 },
467
468 appendFileSync(path, data, options) {
469 using _ = slowLogging`fs.appendFileSync(${path}, ${data.length} chars)`
470 // For new files with explicit mode, use 'ax' (atomic create-with-mode) to avoid
471 // TOCTOU race between existence check and open. Fall back to normal append if exists.
472 if (options?.mode !== undefined) {
473 try {
474 const fd = fs.openSync(path, 'ax', options.mode)
475 try {
476 fs.appendFileSync(fd, data)
477 } finally {
478 fs.closeSync(fd)
479 }
480 return
481 } catch (e) {
482 if (getErrnoCode(e) !== 'EEXIST') throw e
483 // File exists — fall through to normal append
484 }
485 }
486 fs.appendFileSync(path, data)
487 },
488
489 copyFileSync(src, dest) {
490 using _ = slowLogging`fs.copyFileSync(${src} → ${dest})`

Callers 5

getRenderContextFunction · 0.90
appendJobReplyFunction · 0.90
rcLogFunction · 0.85
rcLogClearFunction · 0.85
appendBreakEventFunction · 0.85

Calls 1

getErrnoCodeFunction · 0.85

Tested by

no test coverage detected