summaryrefslogtreecommitdiff
path: root/library/storage.cpp
Unidiff
Diffstat (limited to 'library/storage.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--library/storage.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/library/storage.cpp b/library/storage.cpp
index 0ea465b..fcee689 100644
--- a/library/storage.cpp
+++ b/library/storage.cpp
@@ -50,98 +50,98 @@ static bool isCF(const QString& m)
50 50
51#ifndef Q_OS_MACX 51#ifndef Q_OS_MACX
52 FILE* f = fopen("/var/run/stab", "r"); 52 FILE* f = fopen("/var/run/stab", "r");
53 if (!f) f = fopen("/var/state/pcmcia/stab", "r"); 53 if (!f) f = fopen("/var/state/pcmcia/stab", "r");
54 if (!f) f = fopen("/var/lib/pcmcia/stab", "r"); 54 if (!f) f = fopen("/var/lib/pcmcia/stab", "r");
55 if ( f ) 55 if ( f )
56 { 56 {
57 char line[1024]; 57 char line[1024];
58 char devtype[80]; 58 char devtype[80];
59 char devname[80]; 59 char devname[80];
60 while ( fgets( line, 1024, f ) ) 60 while ( fgets( line, 1024, f ) )
61 { 61 {
62 // 0 ide ide-cs 0 hda 3 0 62 // 0 ide ide-cs 0 hda 3 0
63 if ( sscanf(line,"%*d %s %*s %*s %s", devtype, devname )==2 ) 63 if ( sscanf(line,"%*d %s %*s %*s %s", devtype, devname )==2 )
64 { 64 {
65 if ( QString(devtype) == "ide" && m.find(devname)>0 ) 65 if ( QString(devtype) == "ide" && m.find(devname)>0 )
66 { 66 {
67 fclose(f); 67 fclose(f);
68 return TRUE; 68 return TRUE;
69 } 69 }
70 } 70 }
71 } 71 }
72 fclose(f); 72 fclose(f);
73 } 73 }
74#endif /* Q_OS_MACX */ 74#endif /* Q_OS_MACX */
75 return FALSE; 75 return FALSE;
76} 76}
77 77
78/*! \class StorageInfo storage.h 78/*! \class StorageInfo storage.h
79 \brief The StorageInfo class describes the disks mounted on the file system. 79 \brief The StorageInfo class describes the disks mounted on the file system.
80 80
81 This class provides access to the mount information for the Linux 81 This class provides access to the mount information for the Linux
82 filesystem. Each mount point is represented by the FileSystem class. 82 filesystem. Each mount point is represented by the FileSystem class.
83 To ensure this class has the most up to date size information, call 83 To ensure this class has the most up to date size information, call
84 the update() method. Note that this will automatically be signaled 84 the update() method. Note that this will automatically be signaled
85 by the operating system when a disk has been mounted or unmounted. 85 by the operating system when a disk has been mounted or unmounted.
86 86
87 \ingroup qtopiaemb 87 \ingroup qtopiaemb
88*/ 88*/
89 89
90/*! Constructor that determines the current mount points of the filesystem. 90/*! Constructor that determines the current mount points of the filesystem.
91 The standard \a parent parameters is passed on to QObject. 91 The standard \a parent parameters is passed on to QObject.
92 */ 92 */
93StorageInfo::StorageInfo( QObject *parent ) 93StorageInfo::StorageInfo( QObject *parent )
94 : QObject( parent ) 94 : QObject( parent )
95{ 95{
96 mFileSystems.setAutoDelete( TRUE ); 96 mFileSystems.setAutoDelete( TRUE );
97 channel = new QCopChannel( "QPE/Card", this ); 97 channel = new QCopChannel( "QPE/Card", this );
98 connect( channel, SIGNAL(received(const QCString &, const QByteArray &)), 98 connect( channel, SIGNAL(received(const QCString&,const QByteArray&)),
99 this, SLOT(cardMessage( const QCString &, const QByteArray &)) ); 99 this, SLOT(cardMessage(const QCString&,const QByteArray&)) );
100 update(); 100 update();
101} 101}
102 102
103/*! Returns the longest matching FileSystem that starts with the 103/*! Returns the longest matching FileSystem that starts with the
104 same prefix as \a filename as its mount point. 104 same prefix as \a filename as its mount point.
105*/ 105*/
106const FileSystem *StorageInfo::fileSystemOf( const QString &filename ) 106const FileSystem *StorageInfo::fileSystemOf( const QString &filename )
107{ 107{
108 for (QListIterator<FileSystem> i(mFileSystems); i.current(); ++i) 108 for (QListIterator<FileSystem> i(mFileSystems); i.current(); ++i)
109 { 109 {
110 if ( filename.startsWith( (*i)->path() ) ) 110 if ( filename.startsWith( (*i)->path() ) )
111 return (*i); 111 return (*i);
112 } 112 }
113 return 0; 113 return 0;
114} 114}
115 115
116 116
117void StorageInfo::cardMessage( const QCString& msg, const QByteArray& ) 117void StorageInfo::cardMessage( const QCString& msg, const QByteArray& )
118{ 118{
119 if ( msg == "mtabChanged()" ) 119 if ( msg == "mtabChanged()" )
120 update(); 120 update();
121} 121}
122 122
123 123
124/*! Updates the mount and free space available information for each mount 124/*! Updates the mount and free space available information for each mount
125 point. This method is automatically called when a disk is mounted or 125 point. This method is automatically called when a disk is mounted or
126 unmounted. 126 unmounted.
127*/ 127*/
128// cause of the lack of a d pointer we need 128// cause of the lack of a d pointer we need
129// to store informations in a config file :( 129// to store informations in a config file :(
130void StorageInfo::update() 130void StorageInfo::update()
131{ 131{
132 //qDebug("StorageInfo::updating"); 132 //qDebug("StorageInfo::updating");
133#if defined(_OS_LINUX_) || defined(Q_OS_LINUX) 133#if defined(_OS_LINUX_) || defined(Q_OS_LINUX)
134 struct mntent *me; 134 struct mntent *me;
135 FILE *mntfp = setmntent( "/etc/mtab", "r" ); 135 FILE *mntfp = setmntent( "/etc/mtab", "r" );
136 136
137 QStringList curdisks; 137 QStringList curdisks;
138 QStringList curopts; 138 QStringList curopts;
139 QStringList curfs; 139 QStringList curfs;
140 bool rebuild = FALSE; 140 bool rebuild = FALSE;
141 int n=0; 141 int n=0;
142 if ( mntfp ) 142 if ( mntfp )
143 { 143 {
144 while ( (me = getmntent( mntfp )) != 0 ) 144 while ( (me = getmntent( mntfp )) != 0 )
145 { 145 {
146 QString fs = me->mnt_fsname; 146 QString fs = me->mnt_fsname;
147 if ( fs.left(7)=="/dev/hd" || fs.left(7)=="/dev/sd" 147 if ( fs.left(7)=="/dev/hd" || fs.left(7)=="/dev/sd"