MCPcopy Create free account
hub / github.com/MCSManager/MCSManager / resolveRealPath

Function resolveRealPath

daemon/src/tools/path_link_check.ts:11–30  ·  view source on GitHub ↗
(absolutePath: string)

Source from the content-addressed store, hash-verified

9 * Returns null if realpathSync fails on the existing ancestor.
10 */
11export function resolveRealPath(absolutePath: string): string | null {
12 let dir = path.resolve(absolutePath);
13 const root = path.parse(dir).root;
14 const missed: string[] = [];
15
16 while (true) {
17 try {
18 fs.lstatSync(dir);
19 try {
20 return path.join(fs.realpathSync(dir), ...missed);
21 } catch {
22 return null;
23 }
24 } catch {
25 if (dir === root) return null;
26 missed.unshift(path.basename(dir));
27 dir = path.dirname(dir);
28 }
29 }
30}

Callers 1

isOutsideWorkspaceMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected