MCPcopy Index your code
hub / github.com/jvilk/BrowserFS / realpath

Method realpath

src/core/file_system.ts:571–591  ·  view source on GitHub ↗
(p: string, cache: {[path: string]: string}, cb: BFSCallback<string>)

Source from the content-addressed store, hash-verified

569 }
570 }
571 public realpath(p: string, cache: {[path: string]: string}, cb: BFSCallback<string>): void {
572 if (this.supportsLinks()) {
573 // The path could contain symlinks. Split up the path,
574 // resolve any symlinks, return the resolved string.
575 const splitPath = p.split(path.sep);
576 // TODO: Simpler to just pass through file, find sep and such.
577 for (let i = 0; i < splitPath.length; i++) {
578 const addPaths = splitPath.slice(0, i + 1);
579 splitPath[i] = path.join.apply(null, addPaths);
580 }
581 } else {
582 // No symlinks. We just need to verify that it exists.
583 this.exists(p, function(doesExist) {
584 if (doesExist) {
585 cb(null, p);
586 } else {
587 cb(ApiError.ENOENT(p));
588 }
589 });
590 }
591 }
592 public realpathSync(p: string, cache: {[path: string]: string}): string {
593 if (this.supportsLinks()) {
594 // The path could contain symlinks. Split up the path,

Callers

nothing calls this directly

Calls 4

supportsLinksMethod · 0.95
existsMethod · 0.95
cbFunction · 0.85
ENOENTMethod · 0.80

Tested by

no test coverage detected