MCPcopy Index your code
hub / github.com/nodejs/node / toNamespacedPath

Function toNamespacedPath

lib/path.js:768–797  ·  view source on GitHub ↗

* @param {string} path * @returns {string}

(path)

Source from the content-addressed store, hash-verified

766 * @returns {string}
767 */
768 toNamespacedPath(path) {
769 // Note: this will *probably* throw somewhere.
770 if (typeof path !== 'string' || path.length === 0)
771 return path;
772
773 const resolvedPath = win32.resolve(path);
774
775 if (resolvedPath.length <= 2)
776 return path;
777
778 if (StringPrototypeCharCodeAt(resolvedPath, 0) === CHAR_BACKWARD_SLASH) {
779 // Possible UNC root
780 if (StringPrototypeCharCodeAt(resolvedPath, 1) === CHAR_BACKWARD_SLASH) {
781 const code = StringPrototypeCharCodeAt(resolvedPath, 2);
782 if (code !== CHAR_QUESTION_MARK && code !== CHAR_DOT) {
783 // Matched non-long UNC root, convert the path to a long UNC path
784 return `\\\\?\\UNC\\${StringPrototypeSlice(resolvedPath, 2)}`;
785 }
786 }
787 } else if (
788 isWindowsDeviceRoot(StringPrototypeCharCodeAt(resolvedPath, 0)) &&
789 StringPrototypeCharCodeAt(resolvedPath, 1) === CHAR_COLON &&
790 StringPrototypeCharCodeAt(resolvedPath, 2) === CHAR_BACKWARD_SLASH
791 ) {
792 // Matched device root, convert the path to a long UNC path
793 return `\\\\?\\${resolvedPath}`;
794 }
795
796 return resolvedPath;
797 },
798
799 /**
800 * @param {string} path

Callers 2

watchers.jsFile · 0.85
watchFunction · 0.85

Calls 2

isWindowsDeviceRootFunction · 0.85
resolveMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…