import { CHAR_BACKWARD_SLASH, CHAR_COLON, CHAR_DOT, CHAR_QUESTION_MARK,} from "./_constants.ts";import { isWindowsDeviceRoot } from "./_util.ts";import { windowsResolve } from "./_resolve.ts";
export function posixToNamespacedPath(path: string): string { return path;}
export function windowsToNamespacedPath(path: string): string { if (typeof path !== "string") return path; if (path.length === 0) return "";
const resolvedPath = windowsResolve(path);
if (resolvedPath.length >= 3) { if (resolvedPath.charCodeAt(0) === CHAR_BACKWARD_SLASH) {
if (resolvedPath.charCodeAt(1) === CHAR_BACKWARD_SLASH) { const code = resolvedPath.charCodeAt(2); if (code !== CHAR_QUESTION_MARK && code !== CHAR_DOT) { return `\\\\?\\UNC\\${resolvedPath.slice(2)}`; } } } else if (isWindowsDeviceRoot(resolvedPath.charCodeAt(0))) {
if ( resolvedPath.charCodeAt(1) === CHAR_COLON && resolvedPath.charCodeAt(2) === CHAR_BACKWARD_SLASH ) { return `\\\\?\\${resolvedPath}`; } } }
return path;}