continue phasing out SLASH

This commit is contained in:
Glenn Maynard
2003-12-10 09:47:36 +00:00
parent 688a36eb16
commit f76a664437
2 changed files with 15 additions and 15 deletions
+5 -5
View File
@@ -889,20 +889,20 @@ CString Basename( const CString &dir )
CString Dirname( const CString &dir )
{
/* Special case: "/" -> "/". */
if( dir.size() == 1 && dir[0] == SLASH[0] )
return SLASH;
if( dir.size() == 1 && dir[0] == '/' )
return "/";
int pos = dir.size()-1;
/* Skip trailing slashes. */
while( pos >= 0 && dir[pos] == SLASH[0] )
while( pos >= 0 && dir[pos] == '/' )
--pos;
/* Skip the last component. */
while( pos >= 0 && dir[pos] != SLASH[0] )
while( pos >= 0 && dir[pos] != '/' )
--pos;
if( pos < 0 )
return "." SLASH;
return "./";
return dir.substr(0, pos+1);
}