diff --git a/xpcom/obsolete/nsFileSpec.cpp b/xpcom/obsolete/nsFileSpec.cpp index ad74cc2f506..9be29eb903b 100644 --- a/xpcom/obsolete/nsFileSpec.cpp +++ b/xpcom/obsolete/nsFileSpec.cpp @@ -467,8 +467,18 @@ void nsFileSpecHelpers::MakeAllDirectories(const char* inPath, int mode) } else { + // move after server name and share name in UNC path + if (pathCopy[0] == '/' && + currentEnd == currentStart+kSkipFirst) + { + *currentEnd = '/'; + currentStart = strchr(pathCopy+2, kSeparator); + currentStart = strchr(currentStart+1, kSeparator); + currentEnd = strchr(currentStart+1, kSeparator); + if (currentEnd) + *currentEnd = '\0'; + } spec = nsFilePath(pathCopy, PR_FALSE); - } #else spec = nsFilePath(pathCopy, PR_FALSE); @@ -728,7 +738,8 @@ nsFilePath::nsFilePath(const nsString& inString, PRBool inCreateDirs) // Make canonical and absolute. nsFileSpecHelpers::Canonify(mPath, inCreateDirs); #if defined(XP_WIN) || defined(XP_OS2) - NS_ASSERTION( mPath[1] == ':', "unexpected canonical path" ); + NS_ASSERTION( mPath[1] == ':' || (mPath[0] == '\\' && mPath[1] == '\\'), + "unexpected canonical path" ); nsFileSpecHelpers::NativeToUnix(mPath); #endif } diff --git a/xpcom/obsolete/nsFileSpecWin.cpp b/xpcom/obsolete/nsFileSpecWin.cpp index 7d9fe50a3b5..7d7e863deb9 100644 --- a/xpcom/obsolete/nsFileSpecWin.cpp +++ b/xpcom/obsolete/nsFileSpecWin.cpp @@ -153,6 +153,9 @@ void nsFileSpecHelpers::NativeToUnix(nsSimpleCharString& ioPath) if (strstr(cp, ":\\") == cp) *cp = '|'; // absolute path else + if (cp[0] == '\\') // unc path + cp--; + else temp[0] = '\0'; // relative path // Convert '\' to '/'