From d34dc773591a2d467c68875a68a671d6a809f861 Mon Sep 17 00:00:00 2001 From: eilers Date: Mon, 03 Nov 2003 16:52:18 +0000 Subject: Porting Opie to MacOS-X. The base system and all platform independent applications and platforms should work. Please see $OPIEDIR/development/macosx for details --- (limited to 'library/storage.cpp') diff --git a/library/storage.cpp b/library/storage.cpp index dc5cc22..f8b75d0 100644 --- a/library/storage.cpp +++ b/library/storage.cpp @@ -29,19 +29,30 @@ #include -#if defined(_OS_LINUX_) || defined(Q_OS_LINUX) +#if defined(_OS_LINUX_) || defined(Q_OS_LINUX) #include #include #endif +#ifdef Q_OS_MACX +# include +# include +# include +# include // For strerror() +# include +#endif /* Q_OS_MACX */ + #include -#include -#include +// Shouldn't be here ! (eilers) +// #include +// #include 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"); @@ -61,6 +72,7 @@ static bool isCF(const QString& m) } fclose(f); } +#endif /* Q_OS_MACX */ return FALSE; } @@ -204,8 +216,25 @@ void StorageInfo::update() } 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 ) { @@ -218,6 +247,9 @@ bool deviceTab( const char *device) { } } endmntent( mntfp ); +#endif /* Q_OS_MACX */ + + return hasDevice; } -- cgit v0.9.0.2