Remove obsolete DiskUsage class
authorMichael Andres <ma@suse.de>
Fri, 13 Dec 2013 18:25:52 +0000 (19:25 +0100)
committerMichael Andres <ma@suse.de>
Fri, 13 Dec 2013 18:30:40 +0000 (19:30 +0100)
zypp/CMakeLists.txt
zypp/DiskUsage.cc [deleted file]
zypp/DiskUsage.h [deleted file]
zypp/ResObject.cc
zypp/ResObject.h
zypp/target/rpm/RpmHeader.cc
zypp/target/rpm/RpmHeader.h

index 671af88..a52ea30 100644 (file)
@@ -17,7 +17,6 @@ SET( zypp_SRCS
   Date.cc
   Dep.cc
   Digest.cc
-  DiskUsage.cc
   DiskUsageCounter.cc
   DownloadMode.cc
   Edition.cc
@@ -105,7 +104,6 @@ SET( zypp_HEADERS
   Dep.h
   Digest.h
   DiskUsageCounter.h
-  DiskUsage.h
   DownloadMode.h
   Edition.h
   ExternalProgram.h
diff --git a/zypp/DiskUsage.cc b/zypp/DiskUsage.cc
deleted file mode 100644 (file)
index 61af853..0000000
+++ /dev/null
@@ -1,91 +0,0 @@
-/*---------------------------------------------------------------------\
-|                          ____ _   __ __ ___                          |
-|                         |__  / \ / / . \ . \                         |
-|                           / / \ V /|  _/  _/                         |
-|                          / /__ | | | | | |                           |
-|                         /_____||_| |_| |_|                           |
-|                                                                      |
-\---------------------------------------------------------------------*/
-/** \file      zypp/DiskUsage.cc
- *
-*/
-#include "zypp/DiskUsage.h"
-#include <iostream>
-
-using namespace std;
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
-  std::ostream & operator<<( std::ostream & str, const DiskUsage::Entry & obj )
-  {
-    return str << obj.path << '\t' << obj._size << "; files " << obj._files;
-  }
-
-  DiskUsage::Entry DiskUsage::extract( const std::string & dirname_r )
-  {
-    Entry ret( dirname_r );
-
-    iterator fst = begin();
-    for ( ; fst != end() && !fst->isBelow( ret ); ++fst )
-      ; // seek 1st equal or below
-
-    bool found = false;
-    if ( fst != end() ) {
-      iterator lst = fst;
-      found = true;
-      // return the first found, the value is sum of all subdirectories below
-      ret += *lst;
-      for ( ; lst != end() && lst->isBelow( ret ); ++lst ) {
-      }
-      // remove
-      _dirs.erase( fst, lst );
-    }
-
-    // the dir entry has been found, update all parent entries
-    if (found)
-    {
-       std::string dname = dirname_r;
-       if (dname.size() > 1 && dname[0] != '/')
-       {
-           dname.insert(dname.begin(), '/');
-       }
-
-       Entry tmp( dname );
-
-       tmp._size = ret._size;
-       tmp._files = ret._files;
-       // subtract du from directories above
-       iterator fst = begin();
-       for ( ; fst != end(); ++fst )
-       {
-           // add slash if it's missing
-           std::string dd = fst->path;
-           if (dd.size() > 1 && dd[0] != '/')
-           {
-               dd.insert(dd.begin(), '/');
-           }
-
-           // update the entry
-           if (tmp.isBelow(dd))
-           {
-               *fst -= tmp;
-           }
-       }
-    }
-
-    return ret;
-  }
-
-  std::ostream & operator<<( std::ostream & str, const DiskUsage & obj )
-  {
-    str << "Package Disk Usage {" << endl;
-    for ( DiskUsage::EntrySet::const_iterator it = obj._dirs.begin(); it != obj._dirs.end(); ++it ) {
-      str << "   " << *it << endl;
-    }
-    return str << "}";
-  }
-
-
-} // namespace zypp
-///////////////////////////////////////////////////////////////////
diff --git a/zypp/DiskUsage.h b/zypp/DiskUsage.h
deleted file mode 100644 (file)
index 18fe1a9..0000000
+++ /dev/null
@@ -1,178 +0,0 @@
-/*---------------------------------------------------------------------\
-|                          ____ _   __ __ ___                          |
-|                         |__  / \ / / . \ . \                         |
-|                           / / \ V /|  _/  _/                         |
-|                          / /__ | | | | | |                           |
-|                         /_____||_| |_| |_|                           |
-|                                                                      |
-\---------------------------------------------------------------------*/
-/** \file      zypp/DiskUsage.h
- *
-*/
-#ifndef ZYPP_DISKUSAGE_H
-#define ZYPP_DISKUSAGE_H
-
-#include <set>
-#include <string>
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
-
-  class DiskUsage {
-  public:
-    /**
-    * @short Holds data about how much space will be needed per directory.
-    **/
-    struct Entry {
-      Entry() : _size(0), _files(0) {};
-      Entry(const std::string& path_r,
-              const unsigned size_r = 0,
-              const unsigned files_r = 0)
-      : path(path_r), _size(size_r), _files(files_r)
-      {
-        // 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 );
-      /**
-       * Test for equality based on directory name.
-       **/
-      bool operator==( const Entry & rhs ) const {
-        return  path == rhs.path;
-      }
-      /**
-       * Order based on directory name.
-       **/
-      bool operator<( const Entry & rhs ) const {
-        return  path < rhs.path;
-      }
-      /**
-       * Return true if this entry denotes a directory equal to or below rhs._dirname.
-       **/
-      bool isBelow( const Entry & rhs ) const {
-        // whether _dirname has prefix rhs._dirname
-        return( path.compare( 0, rhs.path.size(), rhs.path ) == 0 );
-      }
-      /**
-       * Return true if this entry denotes a directory equal to or below dirname_r.
-       **/
-      bool isBelow( const std::string & dirname_r ) const {
-        return  isBelow( Entry( dirname_r ) );
-      }
-
-      /**
-       * Numerical operation based on size and files values.
-       **/
-      const Entry & operator+=( const Entry & rhs ) const {
-        _size  += rhs._size;
-        _files += rhs._files;
-        return *this;
-      }
-      /**
-       * Numerical operation based on size and files values.
-       **/
-      const Entry & operator-=( const Entry & rhs ) const {
-        _size  -= rhs._size;
-        _files -= rhs._files;
-        return *this;
-      }
-    };
-  private:
-    typedef std::set<Entry> EntrySet;
-    EntrySet _dirs;
-  public:
-
-    DiskUsage() {};
-   /**
-     * Add an entry. If already present, sum up the new entries size and files value.
-     **/
-    void add( const Entry & newent_r ) {
-      std::pair<EntrySet::iterator,bool> res = _dirs.insert( newent_r );
-      if ( !res.second ) {
-        *res.first += newent_r;
-      }
-    }
-   /**
-     * Add an entry. If already present, sum up the new entries size and files value.
-     **/
-    void add( const std::string & dirname_r, const unsigned & size_r = 0, const unsigned & files_r = 0 ) {
-      add( Entry( dirname_r, size_r, files_r ) );
-    }
-    /**
-     * Whether there is no entry available.
-     */
-    bool empty() const { return _dirs.empty(); }
-    /**
-     * Number of entries
-     **/
-    unsigned size() const { return _dirs.size(); }
-    /**
-     * Clear EntrySet
-     **/
-    void clear() { _dirs.clear(); }
-    /**
-     * Sum up any entries for dirname_r and its descendants and remove them
-     * on the fly. Return the result.
-     **/
-    Entry extract( const std::string & dirname_r );
-
-  public:
-
-    typedef EntrySet::iterator               iterator;
-    typedef EntrySet::reverse_iterator       reverse_iterator;
-
-    /**
-     * Forward iterator pointing to the first entry (if any)
-     **/
-    iterator begin() { return _dirs.begin(); }
-    /**
-     * Forward iterator pointing behind the last entry.
-     **/
-    iterator end() { return _dirs.end(); }
-    /**
-     * Reverse iterator pointing to the last entry (if any)
-     **/
-    reverse_iterator rbegin() { return _dirs.rbegin(); }
-    /**
-     * Reverse iterator pointing before the first entry.
-     **/
-    reverse_iterator rend() { return _dirs.rend(); }
-
-    typedef EntrySet::const_iterator         const_iterator;
-    typedef EntrySet::const_reverse_iterator const_reverse_iterator;
-
-    /**
-     * Forward const iterator pointing to the first entry (if any)
-     **/
-    const_iterator begin() const { return _dirs.begin(); }
-    /**
-     * Forward const iterator pointing behind the last entry.
-     **/
-    const_iterator end() const { return _dirs.end(); }
-    /**
-     * Reverse const iterator pointing to the last entry (if any)
-     **/
-    const_reverse_iterator rbegin() const { return _dirs.rbegin(); }
-    /**
-     * Reverse const iterator pointing before the first entry.
-     **/
-    const_reverse_iterator rend()const { return _dirs.rend(); }
-
-  public:
-
-    friend std::ostream & operator<<( std::ostream & str, const DiskUsage & obj );
-
-  };
-  ///////////////////////////////////////////////////////////////////
-  /////////////////////////////////////////////////////////////////
-} // namespace zypp
-///////////////////////////////////////////////////////////////////
-#endif // ZYPP_DISKUSAGE_H
index 958c671..c82561e 100644 (file)
@@ -103,13 +103,6 @@ namespace zypp
   Date ResObject::installtime() const
   { return Date( lookupNumAttribute( sat::SolvAttr::installtime ) ); }
 
-#warning DUMMY diskusage
-  const DiskUsage & ResObject::diskusage() const
-  {
-    static DiskUsage _du;
-    return _du;
-  }
-
    /////////////////////////////////////////////////////////////////
 } // namespace zypp
 ///////////////////////////////////////////////////////////////////
index 8ffd39f..71c0cec 100644 (file)
@@ -19,7 +19,6 @@
 #include "zypp/Locale.h"
 #include "zypp/Vendor.h"
 #include "zypp/ByteCount.h"
-#include "zypp/DiskUsage.h"
 #include "zypp/OnMediaLocation.h"
 #include "zypp/Repository.h"
 
@@ -192,14 +191,6 @@ namespace zypp
      */
     Date installtime() const;
 
-    /**
-     * \short Disk usage per directory
-     * A common attribute, although mostly packages require
-     * noticeable disk space. An e.g product could try to reserve
-     * a certain ammount of diskspace by providing DiskUsage data.
-     */
-    const DiskUsage & diskusage() const;
-
   protected:
     friend ResObject::Ptr makeResObject( const sat::Solvable & solvable_r );
     /** Ctor */
index 3eefab1..45e4b90 100644 (file)
@@ -960,108 +960,6 @@ Changelog RpmHeader::tag_changelog() const
   return ret;
 }
 
-///////////////////////////////////////////////////////////////////
-//
-//
-//        METHOD NAME : RpmHeader::tag_du
-//        METHOD TYPE : PkgDu &
-//
-//        DESCRIPTION :
-//
-DiskUsage & RpmHeader::tag_du( DiskUsage & dudata_r ) const
-{
-  dudata_r.clear();
-  stringList basenames;
-  if ( string_list( RPMTAG_BASENAMES, basenames ) )
-  {
-    stringList dirnames;
-    string_list( RPMTAG_DIRNAMES, dirnames );
-    intList dirindexes;
-    int_list( RPMTAG_DIRINDEXES, dirindexes );
-
-    intList filedevices;
-    int_list( RPMTAG_FILEDEVICES, filedevices );
-    intList fileinodes;
-    int_list( RPMTAG_FILEINODES, fileinodes );
-    intList filesizes;
-    int_list( RPMTAG_FILESIZES, filesizes );
-    intList filemodes;
-    int_list( RPMTAG_FILEMODES, filemodes );
-
-    ///////////////////////////////////////////////////////////////////
-    // Create and collect Entries by index. devino_cache is used to
-    // filter out hardliks ( different name but same device and inode ).
-    ///////////////////////////////////////////////////////////////////
-    filesystem::DevInoCache trace;
-    std::vector<DiskUsage::Entry> entries;
-    entries.resize( dirnames.size() );
-    for ( unsigned i = 0; i < dirnames.size(); ++i )
-    {
-      entries[i] = DiskUsage::Entry( dirnames[i] );
-
-      // cut off deeper directory levels in DiskUsage::Entry
-      unsigned level             = 3; // number of '/' incl. a trailing one
-      std::string::size_type pos = 0; // we know rpm stores absolute pathnames
-      while ( --level && pos != std::string::npos )
-      {
-        pos = entries[i].path.find( "/", pos+1 );
-      }
-      if ( pos != std::string::npos )
-      {
-        entries[i].path.erase( pos+1 );
-      }
-    }
-
-    for ( unsigned i = 0; i < basenames.size(); ++ i )
-    {
-      filesystem::StatMode mode( filemodes[i] );
-      if ( mode.isFile() )
-      {
-        if ( trace.insert( filedevices[i], fileinodes[i] ) )
-        {
-          // Count full 1K blocks
-          entries[dirindexes[i]]._size += ByteCount( filesizes[i] ).blocks( ByteCount::K );
-          ++(entries[dirindexes[i]]._files);
-        }
-        // else: hardlink; already counted this device/inode
-      }
-    }
-
-    ///////////////////////////////////////////////////////////////////
-    // Collect all enties. We first unify the duplicate entries that
-    // were created by cutting off deeper levels. Then the size of each
-    // directory must also be added to each of it's parent directories.
-    ///////////////////////////////////////////////////////////////////
-    DiskUsage tmpdata;
-    for ( unsigned i = 0; i < entries.size(); ++i )
-    {
-      if ( entries[i]._size )
-        tmpdata.add( entries[i] );
-    }
-
-    for_( it, tmpdata.begin(), tmpdata.end() )
-    {
-      DiskUsage::Entry ent( *it );
-
-      do {
-        dudata_r.add( ent );
-        if ( ent.path.size() <= 1 ) // "" or "/"
-          break;
-
-        // set path to parent dir. Note that DiskUsage::Entry
-        // has leading and trailing '/' on pathnmes.
-        std::string::size_type rstart = ent.path.size() - 2;           // trailing '/' !
-        std::string::size_type lpos   = ent.path.rfind( '/', rstart ); // one but last '/'
-        if ( lpos == std::string::npos )
-          break;
-
-        ent.path.erase( lpos + 1 );
-      } while( true );
-    }
-  }
-  return dudata_r;
-}
-
 } // namespace rpm
 } // namespace target
 } // namespace zypp
index 8354326..02dd8d1 100644 (file)
@@ -20,7 +20,6 @@
 #include "zypp/Package.h"
 #include "zypp/Changelog.h"
 #include "zypp/Pathname.h"
-#include "zypp/DiskUsage.h"
 
 
 namespace zypp
@@ -162,11 +161,6 @@ public:
 
   Changelog tag_changelog() const;
 
-  /**
-   * Returns reference to arg <code>dudata_r</code>.
-   **/
-  DiskUsage & tag_du( DiskUsage & dudata_r ) const;
-
 public:
 
   virtual std::ostream & dumpOn( std::ostream & str ) const;