-rw-r--r-- | noncore/settings/aqpkg/utils.cpp | 22 | ||||
-rw-r--r-- | noncore/settings/aqpkg/utils.h | 1 |
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 @@ -16,4 +16,8 @@ ***************************************************************************/ +#include <stdio.h> +#include <sys/vfs.h> +//#include <mntent.h> + #include "utils.h" #include "global.h" @@ -73,2 +77,20 @@ QString Utils :: getPackageVersionFromIpkFilename( const QString &file ) } + +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 @@ -34,4 +34,5 @@ public: static QString getPackageNameFromIpkFilename( const QString &file ); static QString getPackageVersionFromIpkFilename( const QString &file ); + static bool getStorageSpace( const char *path, long *blockSize, long *totalBlocks, long *availBlocks ); }; |