BUG: FileIsDirectory would remove the trailing '/' even when the path is indeed the root i.e. '/'. Hence the test would be incorrect for root directory. Fixed that.

This commit is contained in:
Utkarsh Ayachit 2006-12-18 11:30:09 -05:00
parent b95f198348
commit fa69ba942e
1 changed files with 2 additions and 1 deletions

View File

@ -2293,7 +2293,8 @@ bool SystemTools::FileIsDirectory(const char* name)
// Remove any trailing slash from the name.
char buffer[KWSYS_SYSTEMTOOLS_MAXPATH];
int last = static_cast<int>(strlen(name))-1;
if(last >= 0 && (name[last] == '/' || name[last] == '\\'))
if(last > 0 && (name[last] == '/' || name[last] == '\\')
&& strcmp(name, "/") !=0)
{
memcpy(buffer, name, last);
buffer[last] = 0;