- Assert assert leading and trailing '/' on pathnames in ctor.
authorMichael Andres <ma@suse.de>
Wed, 12 Sep 2007 15:24:20 +0000 (15:24 +0000)
committerMichael Andres <ma@suse.de>
Wed, 12 Sep 2007 15:24:20 +0000 (15:24 +0000)
- Remove empty dummy operator= causing data loss

zypp/DiskUsage.cc
zypp/DiskUsage.h

index b2a6c9b..61af853 100644 (file)
@@ -29,8 +29,8 @@ namespace zypp
     iterator fst = begin();
     for ( ; fst != end() && !fst->isBelow( ret ); ++fst )
       ; // seek 1st equal or below
-    bool found = false; 
+
+    bool found = false;
     if ( fst != end() ) {
       iterator lst = fst;
       found = true;
@@ -50,7 +50,7 @@ namespace zypp
        {
            dname.insert(dname.begin(), '/');
        }
-           
+
        Entry tmp( dname );
 
        tmp._size = ret._size;
@@ -73,7 +73,7 @@ namespace zypp
            }
        }
     }
-  
+
     return ret;
   }
 
index c1501c9..18fe1a9 100644 (file)
@@ -22,7 +22,7 @@ namespace zypp
   class DiskUsage {
   public:
     /**
-    * @short Holds data about how much space will be needed per directory
+    * @short Holds data about how much space will be needed per directory.
     **/
     struct Entry {
       Entry() : _size(0), _files(0) {};
@@ -30,8 +30,15 @@ namespace zypp
               const unsigned size_r = 0,
               const unsigned files_r = 0)
       : path(path_r), _size(size_r), _files(files_r)
-      {}
-      const std::string path;
+      {
+        // assert leading and trailing '/'
+        if ( ! path.empty() )
+        {
+          if ( *path.begin() != '/' ) path.insert( path.begin(), '/' );
+          if ( *path.rbegin() != '/' ) path.insert( path.end(), '/' );
+        }
+      }
+      std::string path;
       mutable unsigned _size;
       mutable unsigned _files;
       friend std::ostream & operator<<( std::ostream & str, const Entry & obj );
@@ -62,12 +69,6 @@ namespace zypp
       }
 
       /**
-       *
-       **/
-      const Entry & operator=( const Entry & rhs ) const {
-        return rhs;
-      }
-      /**
        * Numerical operation based on size and files values.
        **/
       const Entry & operator+=( const Entry & rhs ) const {