fix problems accessing local folders with unc path local dirs, r=bienvenu, sr=mscott, patch by slavek.banko@axis.cz 133153

git-svn-id: svn://10.0.0.236/trunk@162606 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
bienvenu%nventure.com 2004-09-21 17:56:44 +00:00
parent 389ea5bfe3
commit 8bd2ecd258
2 changed files with 16 additions and 2 deletions

View File

@ -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
}

View File

@ -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 '/'