MCPcopy
hub / github.com/21st-dev/1code / exists

Function exists

src/main/lib/git/security/secure-fs.ts:421–431  ·  view source on GitHub ↗

* Check if a file exists within a worktree. * * Returns false for non-existent files, symlink escapes, and validation failures.

(worktreePath: string, filePath: string)

Source from the content-addressed store, hash-verified

419 * Returns false for non-existent files, symlink escapes, and validation failures.
420 */
421 async exists(worktreePath: string, filePath: string): Promise<boolean> {
422 try {
423 assertRegisteredWorktree(worktreePath);
424 const fullPath = resolvePathInWorktree(worktreePath, filePath);
425 await assertRealpathInWorktree(worktreePath, fullPath);
426 await stat(fullPath);
427 return true;
428 } catch {
429 return false;
430 }
431 },
432
433 /**
434 * Check if a file is a symlink that points outside the worktree.

Callers

nothing calls this directly

Calls 4

assertRegisteredWorktreeFunction · 0.90
resolvePathInWorktreeFunction · 0.90
assertRealpathInWorktreeFunction · 0.85
statFunction · 0.85

Tested by

no test coverage detected