Logo Search packages:      
Sourcecode: q4wine version File versions  Download package

bool corelib::mountImage ( QString  image_name,
const QString  prefix_name 
)

This function mount an image or drive to prefix mount point.

Parameters:
image_name Image or drive name.
prefix_name Prefix name.
Returns:
Return an list of cdrom devices.

Definition at line 1144 of file q4wine-lib.cpp.

References getEscapeString(), Prefix::getMountPoint(), Image::getPath(), getSetting(), getWhichOut(), runProcess(), showError(), and umountImage().

                                                                                   {

            this->umountImage(prefix_name);

            QString mount_point=db_prefix.getMountPoint(prefix_name);
#ifdef DEBUG
                  qDebug()<<"[ii] corelib::mountImage: mount point: "<<mount_point;
#endif

                  if (mount_point.isEmpty()){
                        this->showError(QObject::tr("It seems no mount point was set in prefix options.<br>You might need to set it manualy."));
                        return false;
                  }
                  if (image_name.isEmpty())
                        return false;

                  QStringList args;
                  QString mount_string;

#ifdef _OS_FREEBSD_
                  if ((image_name.contains("/") && (!image_name.contains(".iso", Qt::CaseInsensitive)) && (!image_name.contains(".nrg", Qt::CaseInsensitive)))) {
                        mount_string=this->getSetting("quickmount", "mount_drive_string", false).toString();
#ifdef DEBUG
                        qDebug()<<"[ii] corelib::mountImage:FreeBSD drive mount base string: "<<mount_string;
#endif
                        mount_string.replace("%MOUNT_DRIVE%", this->getEscapeString(image_name));
                  } else {
                        mount_string=this->getSetting("quickmount", "mount_image_string", false).toString();
#ifdef DEBUG
                        qDebug()<<"[ii] corelib::mountImage:FreeBSD image mount base string: "<<mount_string;
#endif

                        if (!QFile(image_name).exists()){
                    mount_string.replace("%MOUNT_IMAGE%", this->getEscapeString(db_image.getPath(image_name)));
                        } else {
                              mount_string.replace("%MOUNT_IMAGE%", this->getEscapeString(image_name));
                        }
                mount_string.replace("%MDCONFIG_BIN%", this->getWhichOut("mdconfig"));
                  }

                  mount_string.replace("%GUI_SUDO%", getSetting("system", "gui_sudo").toString());
                  mount_string.replace("%SUDO%", getSetting("system", "sudo").toString());
                  mount_string.replace("%MOUNT_BIN%", getSetting("system", "mount").toString());
                  mount_string.replace("%MOUNT_POINT%", this->getEscapeString(mount_point));
#endif

#ifdef _OS_LINUX_
                  if ((image_name.contains("/") && (!image_name.contains(".iso", Qt::CaseInsensitive)) && (!image_name.contains(".nrg", Qt::CaseInsensitive)))) {
                        mount_string=this->getSetting("quickmount", "mount_drive_string", false).toString();
#ifdef DEBUG
                        qDebug()<<"[ii] corelib::mountImage:Linux drive mount base string: "<<mount_string;
#endif
                        mount_string.replace("%MOUNT_DRIVE%", this->getEscapeString(image_name));
                  } else {
                        mount_string=this->getSetting("quickmount", "mount_image_string", false).toString();
#ifdef DEBUG
                        qDebug()<<"[ii] corelib::mountImage:Linux image mount base string: "<<mount_string;
#endif

                        if (!QFile(image_name).exists()){
                              mount_string.replace("%MOUNT_IMAGE%", this->getEscapeString(this->db_image.getPath(image_name)));
                        } else {
                              mount_string.replace("%MOUNT_IMAGE%", this->getEscapeString(image_name));
                        }

                        if (image_name.right(3)=="nrg"){
                              mount_string.replace("%MOUNT_OPTIONS%", "-o  loop,offset=307200");
                        } else {
                              mount_string.replace("%MOUNT_OPTIONS%", "-o  loop");
                        }
                  }

                  mount_string.replace("%GUI_SUDO%", getSetting("system", "gui_sudo").toString());
                  mount_string.replace("%SUDO%", getSetting("system", "sudo").toString());
                  mount_string.replace("%MOUNT_BIN%", getSetting("system", "mount").toString());
                  mount_string.replace("%MOUNT_POINT%", this->getEscapeString(mount_point));
#endif

                  args.clear();
                  args.append("-c");
                  args.append(mount_string);

#ifdef DEBUG
                  qDebug()<<"[ii] corelib::mountImage: mount args: "<<args;
#endif
                  return this->runProcess(args, QObject::tr("Mounting..."),  QObject::tr("Mounting %1 into %2").arg(image_name).arg(mount_point));
            }


Generated by  Doxygen 1.6.0   Back to index