author | llornkcor <llornkcor> | 2003-03-26 02:06:21 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2003-03-26 02:06:21 (UTC) |
commit | a76176911328349414203edda3785ac8925c0648 (patch) (unidiff) | |
tree | 30e345d6c458b3dc2f0fd06fe900d4b7203e902f | |
parent | f50d60ad220bbaf76e6cbcb07caf5bed037311d5 (diff) | |
download | opie-a76176911328349414203edda3785ac8925c0648.zip opie-a76176911328349414203edda3785ac8925c0648.tar.gz opie-a76176911328349414203edda3785ac8925c0648.tar.bz2 |
add static isCf, isSd, and isMmc
-rw-r--r-- | library/storage.cpp | 61 | ||||
-rw-r--r-- | library/storage.h | 8 |
2 files changed, 65 insertions, 4 deletions
diff --git a/library/storage.cpp b/library/storage.cpp index a7c466d..912b22d 100644 --- a/library/storage.cpp +++ b/library/storage.cpp | |||
@@ -2,5 +2,6 @@ | |||
2 | ** Copyright (C) Holger 'zecke' Freyther <freyther@kde.org> | 2 | ** Copyright (C) Holger 'zecke' Freyther <freyther@kde.org> |
3 | ** Copyright (C) Lorn Potter <llornkcor@handhelds.org> | ||
3 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 4 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
4 | ** | 5 | ** |
5 | ** This file is part of Qtopia Environment. | 6 | ** This file is part of Opie Environment. |
6 | ** | 7 | ** |
@@ -39,2 +40,6 @@ | |||
39 | 40 | ||
41 | #include <sys/vfs.h> | ||
42 | #include <mntent.h> | ||
43 | |||
44 | |||
40 | static bool isCF(const QString& m) | 45 | static bool isCF(const QString& m) |
@@ -176,2 +181,56 @@ void StorageInfo::update() | |||
176 | 181 | ||
182 | bool deviceTab( const char *device) { | ||
183 | QString name = device; | ||
184 | bool hasDevice=false; | ||
185 | struct mntent *me; | ||
186 | FILE *mntfp = setmntent( "/etc/mtab", "r" ); | ||
187 | if ( mntfp ) { | ||
188 | while ( (me = getmntent( mntfp )) != 0 ) { | ||
189 | QString deviceName = me->mnt_fsname; | ||
190 | // qDebug(deviceName); | ||
191 | if( deviceName.left(name.length()) == name) { | ||
192 | hasDevice = true; | ||
193 | } | ||
194 | } | ||
195 | } | ||
196 | endmntent( mntfp ); | ||
197 | return hasDevice; | ||
198 | } | ||
199 | |||
200 | /*! | ||
201 | * @fn hasCf() | ||
202 | * @brief returns whether device has Cf mounted | ||
203 | * | ||
204 | */ | ||
205 | bool StorageInfo::hasCf() | ||
206 | { | ||
207 | return deviceTab("/dev/hd"); | ||
208 | } | ||
209 | |||
210 | /*! | ||
211 | * @fn hasSd() | ||
212 | * @brief returns whether device has SD mounted | ||
213 | * | ||
214 | */ | ||
215 | bool StorageInfo::hasSd() | ||
216 | { | ||
217 | return deviceTab("/dev/mmcd"); | ||
218 | } | ||
219 | |||
220 | /*! | ||
221 | * @fn hasMmc() | ||
222 | * @brief reutrns whether device has mmc mounted | ||
223 | * | ||
224 | */ | ||
225 | bool StorageInfo::hasMmc() | ||
226 | { | ||
227 | bool hasMmc=false; | ||
228 | if( deviceTab("/dev/mmc/part")) | ||
229 | hasMmc=true; | ||
230 | if( deviceTab("/dev/mmcd")) | ||
231 | hasMmc=true; | ||
232 | return hasMmc; | ||
233 | } | ||
234 | |||
235 | |||
177 | //--------------------------------------------------------------------------- | 236 | //--------------------------------------------------------------------------- |
diff --git a/library/storage.h b/library/storage.h index 66a9f9d..0a0698f 100644 --- a/library/storage.h +++ b/library/storage.h | |||
@@ -34,5 +34,7 @@ public: | |||
34 | 34 | ||
35 | const QList<FileSystem> &fileSystems() const { return mFileSystems; } | 35 | const QList<FileSystem> &fileSystems() const { return mFileSystems; } |
36 | const FileSystem *fileSystemOf( const QString &filename ); | 36 | const FileSystem *fileSystemOf( const QString &filename ); |
37 | 37 | static bool hasCf(); | |
38 | static bool hasSd(); | ||
39 | static bool hasMmc(); | ||
38 | signals: | 40 | signals: |