Make dirname behave sensibly for single-component paths
authorMikko Rasa <tdb@tdb.fi>
Fri, 12 Sep 2008 19:11:08 +0000 (19:11 +0000)
committerMikko Rasa <tdb@tdb.fi>
Fri, 12 Sep 2008 19:11:08 +0000 (19:11 +0000)
source/utils.cpp

index 2f7e4d704f35b1ee9cebe5dc150c654c5d15ef70..abe0d2563125d9288dbdb2cdc5c6ee6b291e856f 100644 (file)
@@ -30,6 +30,12 @@ string basename(const Path &p)
 
 Path dirname(const Path &p)
 {
+       if(p.size()==1)
+       {
+               if(p.is_absolute())
+                       return p;
+               return ".";
+       }
        return p.subpath(0, p.size()-1);
 }