1
//This file is part of AcetoneISO. Copyright 2006,2007,2008,2009 Marco Di Antonio and Fabrizio Di Marco (acetoneiso@gmail.com)
3
// AcetoneISO is free software: you can redistribute it and/or modify
4
// it under the terms of the GNU General Public License as published by
5
// the Free Software Foundation, either version 3 of the License, or
6
// (at your option) any later version.
8
// AcetoneISO is distributed in the hope that it will be useful,
9
// but WITHOUT ANY WARRANTY; without even the implied warranty of
10
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
// GNU General Public License for more details.
13
// You should have received a copy of the GNU General Public License
14
// along with AcetoneISO. If not, see <http://www.gnu.org/licenses/>.
15
void acetoneiso::gmount()
17
QMessageBox::warning(this, "AcetoneISO::Warning!",tr("NOTE: If you want to mount an image in a root folder like /media/cdrom, please launch AcetoneISO as root user. "));
18
QDir Home = QDir::home();
19
QFile file(Home.path() + "/.acetoneiso/acetoneiso.conf");
20
file.open(QIODevice::ReadOnly);//lo apro in sola lettura
21
QTextStream in(&file);
22
QString stra = in.readLine();
23
QString strb = in.readLine();
24
QString strc = in.readLine();
26
QFile Mtab("/etc/mtab");//dichiaro un file Mtab che sarebbe /etc/mtab
27
Mtab.open(QIODevice::ReadOnly);//lo apro in sola lettura
28
QString str1 = (Mtab.readAll());//leggo il contenuto del file mtab
31
isodamontare = QFileDialog::getOpenFileName(this,tr("Open Image"), Home.path() , tr("Image Files (*.iso *.daa *.bin *.mdf *.ashdisc *.bwi *.b5i *.lcd *.img *.cdi *.cif *.p01 *.pdi *.nrg *.ncd *.pxi *.gi *.fcd *.vcd *.c2d)"));
33
if ( !isodamontare.isNull() ) {
34
//mi ricavo l'estensione dell'immagine
35
QFileInfo getinfo(isodamontare);
36
QString ext = getinfo.suffix(); // ext = "iso?mdf?xyz?"
37
if (((ext != "iso") && (ext != "nrg")) && ((ext != "bin") && (ext != "img")) && (ext != "mdf")) {
39
msgBox.setText(tr("The image ") + isodamontare + tr(" can't be mounted. You must convert it to ISO or extract content to a folder.\nPlease choose what to do:") );
40
QPushButton *connectButton = msgBox.addButton(tr(" Convert to ISO "), QMessageBox::ActionRole);
41
QPushButton *connectButton2 = msgBox.addButton(tr(" Extract image to a folder "), QMessageBox::ActionRole);
42
//msgBox.setStandardButtons(QMessageBox::("ISO File") | QMessageBox::("CD/DVD"));
44
if (msgBox.clickedButton() == connectButton) {
47
else if (msgBox.clickedButton() == connectButton2) {
52
QString folder = QFileDialog::getExistingDirectory( this, tr("AcetoneISO::Select where to mount image"), Home.path() );
53
if (!folder.isNull()) {
54
folder.chop(1);//casini del qt...il chop serve per togliere l'ultimo slash (/) dal percorso altrimenti in mtab non troverà mai il percorso con lo slash finale..
55
if(!str1.contains( folder ) ) {
56
FUse.start("fuseiso",QStringList() << isodamontare << folder << "-o" << "nonempty" );
57
if(strc.contains("kde", Qt::CaseInsensitive)) {
58
BRowser.startDetached("kfmclient",QStringList() << "exec" << folder );
61
BRowser.startDetached("nautilus",QStringList() << folder );
65
QMessageBox::warning(this, "AcetoneISO::Warning!",tr("The folder ") + folder + tr(" can't be mounted"));
73
void acetoneiso::gumount()
75
QDir Home = QDir::home();
76
QFile Mtab("/etc/mtab");//dichiaro un file Mtab che sarebbe /etc/mtab
77
Mtab.open(QIODevice::ReadOnly);//lo apro in sola lettura
78
QString str1 = (Mtab.readAll());//leggo il contenuto del file mtab
79
QString folder = QFileDialog::getExistingDirectory( this, tr("AcetoneISO::Select folder to unmount"), Home.path() );
81
if(str1.contains( folder ) ) {
82
FUsermount.start("fusermount",QStringList() << "-u" << "-z" << folder );
85
QMessageBox::warning(this, "AcetoneISO::Warning!",tr("The folder ") + folder + tr(" is not mounted!"));