X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=blobdiff_plain;f=source%2Fpath.cpp;h=4f3a0b1547c3ea94018feac0c4bbd3bbbbfe77eb;hp=6127f7a84c06955dc4963589a8406515d3bd4207;hb=174debf33b2001b3244c007825d0a5539566bd8c;hpb=bfbb7edfb2ae76d23f26e0b22787617ff621747d diff --git a/source/path.cpp b/source/path.cpp index 6127f7a..4f3a0b1 100644 --- a/source/path.cpp +++ b/source/path.cpp @@ -3,7 +3,7 @@ This file is part of libmsppath Copyright © 2006 Mikko Rasa, Mikkosoft Productions Distributed under the LGPL */ -#include +#include #include "path.h" #include "utils.h" @@ -155,7 +155,7 @@ void Path::add_component(const string &comp) { unsigned slash=path.rfind(DIRCHAR); unsigned start=(slash==string::npos)?0:slash+1; - if(path.compare(start, string::npos, "..")) + if(!path.compare(start, string::npos, "..")) { // If the last component already is a .., add another path+=DIRCHAR; @@ -166,8 +166,10 @@ void Path::add_component(const string &comp) path.erase(slash, string::npos); } } - else if(comp!=".") + else if(comp!="." || path.empty()) { + if(path==".") + path=""; if(path.size()>1 || (path.size()==1 && path[0]!=DIRCHAR)) path+=DIRCHAR; path+=comp;