summaryrefslogtreecommitdiff
path: root/library/storage.cpp
authoreilers <eilers>2003-11-03 16:52:18 (UTC)
committer eilers <eilers>2003-11-03 16:52:18 (UTC)
commitd34dc773591a2d467c68875a68a671d6a809f861 (patch) (side-by-side diff)
treeb57e5ae15c51e3d87ca95d57aedfd1ca3db57bfe /library/storage.cpp
parentce84f2d8bdd65c438821f0457cdad6bbbfa73380 (diff)
downloadopie-d34dc773591a2d467c68875a68a671d6a809f861.zip
opie-d34dc773591a2d467c68875a68a671d6a809f861.tar.gz
opie-d34dc773591a2d467c68875a68a671d6a809f861.tar.bz2
Porting Opie to MacOS-X.
The base system and all platform independent applications and platforms should work. Please see $OPIEDIR/development/macosx for details
Diffstat (limited to 'library/storage.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--library/storage.cpp42
1 files changed, 37 insertions, 5 deletions
diff --git a/library/storage.cpp b/library/storage.cpp
index dc5cc22..f8b75d0 100644
--- a/library/storage.cpp
+++ b/library/storage.cpp
@@ -26,25 +26,36 @@
#include <qfile.h>
#include <qtimer.h>
#include <qcopchannel_qws.h>
#include <stdio.h>
-#if defined(_OS_LINUX_) || defined(Q_OS_LINUX)
+#if defined(_OS_LINUX_) || defined(Q_OS_LINUX)
#include <sys/vfs.h>
#include <mntent.h>
#endif
+#ifdef Q_OS_MACX
+# include <sys/param.h>
+# include <sys/ucred.h>
+# include <sys/mount.h>
+# include <stdio.h> // For strerror()
+# include <errno.h>
+#endif /* Q_OS_MACX */
+
#include <qstringlist.h>
-#include <sys/vfs.h>
-#include <mntent.h>
+// Shouldn't be here ! (eilers)
+// #include <sys/vfs.h>
+// #include <mntent.h>
static bool isCF(const QString& m)
{
+
+#ifndef Q_OS_MACX
FILE* f = fopen("/var/run/stab", "r");
if (!f) f = fopen("/var/state/pcmcia/stab", "r");
if (!f) f = fopen("/var/lib/pcmcia/stab", "r");
if ( f ) {
char line[1024];
char devtype[80];
@@ -58,12 +69,13 @@ static bool isCF(const QString& m)
return TRUE;
}
}
}
fclose(f);
}
+#endif /* Q_OS_MACX */
return FALSE;
}
/*! \class StorageInfo storage.h
\brief The StorageInfo class describes the disks mounted on the file system.
@@ -201,26 +213,46 @@ void StorageInfo::update()
i.current()->update();
}
#endif
}
bool deviceTab( const char *device) {
- QString name = device;
- bool hasDevice=false;
+ QString name = device;
+ bool hasDevice=false;
+
+#ifdef Q_OS_MACX
+ // Darwin (MacOS X)
+ struct statfs** mntbufp;
+ int count = 0;
+ if ( ( count = getmntinfo( mntbufp, MNT_WAIT ) ) == 0 ){
+ qWarning("deviceTab: Error in getmntinfo(): %s",strerror( errno ) );
+ hasDevice = false;
+ }
+ for( int i = 0; i < count; i++ ){
+ QString deviceName = mntbufp[i]->f_mntfromname;
+ qDebug(deviceName);
+ if( deviceName.left( name.length() ) == name )
+ hasDevice = true;
+ }
+#else
+ // Linux
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 );
+#endif /* Q_OS_MACX */
+
+
return hasDevice;
}
/*!
* @fn static bool StorageInfo::hasCf()
* @brief returns whether device has Cf mounted