Diffstat (limited to 'noncore/settings/aqpkg/utils.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/settings/aqpkg/utils.cpp | 22 |
1 files changed, 22 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 @@ -12,12 +12,16 @@ * 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() { } @@ -69,6 +73,24 @@ QString Utils :: getPackageVersionFromIpkFilename( const QString &file ) 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; +} + |