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