[SCM] Kaboom - Debian KDE 3->4 migration tool branch, master, updated. 0303766c1c0009265e83615f4d7ed7efa5a2308a

Sune Vuorela pusling-guest at alioth.debian.org
Sat Feb 21 14:49:28 UTC 2009


The following commit has been merged in the master branch:
commit d147c0900f5b4e68df484efa93b1c8153c30a2da
Author: Sune Vuorela <sune at vuorela.dk>
Date:   Sat Feb 21 15:48:43 2009 +0100

    add operations to calculate free space and such

diff --git a/diroperations/diroperations.cpp b/diroperations/diroperations.cpp
index 2366027..7c046b8 100644
--- a/diroperations/diroperations.cpp
+++ b/diroperations/diroperations.cpp
@@ -15,6 +15,8 @@
     You should have received a copy of the GNU Lesser General Public License
     along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
+#define _FILE_OFFSET_BITS 64
+#include <sys/statvfs.h> // for statvfs for calculating free space
 #include "diroperations.h"
 #include <QDir>
 #include <QFileInfo>
@@ -22,6 +24,7 @@
 #include <QDebug>
 #include <climits> //for PATH_MAX
 
+
 namespace DirOperations {
 
 QString Exception::what() const
@@ -49,6 +52,33 @@ QString relativeSymLinkTarget(const QString & fileName)
     return QString(buff);
 }
 
+quint64 freeDirSpace(const QString & dir)
+{
+    struct statvfs info;
+    int ret = statvfs(dir.toLocal8Bit(),&info);
+    if(ret < 0) {
+      qDebug() << "statvfs errors" << ret;
+      //error handling
+      return -1;
+    }
+    qDebug() << "freeDirSpace" << dir << info.f_bsize*info.f_bavail;
+    return info.f_bsize*info.f_bavail;
+  
+}
+
+quint64 totalPartitionSize(const QString & dir)
+{
+    struct statvfs info;
+    int ret = statvfs(dir.toLocal8Bit(),&info);
+    if(ret < 0) {
+      qDebug() << "statvfs errors" << ret;
+      //error handling
+      return -1;
+    }
+    qDebug() << "totalPartitionSize" << dir << info.f_bsize*info.f_blocks;
+    return info.f_frsize*info.f_blocks;
+  
+}
 
 qint64 calculateDirSize(const QString & dir, ProgressDialogInterface *pd)
 {
diff --git a/diroperations/diroperations.h b/diroperations/diroperations.h
index 9726523..9ed2e32 100644
--- a/diroperations/diroperations.h
+++ b/diroperations/diroperations.h
@@ -64,6 +64,12 @@ namespace DirOperations {
      */
     QString relativeSymLinkTarget(const QString & fileName);
 
+    /*! Calculates the free space in the partition of a dir */
+    quint64 freeDirSpace(const QString & dir);
+    
+    /*! Calculates the total space of a partition */
+    quint64 totalPartitionSize(const QString & dir);
+
     /*! Calculates the size of a directory. Works like "du -hs". */
     qint64 calculateDirSize(const QString & dir, ProgressDialogInterface *pd = 0);
 

-- 
Kaboom - Debian KDE 3->4 migration tool



More information about the pkg-kde-commits mailing list