fix up path handling

This commit is contained in:
Glenn Maynard
2003-12-11 07:24:32 +00:00
parent 65248e01d7
commit a7190307f3
2 changed files with 26 additions and 15 deletions
+8 -1
View File
@@ -32,8 +32,9 @@ CString FixSlashes( CString sPath )
void CollapsePath( CString &sPath )
{
/* Don't ignore empty: we do want to keep trailing slashes. */
CStringArray as;
split( sPath, "/", as, true );
split( sPath, "/", as, false );
for( unsigned i=0; i<as.size(); i++ )
{
@@ -43,6 +44,12 @@ void CollapsePath( CString &sPath )
as.erase( as.begin()+i-1 );
i -= 2;
}
else if( as[i] == "" && i+1 < as.size() )
{
/* Remove empty parts that aren't at the end; "foo//bar/" -> "foo/bar/". */
as.erase( as.begin()+i );
i -= 1;
}
else if( as[i] == "." )
{
as.erase( as.begin()+i );