/**
 * File system utilities.
 *
 * @module
 */
/**
 * Write a file atomically via temp file + rename.
 *
 * Writes to `<path>.tmp` then renames over `path` so readers either see the
 * old contents or the full new contents — never a partial write.
 *
 * @mutates filesystem - creates `<path>.tmp` then renames it to `path`
 * @throws Error if `write_text_file` or `rename` rejects (permissions, disk full, cross-device rename, etc.)
 */
export const write_file_atomic = async (deps, path, content) => {
    const temp_path = path + '.tmp';
    await deps.write_text_file(temp_path, content);
    await deps.rename(temp_path, path);
};
