author | andyq <andyq> | 2002-12-04 23:15:20 (UTC) |
---|---|---|
committer | andyq <andyq> | 2002-12-04 23:15:20 (UTC) |
commit | 35d40e65116cee8b430cdc586db187f81488aa1d (patch) (side-by-side diff) | |
tree | 7cc95fa6b0525f178734de42760b36e4208d00be /noncore/settings/aqpkg | |
parent | 128343cd009009e42ce6bcdfd45a294c7ea44f83 (diff) | |
download | opie-35d40e65116cee8b430cdc586db187f81488aa1d.zip opie-35d40e65116cee8b430cdc586db187f81488aa1d.tar.gz opie-35d40e65116cee8b430cdc586db187f81488aa1d.tar.bz2 |
Added new method to get available space on a volume
-rw-r--r-- | noncore/settings/aqpkg/utils.cpp | 24 | ||||
-rw-r--r-- | noncore/settings/aqpkg/utils.h | 1 |
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 @@ -17,2 +17,6 @@ +#include <stdio.h> +#include <sys/vfs.h> +//#include <mntent.h> + #include "utils.h" @@ -56,3 +60,3 @@ QString Utils :: getPackageNameFromIpkFilename( const QString &file ) if ( p != -1 ) - name = name.mid( p + 1 ); + name = name.mid( p + 1 ); p = name.find( "_" ); @@ -74 +78,19 @@ 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 @@ -35,2 +35,3 @@ public: static QString getPackageVersionFromIpkFilename( const QString &file ); + static bool getStorageSpace( const char *path, long *blockSize, long *totalBlocks, long *availBlocks ); }; |