diff --git a/stepmania/src/RageFile.cpp b/stepmania/src/RageFile.cpp index da777d1b7e..d34c959ef8 100644 --- a/stepmania/src/RageFile.cpp +++ b/stepmania/src/RageFile.cpp @@ -30,6 +30,22 @@ CString FixSlashes( CString sPath ) return sPath; } +/* + * Keep trailing slashes, since that can be used to illustrate that a path always + * represents a directory. Not sure if we should always keep leading "." (we do + * because it's simpler), but be sure to keep the "." if it's all that's there, so + * collapsing "." doesn't result in "". + * + * foo/bar -> foo/bar + * foo/bar/ -> foo/bar/ + * foo///bar/// -> foo/bar/ + * foo/bar/./baz -> foo/bar/baz + * foo/bar/../baz -> foo/baz + * ./foo -> foo + * ./ -> . + * ./// -> . + */ + void CollapsePath( CString &sPath ) { /* Don't ignore empty: we do want to keep trailing slashes. */ @@ -50,7 +66,7 @@ void CollapsePath( CString &sPath ) as.erase( as.begin()+i ); i -= 1; } - else if( as[i] == "." ) + else if( as[i] == "." && i != 0 ) { as.erase( as.begin()+i ); i -= 1;