From ba34b15fddcd16b82338a2d88b7aee8a1654af1f Mon Sep 17 00:00:00 2001 From: Nils Schwabe Date: Wed, 19 Mar 2014 17:48:16 +0100 Subject: removed the file and path option for XMLs --- src/vsession.cpp | 75 ++++---------------------------------------------------- 1 file changed, 5 insertions(+), 70 deletions(-) (limited to 'src/vsession.cpp') diff --git a/src/vsession.cpp b/src/vsession.cpp index e5dfba2..ebe369a 100644 --- a/src/vsession.cpp +++ b/src/vsession.cpp @@ -302,8 +302,7 @@ QList VSession::readXmlFile(const QString& filepath) { QDomDocument doc; QFile file(filepath); - QString backup_filename = "/tmp/vmchooser2_backup.xml"; - QFile backup_file(backup_filename); + QFile backup_file(xml_backup_filename); if (!file.open(QIODevice::ReadOnly)) { @@ -322,7 +321,7 @@ QList VSession::readXmlFile(const QString& filepath) { // try to use backup file if (!backup_file.open(QIODevice::ReadOnly)) { if (debugMode) { - qDebug() << "Cannot read backup file " << backup_filename << " either"; + qDebug() << "Cannot read backup file " << xml_backup_filename << " either"; } return retval; } @@ -336,14 +335,14 @@ QList VSession::readXmlFile(const QString& filepath) { } if (debugMode) { - qDebug() << "Used backup file " << backup_filename; + qDebug() << "Used backup file " << xml_backup_filename; } backup_file.close(); } else { // file is valid --> create backup file - QFile::remove(backup_filename); - QFile::copy(filepath, backup_filename); + QFile::remove(xml_backup_filename); + QFile::copy(filepath, xml_backup_filename); } file.close(); @@ -363,70 +362,6 @@ QList VSession::readXmlFile(const QString& filepath) { return retval; } -/** - * - calls xmlfilter.sh to glob a folder for xmls - * -> if no xmlfilter.sh is available, it globs for available xmls - * - reads all xml files and creates for each its own VSession-struct - */ -QList VSession::readXmlDir(const QString& path) { - QList retval; - - if (QFile::exists(filterScript)) { - // run filterScript - // treat every output line as a filename and read it - QProcess myFilterScript; - myFilterScript.start(filterScript, QStringList(path), - QIODevice::ReadOnly); - myFilterScript.waitForFinished(); - while (!myFilterScript.atEnd()) { - QString filename(myFilterScript.readLine()); - filename = filename.trimmed(); - if (QDir::isRelativePath(filename)) { - filename.prepend(path + "/"); - } - retval.append(readXmlFile(filename)); - } - - myFilterScript.close(); - } else { - // iterate over all .xml files in directory (and sub-directories) - // and read them - QDirIterator di(path, - QDirIterator::Subdirectories | - QDirIterator::FollowSymlinks); - while (di.hasNext()) { - if (!di.next().endsWith(".xml")) continue; - - if (!di.fileInfo().isReadable()) { - if (debugMode) qDebug() << "skip" << di.fileInfo().absoluteFilePath() << ": xml not readable, incorrect file permissions"; - continue; - } - - QList vsessionTmp = readXmlFile(di.fileInfo().absoluteFilePath()); - - if (vsessionTmp.isEmpty()) { - if (debugMode) qDebug() << "skip" << di.fileInfo().absoluteFilePath() << ": reading xml failed for some reason"; - continue; - } - - if (!vsessionTmp.first()->isValid()) { - if (debugMode) qDebug() << "skip" << vsessionTmp.first()->shortDescription() << ": vdi/vmdk missing"; - continue; - } - - if (!vsessionTmp.first()->isActive()) { - if (debugMode) qDebug() << "skip" << vsessionTmp.first()->shortDescription() << ": not active"; - continue; - } - - if (debugMode) qDebug() << "added " << vsessionTmp.first()->shortDescription() << " to list"; - - retval.append(vsessionTmp); - } - } - return retval; -} - bool VSession::operator<(const Session& other) const { int p0 = this->priority(); int p1 = other.priority(); -- cgit v1.2.3-55-g7522