author | andyq <andyq> | 2002-12-04 23:15:20 (UTC) |
---|---|---|
committer | andyq <andyq> | 2002-12-04 23:15:20 (UTC) |
commit | 35d40e65116cee8b430cdc586db187f81488aa1d (patch) (unidiff) | |
tree | 7cc95fa6b0525f178734de42760b36e4208d00be | |
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 | 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 | |||
@@ -15,6 +15,10 @@ | |||
15 | * * | 15 | * * |
16 | ***************************************************************************/ | 16 | ***************************************************************************/ |
17 | 17 | ||
18 | #include <stdio.h> | ||
19 | #include <sys/vfs.h> | ||
20 | //#include <mntent.h> | ||
21 | |||
18 | #include "utils.h" | 22 | #include "utils.h" |
19 | #include "global.h" | 23 | #include "global.h" |
20 | 24 | ||
@@ -72,3 +76,21 @@ QString Utils :: getPackageVersionFromIpkFilename( const QString &file ) | |||
72 | return version; | 76 | return version; |
73 | } | 77 | } |
74 | 78 | ||
79 | |||
80 | bool Utils :: getStorageSpace( const char *path, long *blockSize, long *totalBlocks, long *availBlocks ) | ||
81 | { | ||
82 | bool ret = false; | ||
83 | |||
84 | // qDebug( "Reading from path %s", path ); | ||
85 | struct statfs fs; | ||
86 | if ( !statfs( path, &fs ) ) | ||
87 | { | ||
88 | *blockSize = fs.f_bsize; | ||
89 | *totalBlocks = fs.f_blocks; | ||
90 | *availBlocks = fs.f_bavail; | ||
91 | ret = true; | ||
92 | } | ||
93 | |||
94 | return ret; | ||
95 | } | ||
96 | |||
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 | |||
@@ -33,6 +33,7 @@ public: | |||
33 | static QString getFilenameFromIpkFilename( const QString &file ); | 33 | static QString getFilenameFromIpkFilename( const QString &file ); |
34 | static QString getPackageNameFromIpkFilename( const QString &file ); | 34 | static QString getPackageNameFromIpkFilename( const QString &file ); |
35 | static QString getPackageVersionFromIpkFilename( const QString &file ); | 35 | static QString getPackageVersionFromIpkFilename( const QString &file ); |
36 | static bool getStorageSpace( const char *path, long *blockSize, long *totalBlocks, long *availBlocks ); | ||
36 | }; | 37 | }; |
37 | 38 | ||
38 | #endif | 39 | #endif |