void aBackup::cleanupTmpFiles(const QString& tmpDirName, QStringList *files) { QFile file; QDir dir; file.setName(QDir::convertSeparators(tmpDirName+"/content.xml")); aLog::print(aLog::Debug, tr("aBackup delete file %1").arg(file.name())); file.remove(); file.setName(QDir::convertSeparators(tmpDirName+"/busines-schema.cfg")); aLog::print(aLog::Debug, tr("aBackup delete file %1").arg(file.name())); file.remove(); file.setName(QDir::convertSeparators(tmpDirName+"/META-INF/manifest.xml")); aLog::print(aLog::Debug, tr("aBackup delete file %1").arg(file.name())); file.remove(); for(uint i=0; i<files->count(); i++) { file.setName(QDir::convertSeparators(tmpDirName + "/templates/"+ (*files)[i])); aLog::print(aLog::Debug, tr("aBackup delete file %1").arg(file.name())); file.remove(); } aLog::print(aLog::Debug, tr("aBackup delete directory %1").arg(tmpDirName + "/META-INF")); dir.rmdir(QDir::convertSeparators(tmpDirName + "/META-INF")); aLog::print(aLog::Debug, tr("aBackup delete directory %1").arg(tmpDirName + "/templates")); dir.rmdir(QDir::convertSeparators(tmpDirName + "/templates")); aLog::print(aLog::Debug, tr("aBackup delete directory %1").arg(tmpDirName)); dir.rmdir(QDir::convertSeparators(tmpDirName)); aLog::print(aLog::Info, tr("aBackup cleanup temporary files")); }
/*! Open a new backup (encrypted or unencrypted) and sets the location * * \return success, failed or what else */ Backup::Status Backup::open() { QProcess process; QDir dir; switch (m_encryption) { case Backup::NotEncrypted: dir.setPath(m_origin); if (!dir.exists()) { m_errorString = tr("Directory does not exist or is not accessible."); return Backup::Failed; } m_location = m_origin; break; case Backup::EncFSEncrypted: m_location = findUsableMountPoint(); dir.mkpath(m_location); // start encfs as daemon, reading password from stdin process.start("encfs", QStringList() << "--stdinpass" << "--standard" << m_origin << m_location); if (process.waitForStarted() == false) { m_errorString = process.errorString(); m_rc = process.exitCode(); dir.rmdir(m_location); return Backup::CouldNotStarted; } process.write(m_password.toUtf8()); process.closeWriteChannel(); process.waitForFinished(); m_errorString = QString::fromLocal8Bit(process.readAllStandardOutput().append(process.readAllStandardError())); m_rc = process.exitCode(); if (process.exitStatus() != QProcess::NormalExit) { m_rc = 1; } if (m_rc != 0) { dir.rmdir(m_location); return Backup::Failed; } break; default: return Backup::Failed; break; } m_isOpen = true; return Backup::Success; }
//清除程序临时文件 void CardDoc::removeTempFile(const QString& path) { QDir dir; bool exist = dir.exists(path); if (exist) { QDir dirTmp(path); QFileInfoList list = dirTmp.entryInfoList(); //遍历删除目录下的文件 for (int i = 0; i < list.size(); ++i) { if(list.at(i).fileName() == "." || list.at(i).fileName() == "..") { continue; } dirTmp.remove(list.at(i).fileName()); } //删除tmp文件夹 dir.rmdir(path); } }
void Archive::loadExtractedBaskets(const QString &extractionFolder, QDomNode &basketNode, QMap<QString, QString> &folderMap, Basket *parent) { bool basketSetAsCurrent = (parent != 0); QDomNode n = basketNode; while ( ! n.isNull() ) { QDomElement element = n.toElement(); if ( (!element.isNull()) && element.tagName() == "basket" ) { QString folderName = element.attribute("folderName"); if (!folderName.isEmpty()) { // Move the basket folder to its destination, while renaming it uniquely: QString newFolderName = folderMap[folderName]; FormatImporter copier; // The folder has been "reserved" by creating it. Avoid asking the user to override: QDir dir; dir.rmdir(Global::basketsFolder() + newFolderName); copier.moveFolder(extractionFolder + "baskets/" + folderName, Global::basketsFolder() + newFolderName); // Append and load the basket in the tree: Basket *basket = Global::bnpView->loadBasket(newFolderName); BasketListViewItem *basketItem = Global::bnpView->appendBasket(basket, (basket && parent ? Global::bnpView->listViewItemForBasket(parent) : 0)); basketItem->setExpanded(!XMLWork::trueOrFalse(element.attribute("folded", "false"), false)); QDomElement properties = XMLWork::getElement(element, "properties"); importBasketIcon(properties, extractionFolder); // Rename the icon fileName if necessary basket->loadProperties(properties); // Open the first basket of the archive: if (!basketSetAsCurrent) { Global::bnpView->setCurrentBasket(basket); basketSetAsCurrent = true; } QDomNode node = element.firstChild(); loadExtractedBaskets(extractionFolder, node, folderMap, basket); } } n = n.nextSibling(); } }
bool FacilityLib::rmpath(const QDir &dir) { if(!dir.exists()) return true; bool allHaveWork=true; QFileInfoList list = dir.entryInfoList(QDir::AllEntries|QDir::NoDotAndDotDot|QDir::Hidden|QDir::System,QDir::DirsFirst); for (int i = 0; i < list.size(); ++i) { QFileInfo fileInfo(list.at(i)); if(!fileInfo.isDir()) { if(!QFile(fileInfo.absoluteFilePath()).remove()) allHaveWork=false; } else { //return the fonction for scan the new folder if(!FacilityLib::rmpath(dir.absolutePath()+FacilityLib::text_slash+fileInfo.fileName()+FacilityLib::text_slash)) allHaveWork=false; } } if(!allHaveWork) return false; allHaveWork=dir.rmdir(dir.absolutePath()); return allHaveWork; }
// We could port this to KTempDir::removeDir but then we wouldn't be able to tell the user // where exactly the deletion failed, in case of errors. bool FileProtocol::deleteRecursive(const QString& path) { //kDebug() << path; QDirIterator it(path, QDir::AllEntries | QDir::NoDotAndDotDot | QDir::System | QDir::Hidden, QDirIterator::Subdirectories); QStringList dirsToDelete; while ( it.hasNext() ) { const QString itemPath = it.next(); //kDebug() << "itemPath=" << itemPath; const QFileInfo info = it.fileInfo(); if (info.isDir() && !info.isSymLink()) dirsToDelete.prepend(itemPath); else { //kDebug() << "QFile::remove" << itemPath; if (!QFile::remove(itemPath)) { error(KIO::ERR_CANNOT_DELETE, itemPath); return false; } } } QDir dir; Q_FOREACH(const QString& itemPath, dirsToDelete) { //kDebug() << "QDir::rmdir" << itemPath; if (!dir.rmdir(itemPath)) { error(KIO::ERR_CANNOT_DELETE, itemPath); return false; } } return true; }
CardDoc::~CardDoc() { //removeTempFile(); QDir dir; bool exist = dir.exists("tmp"); if (exist) { QDir dirTmp("tmp//"); QFileInfoList list = dirTmp.entryInfoList(); //遍历删除目录下的文件 for (int i = 0; i < list.size(); ++i) { if(list.at(i).fileName() == "." || list.at(i).fileName() == "..") { continue; } dirTmp.remove(list.at(i).fileName()); } //删除tmp文件夹 dir.rmdir("tmp"); } }
// delete all entries of the specified dir void SettingsDialog::deleteEntriesOfDir(const QDir& dir) { // Delete files of the dir { QFileInfoList filesInfoList= dir.entryInfoList(QDir::Files); const int size= filesInfoList.size(); for (int i= 0; i < size; ++i) { QFile currentFile(filesInfoList.at(i).filePath()); currentFile.remove(); } } // Delete sub dir of the dir { QFileInfoList subDirInfoList= dir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot ); const int size= subDirInfoList.size(); for (int i= 0; i < size; ++i) { QDir subDir(subDirInfoList.at(i).filePath()); deleteEntriesOfDir(subDir); dir.rmdir(subDir.dirName()); } } }
void FileMover::moveFilesWhenRollback(const QMap<QString,Element> &tomove,const QMap<QString,Element> & todelete, QString prjNum) { QDir dir; for(auto it=todelete.cend();it!=todelete.cbegin();){ it--; qDebug()<<"delete from "+_originPath+it.value().getPath(); if(!it.value().isFolder()) QFile::remove(_originPath+it.value().getPath()); else dir.rmdir(_originPath+it.value().getPath()); } /*for(auto elem:todelete.cend()){ qDebug()<<"delete from "+_originPath+elem.getPath(); if(!elem.isFolder()) QFile::remove(_originPath+elem.getPath()); else dir.rmdir(_originPath+elem.getPath()); }*/ for(auto elem:tomove){ QString from=_storagePath+"Project "+prjNum+ "/Version " + QString::number(elem.getVersionId()) + +"/changed" + elem.getPath(); QString to=_originPath+elem.getPath(); qDebug()<<"copy from "<<from<<" to "<<to; if(!elem.isFolder()) FileMover::copyFile(from,to); else dir.mkdir(_originPath+elem.getPath()); } }
bool MythRemoveDirectory(QDir &aDir) { if (!aDir.exists())//QDir::NoDotAndDotDot return false; QFileInfoList entries = aDir.entryInfoList(QDir::NoDotAndDotDot | QDir::Dirs | QDir::Files); int count = entries.size(); bool has_err = false; for (int idx = 0; idx < count && !has_err; idx++) { QFileInfo entryInfo = entries[idx]; QString path = entryInfo.absoluteFilePath(); if (entryInfo.isDir()) { QDir dir(path); has_err = MythRemoveDirectory(dir); } else { QFile file(path); if (!file.remove()) has_err = true; } } if (!has_err && !aDir.rmdir(aDir.absolutePath())) has_err = true; return(has_err); }
bool MainWindow::rmpath(const QDir &dir) { if(!dir.exists()) return true; bool allHaveWork=true; QFileInfoList list = dir.entryInfoList(QDir::AllEntries|QDir::NoDotAndDotDot|QDir::Hidden|QDir::System,QDir::DirsFirst); for (int i = 0; i < list.size(); ++i) { QFileInfo fileInfo(list.at(i)); if(!fileInfo.isDir()) { if(!QFile(fileInfo.absoluteFilePath()).remove()) { qDebug() << "Unable the remove the file: " << fileInfo.absoluteFilePath(); allHaveWork=false; } } else { //return the fonction for scan the new folder if(!rmpath(dir.absolutePath()+'/'+fileInfo.fileName()+'/')) allHaveWork=false; } } if(!allHaveWork) return allHaveWork; if(!dir.rmdir(dir.absolutePath())) { qDebug() << "Unable the remove the file: " << dir.absolutePath(); return false; } return true; }
void medDatabaseRemover::removePatient ( int patientDbId ) { QSqlDatabase db(d->db); QSqlQuery query ( db ); QString patientName; QString patientBirthdate; QString patientId; query.prepare ( "SELECT thumbnail, patientId FROM " + d->T_PATIENT + " WHERE id = :patient " ); query.bindValue ( ":patient", patientDbId ); EXEC_QUERY ( query ); if ( query.next() ) { QString thumbnail = query.value ( 0 ).toString(); this->removeFile ( thumbnail ); patientId = query.value ( 1 ).toString(); } if( removeTableRow ( d->T_PATIENT, patientDbId ) ) emit removed(medDataIndex(1, patientDbId, -1, -1, -1)); medDatabaseController * dbi = medDatabaseController::instance(); QDir patientDir ( medStorage::dataLocation() + "/" + dbi->stringForPath ( patientId ) ); if ( patientDir.exists() ) patientDir.rmdir ( patientDir.path() ); // only removes if empty }
/** remplace QDir::rmpath() because it return false if the folder not exists and seam bug with parent folder */ bool copyEngineUnitTester::rmpath(const QDir &dir) { if(!dir.exists()) return true; bool allHaveWork=true; QFileInfoList list = dir.entryInfoList(QDir::AllEntries|QDir::NoDotAndDotDot|QDir::Hidden|QDir::System,QDir::DirsFirst); for (int i = 0; i < list.size(); ++i) { QFileInfo fileInfo(list.at(i)); if(!fileInfo.isDir()) { ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,"found a file: "+fileInfo.fileName()); allHaveWork=false; } else { //return the fonction for scan the new folder if(!rmpath(dir.absolutePath()+'/'+fileInfo.fileName()+'/')) allHaveWork=false; } } if(!allHaveWork) return allHaveWork; allHaveWork=dir.rmdir(dir.absolutePath()); if(!allHaveWork) ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,"unable to remove the folder: "+dir.absolutePath()); return allHaveWork; }
/*递归删除文件夹内容 ** **dir :文件夹的名字,绝对路径和相对路径均可 ** **返回值 :成功后返回true;否则返回false */ bool removeFileWithDir(const QString &dirName) { static QVector<QString> dirNames; QDir dir; QFileInfoList filst; QFileInfoList::iterator curFi; //初始化 dirNames.clear(); if(dir.exists()){ dirNames<<dirName; } else{ return true; } //遍历各级文件夹,并将这些文件夹中的文件删除 for(int i=0;i<dirNames.size();++i) { dir.setPath(dirNames[i]); filst=dir.entryInfoList(QDir::Dirs|QDir::Files |QDir::Readable|QDir::Writable |QDir::Hidden|QDir::NoDotAndDotDot ,QDir::Name); if(filst.size()>0) { curFi=filst.begin(); while(curFi!=filst.end()) { //遇到文件夹,则添加至文件夹列表dirs尾部 if(curFi->isDir()) { dirNames.push_back(curFi->filePath()); } else if(curFi->isFile()) { //遇到文件,则删除之 if(!dir.remove(curFi->fileName())) { //return false; } } curFi++; }//end of while } } #if 0 //删除文件夹 for(int i=dirNames.size()-1;i>=0;--i) { if(!dir.rmdir(dirNames[i])) { //return false; } } #endif return true; }
void set_user_id(int i) { if ((Uid > 0) && BrowserView::get_project()) { QDir dir = BrowserView::get_dir(); dir.rmdir(QString::number(Uid) + ".lock"); } Uid = i; }
void XMLMoveThread::DelSDPicFile() { //qDebug()<<tr("删除图片开始"); QDir dir; if(!dir.exists("/SDHC")) { LogMsg("lane", tr("未检测到SD卡,不执行SD卡文件清理操作")); //qDebug()<<tr("未检测到SD卡,不执行SD卡文件清理操作"); return; } QString dirName = "/SDHC/PicFile"; if(!dir.exists(dirName)) { LogMsg("lane", tr("SD中不存在图片备份,不执行SD卡文件清理操作")); //qDebug()<<tr("SD中不存在图片备份,不执行SD卡文件清理操作"); return; } QDate curDate = QDateTime::currentDateTime().addDays(-getLaneInfo()->getPicSaveDay()).date(); QString tmpFileName = curDate.toString("MMdd"); dir.setPath(dirName); QFileInfoList dirList = dir.entryInfoList(QDir::Dirs,QDir::Time); QFileInfo dirInfo; int count = dirList.count(); for(int i = count - 1;i > 0;i--) { //qDebug()<<tr("SD卡图片文件夹数量:%1").arg(count); //保留一个文件夹 // if(count <= 3) // { // qDebug()<<tr("保留一个文件夹"); // return; // } dirInfo = dirList.at(i); if(!dirInfo.fileName().startsWith(".") && dirInfo.created().date() <= curDate) //if(dirInfo.fileName() == tmpFileName) { tmpFileName = dirInfo.fileName(); //qDebug()<<tr("确定要删除文件目录:%1").arg(tmpFileName); dir.setPath(dirName + "/" + tmpFileName); QFileInfoList fileList = dir.entryInfoList(QDir::Files,QDir::Time); for(int i = 0;i < fileList.count();i++) { if(!dir.exists("/SDHC")) { LogMsg("lane", tr("文件清理过程中检测不到SD卡")); //qDebug()<<tr("文件清理过程中检测不到SD卡"); return; } QFile::remove(fileList.at(i).filePath()); } dir.rmdir(dirInfo.filePath()); //count --; } } }
void cleanupTestCase() { { QDir testdir(QDir::tempPath() + QLatin1String("/test_speed")); foreach (const QString &filename, testdir.entryList()) { testdir.remove(filename); } } const QDir temp = QDir(QDir::tempPath()); temp.rmdir(QLatin1String("test_speed")); }
rm::rm(QString cmd) { QTextStream out (stdout); QString dirNAME = cmd.mid(3); QDir path; if(cmd.contains(".txt")) path.remove(dirNAME); else if(cmd.contains(" -r")) path.removeRecursively(); else path.rmdir(dirNAME); }
void rmdir(const QString &file) { #ifdef Q_OS_WIN QDir dir; dir.rmdir(file); #else QString cmd = QString("rmdir %1").arg(file); qDebug() << "Command: " << cmd; system(cmd.toLocal8Bit()); #endif }
void RepositoryProfile::removeDirectory ( const QString& path ) { QDir dir ( path ); if ( !dir.exists() ) // nothing to delete return; clearDirectory ( path ); if ( !dir.rmdir ( path ) ) qDebug ( "could not remove directory: %s", qPrintable ( path ) ); }
bool fs::dir(const QString &opt, const QString &path){ QDir dir; if(opt == "create"){ return dir.mkdir(path); } else if(opt == "remove"){ return dir.rmdir(path); } else{ return false; } }
void MainForm::delTmpDir() { QDir dir; dir.setPath(workingDir + "output_files"); dir.setFilter(QDir::Files | QDir::NoSymLinks); for (uint i = 0; i < dir.count(); i++) { if (dir[i].endsWith("jpg") || dir[i].endsWith("bmp")) dir.remove(dir[i]); } dir.rmdir(workingDir + "output_files"); }
void InfoTemplate::on_generateButton_clicked() { if (iTitleList.count()==0) { QMessageBox::information(this,"No topics added!" , "Please add some topics, and content before generating the application!"); return; } QDir dir; dir.mkdir("assets"); QFile indexFile("assets/index.txt"); indexFile.open(QIODevice::WriteOnly | QIODevice::Text); QTextStream out(&indexFile); for (int i=0; i<iTitleList.count(); i++) { out << iTitleList.at(i); out << "\n"; } indexFile.close(); // qDebug()<<iDescriptionList; for (int i=0;i<iDescriptionList.count(); i++) { QFile file("assets/"+ iTitleList.at(i)+".txt"); file.open(QIODevice::WriteOnly | QIODevice::Text); QTextStream out(&file); out << iDescriptionList.at(i); file.close(); } execWindowsCommand("copy config\\templates\\BuildmLearnInfo.apk config\\BuildmLearnInfo_in_use.zip"); execWindowsCommand("config\\templates\\7za.exe a config\\BuildmLearnInfo_in_use.zip assets"); execWindowsCommand("config\\templates\\signapk.jar config\\templates\\certificate.pem config\\templates\\key.pk8 config\\BuildmLearnInfo_in_use.zip applications\\BuildmLearnInfo_signed.apk"); execWindowsCommand("del config\\BuildmLearnInfo_in_use.zip"); // delete temp files for (int i=0;i<iDescriptionList.count(); i++) { QFile file("assets/"+ iTitleList.at(i)+".txt"); file.remove(); } indexFile.remove(); dir.rmdir("assets"); QMessageBox::information(this,"Application generated" , "Your application has been generated. For the installation file, please check /applications folder. "); }
bool PackageProcessor::CleanupDir (const QString& directory) { #ifndef QT_NO_DEBUG qDebug () << Q_FUNC_INFO << directory; #endif QDir dir (directory); for (const auto& subdir : dir.entryList (QDir::Dirs | QDir::NoDotAndDotDot)) if (!CleanupDir (dir.absoluteFilePath (subdir))) { qWarning () << Q_FUNC_INFO << "failed to cleanup subdir" << subdir << "for" << directory; return false; } for (const auto& entry : dir.entryList (QDir::Files | QDir::Hidden | QDir::System)) if (!dir.remove (entry)) { qWarning () << Q_FUNC_INFO << "failed to remove file" << entry << "for dir" << directory; return false; } const auto& dirName = dir.dirName (); if (!dir.cdUp ()) { qWarning () << Q_FUNC_INFO << "cannot cd up from" << directory; return false; } const auto res = dir.rmdir (dirName); if (!res) qWarning () << Q_FUNC_INFO << "cannot remove directory" << dirName << "from parent" << dir.absolutePath (); return res; }
void DeleteDirectory(QDir &dir) { QFileInfoList files = dir.entryInfoList(QDir::Files | QDir::NoDotAndDotDot); for(unsigned i = 0; i != (unsigned) files.size(); ++i) { dir.remove(files.at(i).fileName()); } QFileInfoList subdirs = dir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot); for(unsigned i = 0; i != (unsigned) subdirs.size(); ++i) { dir.cd(subdirs.at(i).fileName()); DeleteDirectory(dir); } QString current = dir.dirName(); dir.cdUp(); dir.rmdir(current); }
QString Serializer::createDirectory(const Id &id, bool logical) const { QString dirName = mWorkingDir + "/tree"; dirName += logical ? "/logical" : "/graphical"; const QStringList partsList = id.toString().split('/'); Q_ASSERT(partsList.size() >= 1 && partsList.size() <= 5); for (int i = 1; i < partsList.size() - 1; ++i) { dirName += "/" + partsList[i]; } QDir dir; dir.rmdir(mWorkingDir); dir.mkpath(dirName); return dirName + "/" + partsList[partsList.size() - 1]; }
void Project::removeTempDirectory() { mDbAdapter->close(); QDir tempDir = getTempDir(); tempDir.setNameFilters(QStringList("*")); QStringList files = tempDir.entryList(QDir::Files,QDir::Name); for(int i=0; i<files.count(); i++) { QFile f( tempDir.absoluteFilePath( files.at(i) ) ); if( ! f.remove() ) qWarning() << f.errorString() << tempDir.absoluteFilePath( files.at(i) ) ; } tempDir.cdUp(); tempDir.rmdir( tempDirName() ); }
void QtUtils::emptyDir(QDir &dir) { foreach (const QString &folder, dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot | QDir::NoSymLinks)) { QDir subdir(dir); bool success = subdir.cd(folder); if (!success) qFatal("cd failure."); emptyDir(subdir); } foreach (const QString &file, dir.entryList(QDir::Files)) dir.remove(file); foreach (const QString &folder, dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot | QDir::NoSymLinks)) dir.rmdir(folder); foreach (const QString &symlink, dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot)) dir.remove(symlink); }
void MainWindow::on_pushButton_Lancer_clicked() { ui->label_fichierEnCours->show(); ui->label_Wait->show(); ui->pushButton_Lancer->setEnabled(false); ui->pushButton_Source->setEnabled(false); ui->pushButton_Destination->setEnabled(false); changerMode(false); ui->pushButton_Quitter->setEnabled(false); ui->progressBar->setMaximum(fichiersSupprDestination.length()+dossiersSupprDestination.length()+dossiersVersSource.length()+dossiersVersDestination.length()+fichiersVersSource.length()+fichiersVersDestination.length()); QDir doss; //Suppression fichiers destination if(!fichiersSupprDestination.isEmpty()){ for(int x=0;x<fichiersSupprDestination.length();x++){ ui->progressBar->setValue(ui->progressBar->value()+1); doss.remove(destination+fichiersSupprDestination[x]); } } //Suppression dossiers destination if(!dossiersSupprDestination.isEmpty()){ for(int x=0;x<dossiersSupprDestination.length();x++){ ui->progressBar->setValue(ui->progressBar->value()+1); doss.rmdir(destination+dossiersSupprDestination[x]); } } //Création dossiers vers source if(!dossiersVersSource.isEmpty()){ for(int x=0;x<dossiersVersSource.length();x++){ ui->progressBar->setValue(ui->progressBar->value()+1); doss.mkdir(source+dossiersVersSource[x]); } } //Création dossiers vers destination if(!dossiersVersDestination.isEmpty()){ for(int x=0;x<dossiersVersDestination.length();x++){ ui->progressBar->setValue(ui->progressBar->value()+1); doss.mkdir(destination+dossiersVersDestination[x]); } } on_finCopieSource(); }
void DelProject::sureDelPro() { QModelIndex index = m_ui->listView->currentIndex(); QString projectName = pathModel->stringList().at(index.row()); QStringList fileToDel; if(projectName == "linux-0.11") { QMessageBox::warning(this, "提示", "无法删除此工程\n" "如果确实要删除,请到程序程序目录下" "oslab/codeview/project目录下删除linux-0.11文件夹"); return; } if (!index.isValid()) return; fileToDel += QString("project") + QDir::separator() + projectName + QDir::separator() + "func.txt"; fileToDel += QString("project") + QDir::separator() + projectName + QDir::separator() + "simple.txt"; fileToDel += QString("project") + QDir::separator() + projectName + QDir::separator() + "struct.txt"; fileToDel += QString("project") + QDir::separator() + projectName + QDir::separator() + "dcpt.txt"; fileToDel += QString("project") + QDir::separator() + projectName + QDir::separator() + "path.txt"; QDir dir; for(int i = 0; i < fileToDel.count(); i++) { if(dir.exists(fileToDel.at(i))) if(!dir.remove(fileToDel.at(i))) { QMessageBox::information(this, "错误", "删除工程文件失败"); return; } } if(!dir.rmdir(QString("project") + QDir::separator() + projectName)) { QMessageBox::information(this, "错误", "删除工程目录失败"); return; } allProject.removeAt(index.row()); pathModel->setStringList(allProject); m_ui->listView->setModel(pathModel); m_ui->lineEdit->clear(); emit projectRemoved(projectName); }