(relPath: string, content: string)
| 210 | |
| 211 | /** 写单个文件(UTF-8)。调用者负责权限校验。 */ |
| 212 | export async function writeFile(relPath: string, content: string): Promise<void> { |
| 213 | const abs = safeResolve(relPath); |
| 214 | // 写入前若文件已存在且是 symlink → 拒绝(避免覆盖项目外文件) |
| 215 | assertNotSymlinkEscape(abs); |
| 216 | await fsp.mkdir(path.dirname(abs), { recursive: true }); |
| 217 | await fsp.writeFile(abs, content, "utf8"); |
| 218 | } |
| 219 | |
| 220 | export async function fileExists(relPath: string): Promise<boolean> { |
| 221 | try { |
no test coverage detected