make sure that /path/to/dir and /path/to/dir/ are treated as equal

This commit is contained in:
shaver%netscape.com 1999-08-29 22:05:11 +00:00
Родитель b0466c1290
Коммит 073e97ad3b
1 изменённых файлов: 24 добавлений и 7 удалений

Просмотреть файл

@ -971,14 +971,31 @@ PRBool nsFileSpec::operator == (const nsFileSpec& inOther) const
return heEmpty;
if (heEmpty) // ('cuz I'm not...)
return PR_FALSE;
#if defined(XP_PC)
// windows does not care about case.
if (_stricmp(mPath, inOther.mPath ) == 0)
nsSimpleCharString str = mPath;
nsSimpleCharString inStr = inOther.mPath;
// Length() is size of buffer, not length of string
PRUint32 strLast = str.Length() - 1, inLast = inStr.Length() - 1;
#if defined(XP_PC)
#define DIR_SEPARATOR '\\' // XXX doesn't NSPR have this?
/* windows does not care about case. */
#define DIR_STRCMP _stricmp
#else
#define DIR_SEPARATOR '/'
#define DIR_STRCMP strcmp
#endif
if(str[strLast] == DIR_SEPARATOR)
str[strLast] = '\0';
if(inStr[inLast] == DIR_SEPARATOR)
inStr[inLast] = '\0';
if (DIR_STRCMP(str, inStr ) == 0)
return PR_TRUE;
#else
if (strcmp(mPath, inOther.mPath ) == 0)
return PR_TRUE;
#endif
#undef DIR_SEPARATOR
#undef DIR_STRCMP
#endif
return PR_FALSE;
}