Skip to content
This repository has been archived by the owner on Dec 4, 2020. It is now read-only.

Commit

Permalink
Merge branch 'master' of github.com:pcbsd/pcbsd
Browse files Browse the repository at this point in the history
  • Loading branch information
Kris Moore committed Aug 6, 2013
2 parents f615958 + d5ff236 commit 959fb5c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
30 changes: 19 additions & 11 deletions src-qt4/pc-mounttray/menuItem.cpp
Expand Up @@ -105,11 +105,23 @@ bool MenuItem::isConnected(){

bool MenuItem::isMounted(){
//Check if device is mounted
QStringList chk = pcbsd::Utils::runShellCommand("mount");
bool mounted=false;
for(int i=0; i<chk.length(); i++){
mounted = chk[i].contains(device) || chk[i].contains(devLabel->text()) || chk[i].contains(devLabel->text().replace(" ","-"));
if(mounted){
//Save the mountpoint if it is mounted
mountpoint = chk[i].section(" on ",1,10).section("(",0,0).simplified();
break;
}
}
return mounted;
/*
QString chk = pcbsd::Utils::runShellCommandSearch("mount",device);
if(chk.isEmpty() ){ chk = pcbsd::Utils::runShellCommandSearch("mount",devLabel->text().replace(" ","-")); }

if(chk.isEmpty() ){ return FALSE; }
else{ return TRUE; }
*/
}

//Cleanup function
Expand Down Expand Up @@ -247,21 +259,17 @@ void MenuItem::mountItem(){

void MenuItem::unmountItem(){
//Unmount the device

//Check to see if the current mountpoint exists or if it is somewhere else
if( !QFile::exists(mountpoint) ){
if( isMounted() ){ //double check that it is actually mounted
//mounted someplace else - find it
QString output = pcbsd::Utils::runShellCommandSearch("mount",device);
mountpoint = output.section(" on ",1,1).section(" (",0,0).replace(" ","-");
}else{
if( !isMounted() ){ //double check that it is actually mounted (and fix the mountpoint)
//it is not mounted to begin with
return;
}
}

QString cmd1 = "umount " + mountpoint;
QString cmd2 = "rmdir " + mountpoint;
//Make sure there are no spaces in the mounpoint path
QString cmd1 = "umount \"" + mountpoint +"\"";
QString cmd2 = "rmdir \"" + mountpoint +"\"";
qDebug() << "Unmounting device from" << mountpoint;
//Run the commands
QStringList output;
Expand Down Expand Up @@ -296,7 +304,7 @@ void MenuItem::updateSizes(){
//this method only works if the device is currently mounted
bool ok = FALSE;
if(isMounted()){
QString cmd = "df "+mountpoint;
QString cmd = "df \""+mountpoint+"\"";
QStringList output = systemCMD(cmd); //make sure we use the one with a 1K blocksize
if(output.length() > 1){
//parse the output (1K blocks) and save them
Expand Down
2 changes: 1 addition & 1 deletion src-qt4/pc-mounttray/mountTray.cpp
Expand Up @@ -310,7 +310,7 @@ void MountTray::openMediaDir(QString dir){
}
//Open the default file manager to the given directory as that user
qDebug() << "Opening the media directory with user permissions";
QString cmd = "su -m "+USERNAME+" -c \'"+FILEMAN+" "+dir+"\' &";
QString cmd = "su -m "+USERNAME+" -c \'"+FILEMAN+" \""+dir+"\"\' &";
if(DEBUG_MODE){ qDebug() << " -cmd:" << cmd; }
system( cmd.toUtf8() );
}
Expand Down

0 comments on commit 959fb5c

Please sign in to comment.