PDA

View Full Version : detecting disks



nishad_kumar
5th September 2007, 10:17
hi all,

i am working on objective c. i want to detect programmatically that how many disks are connected to mac (mounted or not) and how can identify the disk( ie. whether it is hard disk, USB or anything else). if anybody has idea about this please share.


thanks in advance

with regards
Nishad.

patrik08
5th September 2007, 10:51
hi all,

i am working on objective c. i want to detect programmatically that how many disks are connected to mac (mounted or not) and how can identify the disk( ie. whether it is hard disk, USB or anything else). if anybody has idea about this please share.


thanks in advance

with regards
Nishad.

I suppose you must only Read /Volumes dir on this dir is all mounted device...








void Setting_Gui::WebdavSetup()
{
label_webdav->setText(tr("Your OS Not Support Webdav"));
QStringList diskremote;
QString disksetting = Global_Config(APPLICATION_SETTING,"webdav_root");
#if defined Q_WS_WIN
/* http://ciz.ch/service/98,1142862047/de/ netdrive webdrive */
label_webdav->setText(tr("Window XP/2000 OS: Webdav Root (Radice)"));
QString alfa ="A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y, Z";
diskremote = alfa.split(",");
webdav_root->clear();
int loop= 0 - 1;
int activeselected;
QStringListIterator o(diskremote);
while (o.hasNext()) {
loop++;
QString disker = o.next();
QString diskeree = disker.append(":/");
webdav_root->addItem(diskeree);
if (disksetting == diskeree) {
activeselected = loop;
}
}
webdav_root->setEditable(false);
webdav_root->setCurrentIndex(activeselected);
#endif
#if defined Q_WS_MAC
/* apple + K */
label_webdav->setText(tr("Mac OS: Mount Disk Webdav Root"));
QString listdiron ="/Volumes/";
webdav_root->addItem(disksetting);
/* webdav_root->addItem(listdiron);*/
QDir dir(listdiron);
if (dir.exists()) {
const QFileInfoList list = dir.entryInfoList();
QFileInfo fi;
for (int i = 0; i < list.size(); i++)
{
fi = list.at(i);
if (fi.isDir() && fi.fileName() != "." && fi.fileName() != "..") {
QString disker = fi.absoluteFilePath();
QString diskeree = disker.append("/");
webdav_root->addItem(diskeree);
}
}
}
webdav_root->setEditable(false);
#endif

#if defined Q_WS_X11
/* http://www.webdav.org/cadaver/ */
label_webdav->setText(tr("Linux OS: Mount Disk Webdav Root"));
QString listdiron ="/mnt/";
webdav_root->setEditable(true);
webdav_root->addItem(disksetting);
webdav_root->addItem(listdiron);
#endif

}

nishad_kumar
6th September 2007, 07:34
thanks for the replay.

with regards
Nishad

nishad_kumar
7th September 2007, 08:35
hi,

thanks all

i got the drives mounted on mac programmatically by reading /volumes. but actually i need to find the size of each drive. can anybody help me to find programmatically size of drive ?.

with regards
Nishad.