]> git.tdb.fi Git - libs/core.git/blobdiff - source/fs/path.cpp
Add move semantics to Variant
[libs/core.git] / source / fs / path.cpp
index adf376f7a0b0db57341370a7bd07d61b643a7c04..1181b923c1054f894c5f0e188119e067c6508566 100644 (file)
@@ -17,9 +17,6 @@ inline bool is_windows_drive(const string &p)
 namespace Msp {
 namespace FS {
 
-Path::Path()
-{ }
-
 Path::Path(const string &p)
 {
        if(p.empty())
@@ -136,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();
                        }