From: Mikko Rasa Date: Sat, 2 Dec 2017 15:04:00 +0000 (+0200) Subject: Fix basename and dirname on an empty Path X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=e93a28713fe3a50eff4f7e5c07d191e895135748;p=libs%2Fcore.git Fix basename and dirname on an empty Path --- diff --git a/source/fs/utils.cpp b/source/fs/utils.cpp index 1d663b7..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())