X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=blobdiff_plain;f=source%2Fpath.cpp;h=e514d36bfe490f5a4349f9a46946847221caa5f5;hp=d8a2c71e830f08052d9b45573546ba241a4c4df9;hb=fa77438b62207466c48620604c8cc34931080936;hpb=50734eecb739210eb177a12c39d0ea93da10936a diff --git a/source/path.cpp b/source/path.cpp index d8a2c71..e514d36 100644 --- a/source/path.cpp +++ b/source/path.cpp @@ -42,7 +42,7 @@ unsigned Path::size() const if(path.size()==1 && path[0]==DIRSEP) return 1; - unsigned count=1; + unsigned count = 1; for(string::const_iterator i=path.begin(); i!=path.end(); ++i) if(*i==DIRSEP) ++count; return count; @@ -62,12 +62,12 @@ bool Path::is_absolute() const Path Path::subpath(unsigned start, unsigned count) const { Path result; - Iterator i=begin(); + Iterator i = begin(); for(unsigned j=0; (jstart) add_component(p.substr(start, slash-start)); if(slash==string::npos) break; - start=slash+1; + start = slash+1; } } @@ -167,21 +167,21 @@ void Path::add_component(const string &comp) { // Replace the path with the root directory #ifdef WIN32 - unsigned slash=path.find(DIRSEP); + unsigned slash = path.find(DIRSEP); if(is_windows_drive(path.substr(0, slash))) - path=path.substr(0, 2); + path = path.substr(0, 2); else #endif - path=comp; + path = comp; } #ifdef WIN32 else if(is_windows_drive(comp)) - path=comp; + path = comp; #endif else if(comp=="..") { if(path.empty() || path==".") - path=comp; + path = comp; // .. in root directory is a no-op else if(path.size()==1 && path[0]==DIRSEP) ; @@ -191,20 +191,20 @@ void Path::add_component(const string &comp) #endif else { - string::size_type slash=path.rfind(DIRSEP); - string::size_type start=(slash==string::npos ? 0 : slash+1); + string::size_type slash = path.rfind(DIRSEP); + string::size_type start = (slash==string::npos ? 0 : slash+1); if(!path.compare(start, string::npos, "..")) { // If the last component already is a .., add another - path+=DIRSEP; - path+=comp; + path += DIRSEP; + path += comp; } else if(slash==string::npos) - path="."; + path = "."; else { if(slash==0) - slash=1; + slash = 1; // Otherwise, erase the last component path.erase(slash, string::npos); } @@ -213,10 +213,10 @@ void Path::add_component(const string &comp) else if(comp!="." || path.empty()) { if(comp!="." && path.empty()) - path="."; + path = "."; if(path.size()>1 || (path.size()==1 && path[0]!=DIRSEP)) - path+=DIRSEP; - path+=comp; + path += DIRSEP; + path += comp; } } @@ -226,25 +226,25 @@ Path::Iterator::Iterator(const Path &p): start(0) { if(path.path.empty()) - start=end=string::npos; + start=end = string::npos; else if(path.path[0]==DIRSEP) - end=1; + end = 1; #ifdef WIN32 else if(path.path.size()>2 && path.path[2]==DIRSEP && is_windows_drive(path.path.substr(0, 2))) - end=2; + end = 2; #endif else - end=path.path.find(DIRSEP); + end = path.path.find(DIRSEP); } Path::Iterator &Path::Iterator::operator++() { - start=end; + start = end; if(start>=path.path.size()) return *this; if(path.path[start]==DIRSEP) ++start; - end=path.path.find(DIRSEP, start); + end = path.path.find(DIRSEP, start); return *this; } @@ -253,13 +253,13 @@ Path::Iterator &Path::Iterator::operator--() if(start==0) return *this; - end=start; + end = start; if(end>1 && end