X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Ffs%2Fpath.cpp;h=1181b923c1054f894c5f0e188119e067c6508566;hb=dbb2e02721b6250a434a807d92126c7716c40a15;hp=0e86600453be225bcb647ff699f3cb0b5f20649b;hpb=db3397e3b7b9839714ce28d9df2a8f226f2e58b2;p=libs%2Fcore.git diff --git a/source/fs/path.cpp b/source/fs/path.cpp index 0e86600..1181b92 100644 --- a/source/fs/path.cpp +++ b/source/fs/path.cpp @@ -133,11 +133,21 @@ void Path::add_component(const string &comp) path += DIRSEP; path += comp; } - else if(separators.empty()) + else if(start==0) + { + /* Removing the last component of a relative path results in the + current directory */ path = "."; + } + else if(start==1) + { + /* Removing the last component of an absolute path results in the + root directory */ + path.erase(start, string::npos); + } else { - // Otherwise, erase the last component + // Otherwise, erase the last component and its separator path.erase(separators.back(), string::npos); separators.pop_back(); }