(path, data, options)
| 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})` |
no test coverage detected