summaryrefslogtreecommitdiff
path: root/noncore/settings/aqpkg
authorandyq <andyq>2002-12-04 23:15:20 (UTC)
committer andyq <andyq>2002-12-04 23:15:20 (UTC)
commit35d40e65116cee8b430cdc586db187f81488aa1d (patch) (unidiff)
tree7cc95fa6b0525f178734de42760b36e4208d00be /noncore/settings/aqpkg
parent128343cd009009e42ce6bcdfd45a294c7ea44f83 (diff)
downloadopie-35d40e65116cee8b430cdc586db187f81488aa1d.zip
opie-35d40e65116cee8b430cdc586db187f81488aa1d.tar.gz
opie-35d40e65116cee8b430cdc586db187f81488aa1d.tar.bz2
Added new method to get available space on a volume
Diffstat (limited to 'noncore/settings/aqpkg') (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
@@ -12,12 +12,16 @@
12 * it under the terms of the GNU General Public License as published by * 12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or * 13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. * 14 * (at your option) any later version. *
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
21Utils :: Utils() 25Utils :: Utils()
22{ 26{
23} 27}
@@ -51,13 +55,13 @@ QString Utils :: getFilenameFromIpkFilename( const QString &file )
51 55
52QString Utils :: getPackageNameFromIpkFilename( const QString &file ) 56QString Utils :: getPackageNameFromIpkFilename( const QString &file )
53{ 57{
54 int p = file.findRev( "/" ); 58 int p = file.findRev( "/" );
55 QString name = file; 59 QString name = file;
56 if ( p != -1 ) 60 if ( p != -1 )
57 name = name.mid( p + 1 ); 61 name = name.mid( p + 1 );
58 p = name.find( "_" ); 62 p = name.find( "_" );
59 QString packageName = name.mid( 0, p ); 63 QString packageName = name.mid( 0, p );
60 return packageName; 64 return packageName;
61} 65}
62 66
63QString Utils :: getPackageVersionFromIpkFilename( const QString &file ) 67QString Utils :: getPackageVersionFromIpkFilename( const QString &file )
@@ -69,6 +73,24 @@ QString Utils :: getPackageVersionFromIpkFilename( const QString &file )
69 p = name.find( "_" ) + 1; 73 p = name.find( "_" ) + 1;
70 int p2 = name.find( "_", p ); 74 int p2 = name.find( "_", p );
71 QString version = name.mid( p, p2 - p ); 75 QString version = name.mid( p, p2 - p );
72 return version; 76 return version;
73} 77}
74 78
79
80bool 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
@@ -30,9 +30,10 @@ public:
30 ~Utils(); 30 ~Utils();
31 31
32 static QString getPathfromIpkFilename( const QString &file ); 32 static QString getPathfromIpkFilename( const QString &file );
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