From a76176911328349414203edda3785ac8925c0648 Mon Sep 17 00:00:00 2001 From: llornkcor Date: Wed, 26 Mar 2003 02:06:21 +0000 Subject: add static isCf, isSd, and isMmc --- (limited to 'library/storage.cpp') diff --git a/library/storage.cpp b/library/storage.cpp index a7c466d..912b22d 100644 --- a/library/storage.cpp +++ b/library/storage.cpp @@ -1,8 +1,9 @@ /********************************************************************** ** Copyright (C) Holger 'zecke' Freyther +** Copyright (C) Lorn Potter ** Copyright (C) 2000 Trolltech AS. All rights reserved. ** -** This file is part of Qtopia Environment. +** This file is part of Opie Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software @@ -37,6 +38,10 @@ #include +#include +#include + + static bool isCF(const QString& m) { FILE* f = fopen("/var/run/stab", "r"); @@ -174,6 +179,60 @@ void StorageInfo::update() #endif } +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; +} + + //--------------------------------------------------------------------------- FileSystem::FileSystem( const QString &disk, const QString &path, const QString &name, bool rem, const QString &o ) -- cgit v0.9.0.2