]> git.tdb.fi Git - libs/core.git/commitdiff
Fix basename and dirname on an empty Path
authorMikko Rasa <tdb@tdb.fi>
Sat, 2 Dec 2017 15:04:00 +0000 (17:04 +0200)
committerMikko Rasa <tdb@tdb.fi>
Sat, 2 Dec 2017 15:04:00 +0000 (17:04 +0200)
source/fs/utils.cpp

index 1d663b77183cc2c4abcbbc68c9e7a44a75109429..a2fe40be72ee6f39eef6909e576c5703fe9787da 100644 (file)
@@ -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())