diff --git a/FileLister.cpp b/FileLister.cpp index cc939e5fd..06d290e6b 100644 --- a/FileLister.cpp +++ b/FileLister.cpp @@ -17,8 +17,8 @@ */ #include "FileLister.h" -#include -#include +#include +#include #include #ifdef __GNUC__ @@ -28,61 +28,61 @@ #if defined(__BORLANDC__) || defined(_MSC_VER) #include #endif - -std::string FileLister::simplifyPath( const char *originalPath ) -{ - std::string subPath = ""; - std::vector pathParts; - for( ; *originalPath; ++originalPath ) - { - if( *originalPath == '/' ) - { - if( subPath.length() > 0 ) - { - pathParts.push_back( subPath ); - subPath = ""; - } - - pathParts.push_back( "/" ); - } - else - subPath.append( 1, *originalPath ); - } - - if( subPath.length() > 0 ) - pathParts.push_back( subPath ); - - for( std::vector::size_type i = 0; i < pathParts.size(); ++i ) - { - if( pathParts[i] == ".." && i > 1 ) - { - pathParts.erase( pathParts.begin() + i ); - pathParts.erase( pathParts.begin()+i-1 ); - pathParts.erase( pathParts.begin()+i-2 ); - i = 0; - } - else if( i > 0 && pathParts[i] == "." ) - { - pathParts.erase( pathParts.begin()+i ); - i = 0; - } - else if( pathParts[i] == "/" && i > 0 && pathParts[i-1] == "/" ) - { - pathParts.erase( pathParts.begin()+i-1 ); - i = 0; - } - } - - std::ostringstream oss; - for( std::vector::size_type i = 0; i < pathParts.size(); ++i ) - { - oss << pathParts[i]; - } - - return oss.str(); -} - - + +std::string FileLister::simplifyPath( const char *originalPath ) +{ + std::string subPath = ""; + std::vector pathParts; + for( ; *originalPath; ++originalPath ) + { + if( *originalPath == '/' ) + { + if( subPath.length() > 0 ) + { + pathParts.push_back( subPath ); + subPath = ""; + } + + pathParts.push_back( "/" ); + } + else + subPath.append( 1, *originalPath ); + } + + if( subPath.length() > 0 ) + pathParts.push_back( subPath ); + + for( std::vector::size_type i = 0; i < pathParts.size(); ++i ) + { + if( pathParts[i] == ".." && i > 1 ) + { + pathParts.erase( pathParts.begin() + i ); + pathParts.erase( pathParts.begin()+i-1 ); + pathParts.erase( pathParts.begin()+i-2 ); + i = 0; + } + else if( i > 0 && pathParts[i] == "." ) + { + pathParts.erase( pathParts.begin()+i ); + i = 0; + } + else if( pathParts[i] == "/" && i > 0 && pathParts[i-1] == "/" ) + { + pathParts.erase( pathParts.begin()+i-1 ); + i = 0; + } + } + + std::ostringstream oss; + for( std::vector::size_type i = 0; i < pathParts.size(); ++i ) + { + oss << pathParts[i]; + } + + return oss.str(); +} + + bool FileLister::AcceptFile( const std::string &filename ) { diff --git a/tokenize.cpp b/tokenize.cpp index b1a5a5d1d..23b97a9a9 100644 --- a/tokenize.cpp +++ b/tokenize.cpp @@ -33,7 +33,7 @@ #include #include #include // <- strtoul -#include +#include #include #ifdef __BORLANDC__