MCPcopy Create free account
hub / github.com/cloudflare/agents / resolveSymlink

Method resolveSymlink

packages/shell/src/filesystem.ts:396–411  ·  view source on GitHub ↗
(path: string, depth = 0)

Source from the content-addressed store, hash-verified

394 // ── Symlink resolution ────────────────────────────────────────
395
396 private async resolveSymlink(path: string, depth = 0): Promise<string> {
397 if (depth > MAX_SYMLINK_DEPTH) {
398 throw new Error(`ELOOP: too many levels of symbolic links: ${path}`);
399 }
400 const T = this.tableName;
401 const rows = await this.sql.query<{
402 type: string;
403 target: string | null;
404 }>(`SELECT type, target FROM ${T} WHERE path = ?`, path);
405 const r = rows[0];
406 if (!r || r.type !== "symlink" || !r.target) return path;
407 const resolved = r.target.startsWith("/")
408 ? normalizePath(r.target)
409 : normalizePath(getParent(path) + "/" + r.target);
410 return this.resolveSymlink(resolved, depth + 1);
411 }
412
413 // ── Symlink API ───────────────────────────────────────────────
414

Callers 8

statMethod · 0.95
readFileMethod · 0.95
readFileBytesMethod · 0.95
writeFileBytesMethod · 0.95
writeFileMethod · 0.95
readFileStreamMethod · 0.95
appendFileMethod · 0.95
fileExistsMethod · 0.95

Calls 2

getParentFunction · 0.85
normalizePathFunction · 0.70

Tested by

no test coverage detected