Formatting: uniformize end of lines.

This commit is contained in:
Nicolas Le Cam 2008-12-14 22:03:49 +00:00
parent 3851c0f019
commit 24c978d5d2
2 changed files with 58 additions and 58 deletions

View File

@ -17,8 +17,8 @@
*/ */
#include "FileLister.h" #include "FileLister.h"
#include <sstream> #include <sstream>
#include <vector> #include <vector>
#include <string> #include <string>
#ifdef __GNUC__ #ifdef __GNUC__
@ -28,61 +28,61 @@
#if defined(__BORLANDC__) || defined(_MSC_VER) #if defined(__BORLANDC__) || defined(_MSC_VER)
#include <windows.h> #include <windows.h>
#endif #endif
std::string FileLister::simplifyPath( const char *originalPath ) std::string FileLister::simplifyPath( const char *originalPath )
{ {
std::string subPath = ""; std::string subPath = "";
std::vector<std::string> pathParts; std::vector<std::string> pathParts;
for( ; *originalPath; ++originalPath ) for( ; *originalPath; ++originalPath )
{ {
if( *originalPath == '/' ) if( *originalPath == '/' )
{ {
if( subPath.length() > 0 ) if( subPath.length() > 0 )
{ {
pathParts.push_back( subPath ); pathParts.push_back( subPath );
subPath = ""; subPath = "";
} }
pathParts.push_back( "/" ); pathParts.push_back( "/" );
} }
else else
subPath.append( 1, *originalPath ); subPath.append( 1, *originalPath );
} }
if( subPath.length() > 0 ) if( subPath.length() > 0 )
pathParts.push_back( subPath ); pathParts.push_back( subPath );
for( std::vector<std::string>::size_type i = 0; i < pathParts.size(); ++i ) for( std::vector<std::string>::size_type i = 0; i < pathParts.size(); ++i )
{ {
if( pathParts[i] == ".." && i > 1 ) if( pathParts[i] == ".." && i > 1 )
{ {
pathParts.erase( pathParts.begin() + i ); pathParts.erase( pathParts.begin() + i );
pathParts.erase( pathParts.begin()+i-1 ); pathParts.erase( pathParts.begin()+i-1 );
pathParts.erase( pathParts.begin()+i-2 ); pathParts.erase( pathParts.begin()+i-2 );
i = 0; i = 0;
} }
else if( i > 0 && pathParts[i] == "." ) else if( i > 0 && pathParts[i] == "." )
{ {
pathParts.erase( pathParts.begin()+i ); pathParts.erase( pathParts.begin()+i );
i = 0; i = 0;
} }
else if( pathParts[i] == "/" && i > 0 && pathParts[i-1] == "/" ) else if( pathParts[i] == "/" && i > 0 && pathParts[i-1] == "/" )
{ {
pathParts.erase( pathParts.begin()+i-1 ); pathParts.erase( pathParts.begin()+i-1 );
i = 0; i = 0;
} }
} }
std::ostringstream oss; std::ostringstream oss;
for( std::vector<std::string>::size_type i = 0; i < pathParts.size(); ++i ) for( std::vector<std::string>::size_type i = 0; i < pathParts.size(); ++i )
{ {
oss << pathParts[i]; oss << pathParts[i];
} }
return oss.str(); return oss.str();
} }
bool FileLister::AcceptFile( const std::string &filename ) bool FileLister::AcceptFile( const std::string &filename )
{ {

View File

@ -33,7 +33,7 @@
#include <list> #include <list>
#include <algorithm> #include <algorithm>
#include <stdlib.h> // <- strtoul #include <stdlib.h> // <- strtoul
#include <stdio.h> #include <stdio.h>
#include <filelister.h> #include <filelister.h>
#ifdef __BORLANDC__ #ifdef __BORLANDC__