MCPcopy Create free account
hub / github.com/Qinbf/groundmap / writeFile

Function writeFile

web/lib/kb.ts:212–218  ·  view source on GitHub ↗
(relPath: string, content: string)

Source from the content-addressed store, hash-verified

210
211/** 写单个文件(UTF-8)。调用者负责权限校验。 */
212export 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
220export async function fileExists(relPath: string): Promise<boolean> {
221 try {

Callers 2

applyResolveFunction · 0.90
PUTFunction · 0.90

Calls 2

safeResolveFunction · 0.85
assertNotSymlinkEscapeFunction · 0.85

Tested by

no test coverage detected