DiskUsageCounter.h

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------\
00002 |                          ____ _   __ __ ___                          |
00003 |                         |__  / \ / / . \ . \                         |
00004 |                           / / \ V /|  _/  _/                         |
00005 |                          / /__ | | | | | |                           |
00006 |                         /_____||_| |_| |_|                           |
00007 |                                                                      |
00008 \---------------------------------------------------------------------*/
00012 #ifndef ZYPP_DISKUSAGE_COUNTER_H
00013 #define ZYPP_DISKUSAGE_COUNTER_H
00014 
00015 #include <zypp/ResPool.h>
00016 
00017 #include <set>
00018 #include <string>
00019 #include <iostream>
00020 
00022 namespace zypp
00023 { 
00024 
00025   class DiskUsageCounter
00026   {
00027 
00028   public:
00029 
00033     struct MountPoint
00034     {
00038       std::string dir;
00039 
00043       long long block_size;       
00044 
00048       long long total_size;
00049 
00053       long long used_size;
00054 
00058       mutable long long pkg_size;
00059 
00060       bool readonly;
00061 
00065       MountPoint(std::string d = "/", long long bs = 0LL, long long total = 0LL, long long used = 0LL, long long pkg = 0LL, bool ro=false) :
00066         dir(d), block_size(bs), total_size(total), used_size(used), pkg_size(pkg), readonly(ro) {}
00067 
00068       // sort by directory name
00069       bool operator<( const MountPoint & rhs ) const
00070       {
00071         return dir < rhs.dir;
00072       }
00073     };
00074 
00075     typedef std::set<MountPoint> MountPointSet;
00076 
00077     DiskUsageCounter() {}
00078 
00079     bool setMountPoints(const MountPointSet &m)
00080     {
00081         mps = m;
00082         return true;
00083     }
00084 
00085     MountPointSet getMountPoints()
00086     {
00087         return mps;
00088     }
00089 
00090     static MountPointSet detectMountPoints(const std::string &rootdir = "/");
00091 
00095     MountPointSet disk_usage(const ResPool &pool);
00096 
00097   private:
00098 
00099     MountPointSet mps;
00100   };
00103 } // namespace zypp
00105 #endif // ZYPP_DISKUSAGE_COUNTER_H

Generated on Thu Jul 6 00:07:21 2006 for zypp by  doxygen 1.4.6