X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=blobdiff_plain;f=source%2Ffs%2Futils.cpp;h=a2fe40be72ee6f39eef6909e576c5703fe9787da;hp=ed1ca0ab27c3e3c14070b88822e50cc742ca067c;hb=e93a28713fe3a50eff4f7e5c07d191e895135748;hpb=c4bebb877ec98d518bf02152ca81930e18eda6a7 diff --git a/source/fs/utils.cpp b/source/fs/utils.cpp index ed1ca0a..a2fe40b 100644 --- a/source/fs/utils.cpp +++ b/source/fs/utils.cpp @@ -9,11 +9,13 @@ namespace FS { string basename(const Path &p) { - return p[-1]; + return p.empty() ? string() : p[-1]; } Path dirname(const Path &p) { + if(p.empty()) + return p; if(p.size()==1) { if(p.is_absolute()) @@ -43,7 +45,7 @@ Path fix_case(const Path &path) Path result; for(Path::Iterator i=path.begin(); i!=path.end(); ++i) { - if(!found || *i=="/") + if(!found || (result.empty() && (*i=="/" || *i=="."))) result /= *i; else {