summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/aqpkg/utils.cpp24
-rw-r--r--noncore/settings/aqpkg/utils.h1
2 files changed, 24 insertions, 1 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
@@ -14,8 +14,12 @@
* (at your option) any later version. *
* *
***************************************************************************/
+#include <stdio.h>
+#include <sys/vfs.h>
+//#include <mntent.h>
+
#include "utils.h"
#include "global.h"
Utils :: Utils()
@@ -53,9 +57,9 @@ QString Utils :: getPackageNameFromIpkFilename( const QString &file )
{
int p = file.findRev( "/" );
QString name = file;
if ( p != -1 )
- name = name.mid( p + 1 );
+ name = name.mid( p + 1 );
p = name.find( "_" );
QString packageName = name.mid( 0, p );
return packageName;
}
@@ -71,4 +75,22 @@ QString Utils :: getPackageVersionFromIpkFilename( const QString &file )
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
@@ -32,7 +32,8 @@ public:
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