author | eilers <eilers> | 2003-08-08 14:45:49 (UTC) |
---|---|---|
committer | eilers <eilers> | 2003-08-08 14:45:49 (UTC) |
commit | 14d394e6c107b037a09a31a92605034fe50f7813 (patch) (side-by-side diff) | |
tree | 800699cf4dc9681c3eb023340634dd6a15fd04c8 /library/storage.cpp | |
parent | dbc6ea35f5535a1f69deb7ebbafc0f721721dbf2 (diff) | |
download | opie-14d394e6c107b037a09a31a92605034fe50f7813.zip opie-14d394e6c107b037a09a31a92605034fe50f7813.tar.gz opie-14d394e6c107b037a09a31a92605034fe50f7813.tar.bz2 |
Merged branches from BRANCH_1_0
-rw-r--r-- | library/storage.cpp | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/library/storage.cpp b/library/storage.cpp index 4e07ec6..1ce43bc 100644 --- a/library/storage.cpp +++ b/library/storage.cpp @@ -57,49 +57,73 @@ static bool isCF(const QString& m) { if ( QString(devtype) == "ide" && m.find(devname)>0 ) { fclose(f); return TRUE; } } } fclose(f); } return FALSE; } +/*! \class StorageInfo storage.h + \brief The StorageInfo class describes the disks mounted on the file system. + + This class provides access to the mount information for the Linux + filesystem. Each mount point is represented by the FileSystem class. + To ensure this class has the most up to date size information, call + the update() method. Note that this will automatically be signaled + by the operating system when a disk has been mounted or unmounted. + + \ingroup qtopiaemb +*/ + +/*! Constructor that determines the current mount points of the filesystem. + The standard \a parent parameters is passed on to QObject. + */ StorageInfo::StorageInfo( QObject *parent ) : QObject( parent ) { mFileSystems.setAutoDelete( TRUE ); channel = new QCopChannel( "QPE/Card", this ); connect( channel, SIGNAL(received(const QCString &, const QByteArray &)), this, SLOT(cardMessage( const QCString &, const QByteArray &)) ); update(); } +/*! Returns the longest matching FileSystem that starts with the + same prefix as \a filename as its mount point. +*/ const FileSystem *StorageInfo::fileSystemOf( const QString &filename ) { for (QListIterator<FileSystem> i(mFileSystems); i.current(); ++i) { if ( filename.startsWith( (*i)->path() ) ) return (*i); } return 0; } void StorageInfo::cardMessage( const QCString& msg, const QByteArray& ) { if ( msg == "mtabChanged()" ) update(); } + + +/*! Updates the mount and free space available information for each mount + point. This method is automatically called when a disk is mounted or + unmounted. +*/ // cause of the lack of a d pointer we need // to store informations in a config file :( void StorageInfo::update() { //qDebug("StorageInfo::updating"); #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) struct mntent *me; FILE *mntfp = setmntent( "/etc/mtab", "r" ); QStringList curdisks; QStringList curopts; QStringList curfs; @@ -225,37 +249,98 @@ bool StorageInfo::hasSd() * */ bool StorageInfo::hasMmc() { bool hasMmc=false; if( deviceTab("/dev/mmc/part")) hasMmc=true; if( deviceTab("/dev/mmcd")) hasMmc=true; return hasMmc; } +/*! \fn const QList<FileSystem> &StorageInfo::fileSystems() const + Returns a list of all available mounted file systems. + \warning This may change in Qtopia 3.x to return only relevant Qtopia file systems (and ignore mount points such as /tmp) +*/ + +/*! \fn void StorageInfo::disksChanged() + Gets emitted when a disk has been mounted or unmounted, such as when + a CF c +*/ //--------------------------------------------------------------------------- FileSystem::FileSystem( const QString &disk, const QString &path, const QString &name, bool rem, const QString &o ) : fsdisk( disk ), fspath( path ), humanname( name ), blkSize(512), totalBlks(0), availBlks(0), removable( rem ), opts( o ) { update(); } void FileSystem::update() { #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) struct statfs fs; if ( !statfs( fspath.latin1(), &fs ) ) { blkSize = fs.f_bsize; totalBlks = fs.f_blocks; availBlks = fs.f_bavail; } else { blkSize = 0; totalBlks = 0; availBlks = 0; } #endif } +/*! \class FileSystem storage.h + \brief The FileSystem class describes a single mount point. + + This class simply returns information about a mount point, including + file system name, mount point, human readable name, size information + and mount options information. + \ingroup qtopiaemb + + \sa StorageInfo +*/ + +/*! \fn const QString &FileSystem::disk() const + Returns the file system name, such as /dev/hda3 +*/ + +/*! \fn const QString &FileSystem::path() const + Returns the mount path, such as /home +*/ + +/*! \fn const QString &FileSystem::name() const + Returns the translated, human readable name for the mount directory. +*/ + +/*! \fn const QString &FileSystem::options() const + Returns the mount options +*/ + +/*! \fn long FileSystem::blockSize() const + Returns the size of each block on the file system. +*/ + +/*! \fn long FileSystem::totalBlocks() const + Returns the total number of blocks on the file system +*/ + +/*! \fn long FileSystem::availBlocks() const + Returns the number of available blocks on the file system + */ + +/*! \fn bool FileSystem::isRemovable() const + Returns flag whether the file system can be removed, such as a CF card + would be removable, but the internal memory wouldn't +*/ + +/*! \fn bool FileSystem::isWritable() const + Returns flag whether the file system is mounted as writable or read-only. + Returns FALSE if read-only, TRUE if read and write. +*/ + +/*! \fn QStringList StorageInfo::fileSystemNames() const + Returns a list of filesystem names. +*/ |