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

Method realpathSync

src/core/file_system.ts:592–611  ·  view source on GitHub ↗
(p: string, cache: {[path: string]: string})

Source from the content-addressed store, hash-verified

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,
595 // resolve any symlinks, return the resolved string.
596 const splitPath = p.split(path.sep);
597 // TODO: Simpler to just pass through file, find sep and such.
598 for (let i = 0; i < splitPath.length; i++) {
599 const addPaths = splitPath.slice(0, i + 1);
600 splitPath[i] = path.join.apply(path, addPaths);
601 }
602 return splitPath.join(path.sep);
603 } else {
604 // No symlinks. We just need to verify that it exists.
605 if (this.existsSync(p)) {
606 return p;
607 } else {
608 throw ApiError.ENOENT(p);
609 }
610 }
611 }
612 public truncate(p: string, len: number, cb: BFSOneArgCallback): void {
613 this.open(p, FileFlag.getFileFlag('r+'), 0x1a4, (function(er: ApiError, fd?: File) {
614 if (er) {

Callers

nothing calls this directly

Calls 3

supportsLinksMethod · 0.95
existsSyncMethod · 0.95
ENOENTMethod · 0.80

Tested by

no test coverage detected