QT c++ code for mounting and unmounting USB flash drive?
-
wow that was fast.. I am getting back into c++ , QT seems to be a fairly robust IDE. It packs more than you first expect...
thanks for your answer...Heh ,actually I was planning on calling mount and umount as a process call . I thought maybe QT might have a class for this somewhere... -
No it doesn't, that's a bit too platform specific.
Don't forget a thing: mount and umount requires admin privileges to work, unless the mount points are setup to be mountable by the user.
By the way it's Qt, QT stands for Apple QuickTime
-
Hi, Use this i have used QProcess as SGaist suggested.
QProcess* chkproc = new QProcess(); chkproc->start("blkid"); chkproc->waitForFinished(); QString output(chkproc->readAllStandardOutput()); int start = output.indexOf("/dev/sd", 0, Qt::CaseInsensitive); QString usbPath = output.mid(start, 9); QProcess* process = new QProcess(); process->start("mount "+ usbPath +" /media/usb"); process->waitForFinished(); QProcess::ExitStatus Status = process->exitStatus(); if (Status == 0) { qDebug() << "Usb Inserted!"; }
-
@Jimit-Rupani you are leaking at least two object each time you call that routine. Use the stack for the QProcess objects.