summaryrefslogtreecommitdiff
path: root/library
Side-by-side diff
Diffstat (limited to 'library') (more/less context) (ignore whitespace changes)
-rw-r--r--library/storage.cpp61
-rw-r--r--library/storage.h8
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 @@
** Copyright (C) Holger 'zecke' Freyther <freyther@kde.org>
+** Copyright (C) Lorn Potter <llornkcor@handhelds.org>
** Copyright (C) 2000 Trolltech AS. All rights reserved.
**
-** This file is part of Qtopia Environment.
+** This file is part of Opie Environment.
**
@@ -39,2 +40,6 @@
+#include <sys/vfs.h>
+#include <mntent.h>
+
+
static bool isCF(const QString& m)
@@ -176,2 +181,56 @@ void StorageInfo::update()
+bool deviceTab( const char *device) {
+ QString name = device;
+ bool hasDevice=false;
+ struct mntent *me;
+ FILE *mntfp = setmntent( "/etc/mtab", "r" );
+ if ( mntfp ) {
+ while ( (me = getmntent( mntfp )) != 0 ) {
+ QString deviceName = me->mnt_fsname;
+// qDebug(deviceName);
+ if( deviceName.left(name.length()) == name) {
+ hasDevice = true;
+ }
+ }
+ }
+ endmntent( mntfp );
+ return hasDevice;
+}
+
+/*!
+ * @fn hasCf()
+ * @brief returns whether device has Cf mounted
+ *
+ */
+bool StorageInfo::hasCf()
+{
+ return deviceTab("/dev/hd");
+}
+
+/*!
+ * @fn hasSd()
+ * @brief returns whether device has SD mounted
+ *
+ */
+bool StorageInfo::hasSd()
+{
+ return deviceTab("/dev/mmcd");
+}
+
+/*!
+ * @fn hasMmc()
+ * @brief reutrns whether device has mmc mounted
+ *
+ */
+bool StorageInfo::hasMmc()
+{
+ bool hasMmc=false;
+ if( deviceTab("/dev/mmc/part"))
+ hasMmc=true;
+ if( deviceTab("/dev/mmcd"))
+ hasMmc=true;
+ return hasMmc;
+}
+
+
//---------------------------------------------------------------------------
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:
- const QList<FileSystem> &fileSystems() const { return mFileSystems; }
- const FileSystem *fileSystemOf( const QString &filename );
-
+ const QList<FileSystem> &fileSystems() const { return mFileSystems; }
+ const FileSystem *fileSystemOf( const QString &filename );
+ static bool hasCf();
+ static bool hasSd();
+ static bool hasMmc();
signals: