summaryrefslogtreecommitdiff
authorandyq <andyq>2002-12-04 23:15:20 (UTC)
committer andyq <andyq>2002-12-04 23:15:20 (UTC)
commit35d40e65116cee8b430cdc586db187f81488aa1d (patch) (side-by-side diff)
tree7cc95fa6b0525f178734de42760b36e4208d00be
parent128343cd009009e42ce6bcdfd45a294c7ea44f83 (diff)
downloadopie-35d40e65116cee8b430cdc586db187f81488aa1d.zip
opie-35d40e65116cee8b430cdc586db187f81488aa1d.tar.gz
opie-35d40e65116cee8b430cdc586db187f81488aa1d.tar.bz2
Added new method to get available space on a volume
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/settings/aqpkg/utils.cpp22
-rw-r--r--noncore/settings/aqpkg/utils.h1
2 files changed, 23 insertions, 0 deletions
diff --git a/noncore/settings/aqpkg/utils.cpp b/noncore/settings/aqpkg/utils.cpp
index 77d82d4..446ce39 100644
--- a/noncore/settings/aqpkg/utils.cpp
+++ b/noncore/settings/aqpkg/utils.cpp
@@ -1,41 +1,45 @@
/***************************************************************************
utils.cpp - description
-------------------
begin : Sat Sep 7 2002
copyright : (C) 2002 by Andy Qua
email : andy.qua@blueyonder.co.uk
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
+#include <stdio.h>
+#include <sys/vfs.h>
+//#include <mntent.h>
+
#include "utils.h"
#include "global.h"
Utils :: Utils()
{
}
Utils :: ~Utils()
{
}
QString Utils :: getPathfromIpkFilename( const QString &file )
{
int p = file.findRev( "/" );
QString path = "";
if ( p != -1 )
path = file.left( p );
return path;
}
QString Utils :: getFilenameFromIpkFilename( const QString &file )
@@ -51,24 +55,42 @@ QString Utils :: getFilenameFromIpkFilename( const QString &file )
QString Utils :: getPackageNameFromIpkFilename( const QString &file )
{
int p = file.findRev( "/" );
QString name = file;
if ( p != -1 )
name = name.mid( p + 1 );
p = name.find( "_" );
QString packageName = name.mid( 0, p );
return packageName;
}
QString Utils :: getPackageVersionFromIpkFilename( const QString &file )
{
int p = file.findRev( "/" );
QString name = file;
if ( p != -1 )
name = name.mid( p + 1 );
p = name.find( "_" ) + 1;
int p2 = name.find( "_", p );
QString version = name.mid( p, p2 - p );
return version;
}
+
+bool Utils :: getStorageSpace( const char *path, long *blockSize, long *totalBlocks, long *availBlocks )
+{
+ bool ret = false;
+
+// qDebug( "Reading from path %s", path );
+ struct statfs fs;
+ if ( !statfs( path, &fs ) )
+ {
+ *blockSize = fs.f_bsize;
+ *totalBlocks = fs.f_blocks;
+ *availBlocks = fs.f_bavail;
+ ret = true;
+ }
+
+ return ret;
+}
+
diff --git a/noncore/settings/aqpkg/utils.h b/noncore/settings/aqpkg/utils.h
index 15ee4e6..c572f7b 100644
--- a/noncore/settings/aqpkg/utils.h
+++ b/noncore/settings/aqpkg/utils.h
@@ -12,27 +12,28 @@
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef UTILS_H
#define UTILS_H
#include <qstring.h>
/**
*@author Andy Qua
*/
class Utils {
public:
Utils();
~Utils();
static QString getPathfromIpkFilename( const QString &file );
static QString getFilenameFromIpkFilename( const QString &file );
static QString getPackageNameFromIpkFilename( const QString &file );
static QString getPackageVersionFromIpkFilename( const QString &file );
+ static bool getStorageSpace( const char *path, long *blockSize, long *totalBlocks, long *availBlocks );
};
#endif