/** * Matches (recursively) a modified file against the filter rules (plugin' scripts). If the file is * filtered-in, it'll be saved in the DB. */ void Filter::checkModifiedFile(QString path) { // does the file rely under the watched directory? if (!path.startsWith(m_dir)) return; // if no plugins, nothing to do if (m_plugins.isEmpty()) return; // if a parent filter, the file must first have been // filtered in by the parent, else, remove it from db. if (m_parentP != NULL && !m_db.hasFile(m_parentP->m_filterId, path)) { m_db.removeFile(m_filterId, path); // remove file from db // signal delFile(m_virtualDirectoryPath, path); } else { // if any plugin accepts the file, then save its ref // in the db. Else, if the file was in the db, remove it. if (!checkAndSaveFile(path) && m_db.hasFile(m_filterId, path)) { m_db.removeFile(m_filterId, path); // remove file from db // signal delFile(m_virtualDirectoryPath, path); } } // if children are present, broadcast check for (QVector<Filter *>::iterator i = m_children.begin(); i != m_children.end(); i++) { Filter *fP = (Filter *)(*i); fP->checkModifiedFile(path); } }
void operationThread::dirRound(QString down){ QDirIterator it(down,QDir::AllEntries|QDir::NoDotAndDotDot|QDir::Hidden,QDirIterator::Subdirectories); while (it.hasNext()) { if (canceled) return; while (stopped) msleep(DELAY); if (canceled) return; QFileInfo tmp(it.next()); if (tmp.isDir()&&!tmp.isSymLink()){ if (param->type!=1) mkDir(tmp); } else if(param->type!=1) copyFile(tmp); else delFile(tmp); if (canceled) return; } }
void operationThread::del(){ while(!param->files.isEmpty()){ if (canceled) return; if (param->files.first().isDir()&&!param->files.first().isSymLink()){ dirRound(param->files.first().absoluteFilePath()); QString dirName=param->files.first().absoluteFilePath(); system("rm -rf \""+dirName.toLocal8Bit()+"\""); } else delFile(param->files.first()); if (canceled) return; param->files.pop_front(); } //удалить пустые каталоги }
/** * Removes any potentially retained deleted file from the db. */ void Filter::checkDeletedFile(QString path) { // does the file rely under the watched directory? if (!path.startsWith(m_dir)) return; // if no plugins, nothing to do if (m_plugins.isEmpty()) return; // just drop the file reference if it had previously been saved in the db if (m_db.hasFile(m_filterId, path)) { m_db.removeFile(m_filterId, path); // remove file from db // signal delFile(m_virtualDirectoryPath, path); // if children are present, broadcast check for (QVector<Filter *>::iterator i = m_children.begin(); i != m_children.end(); i++) { Filter *fP = (Filter *)(*i); fP->checkDeletedFile(path); } } }
void toProjectTemplate::insertItems(toTreeWidget *parent, QToolBar *toolbar) { Root = new toProjectTemplateItem(parent, Import[""], false); Root->setOpen(true); int id = 1; std::map<QString, QString>::iterator i; std::map<int, toProjectTemplateItem *> itemMap; toProjectTemplateItem *last = NULL; while ((i = Import.find(QString("Items:") + QString::number(id).toLatin1() + ":Parent")) != Import.end()) { QString nam = QString("Items:") + QString::number(id).toLatin1() + ":"; int parent = (*i).second.toInt(); if (parent) last = new toProjectTemplateItem(itemMap[parent], last, Import[nam + "0"], false); else last = new toProjectTemplateItem(Root, last, Import[nam + "0"], false); if (!Import[nam + "Open"].isEmpty()) last->setOpen(true); itemMap[id] = last; id++; } connect(parent, SIGNAL(selectionChanged(toTreeWidgetItem *)), this, SLOT(changeItem(toTreeWidgetItem *))); AddFile = toolbar->addAction(QIcon(QPixmap(const_cast<const char**>(addproject_xpm))), qApp->translate("toProject", "Add file to project"), this, SLOT(addFile())); DelFile = toolbar->addAction(QIcon(QPixmap(const_cast<const char**>(trash_xpm))), qApp->translate("toProject", "Remove file from project"), this, SLOT(delFile())); AddFile->setEnabled(false); DelFile->setEnabled(false); }
void Performance::run( std::vector<TC *> algs, //< Algorithms to be executed std::vector<Input> changes, //< Changes as defined in project description std::string output_prefix) //< e.g. output/changefile3-ins.stat { // Open output streams std::ofstream insFile(outputDir + output_prefix + insSuffix); std::ofstream delFile(outputDir + output_prefix + delSuffix); std::ofstream queryFile(outputDir + output_prefix + querySuffix); // unsigned int querySize; long long cpuClock; for (auto &alg : algs) { const char *name = alg->get_name(); std::string strName(name, strlen(name)); std::ofstream queryOutFile(outputDir + output_prefix + strName + queryOutSuffix); for (auto &change : changes) { switch (change.type) { case 4: alg->jump(change.state); break; case 3: alg->init(change.i); break; case 2: // Reset counters ioctl(this->fd, PERF_EVENT_IOC_RESET, PERF_IOC_FLAG_GROUP); // Start counting ioctl(this->fd, PERF_EVENT_IOC_ENABLE, PERF_IOC_FLAG_GROUP); // Run query querySize = alg->query(); // Stop counting ioctl(this->fd, PERF_EVENT_IOC_DISABLE, PERF_IOC_FLAG_GROUP); // Get CPU clock count cpuClock = _get(PERF_TYPE_SOFTWARE, PERF_COUNT_SW_CPU_CLOCK); // Write cpu time queryFile << name << "," << cpuClock << "\n"; // Write output (for correctness) queryOutFile << querySize << "\n"; break; case 1: // Reset counters ioctl(this->fd, PERF_EVENT_IOC_RESET, PERF_IOC_FLAG_GROUP); // Start counting ioctl(this->fd, PERF_EVENT_IOC_ENABLE, PERF_IOC_FLAG_GROUP); // Run query alg->del(change.i, change.j); // Stop counting ioctl(this->fd, PERF_EVENT_IOC_DISABLE, PERF_IOC_FLAG_GROUP); // Get CPU clock count cpuClock = _get(PERF_TYPE_SOFTWARE, PERF_COUNT_SW_CPU_CLOCK); // Write cpu time delFile << name << "," << cpuClock << "\n"; break; case 0: // Reset counters ioctl(this->fd, PERF_EVENT_IOC_RESET, PERF_IOC_FLAG_GROUP); // Start counting ioctl(this->fd, PERF_EVENT_IOC_ENABLE, PERF_IOC_FLAG_GROUP); // Run query alg->ins(change.i, change.j); // Stop counting ioctl(this->fd, PERF_EVENT_IOC_DISABLE, PERF_IOC_FLAG_GROUP); // Get CPU clock count cpuClock = _get(PERF_TYPE_SOFTWARE, PERF_COUNT_SW_CPU_CLOCK); // Write cpu time insFile << name << "," << cpuClock << "\n"; break; default: std::cout << "ERROR!!" << std::endl; // Close all files queryOutFile.close(); insFile.close(); delFile.close(); queryFile.close(); return; } } queryOutFile.close(); } insFile.close(); delFile.close(); queryFile.close(); }
toProject::toProject(toProjectTemplateItem *top, QWidget *parent) : QWidget(parent) { Root = top; QVBoxLayout *vbox = new QVBoxLayout; vbox->setSpacing(0); vbox->setContentsMargins(0, 0, 0, 0); QToolBar *toolbar = toAllocBar(this, tr("SQL project")); vbox->addWidget(toolbar); toolbar->addAction(QIcon(QPixmap(const_cast<const char**>(addproject_xpm))), tr("Add file to project"), this, SLOT(addFile())); toolbar->addAction(QIcon(QPixmap(const_cast<const char**>(filesave_xpm))), tr("Save project"), this, SLOT(saveProject())); DelFile = toolbar->addAction(QIcon(QPixmap(const_cast<const char**>(trash_xpm))), tr("Remove file from project"), this, SLOT(delFile())); toolbar->addSeparator(); toolbar->addAction(QIcon(QPixmap(const_cast<const char**>(new_xpm))), tr("Add new subproject"), this, SLOT(newProject())); toolbar->addAction(QIcon(QPixmap(const_cast<const char**>(sql_xpm))), tr("Generate SQL for this project"), this, SLOT(generateSQL())); toolbar->addSeparator(); toolbar->addAction(QIcon(QPixmap(const_cast<const char**>(up_xpm))), tr("Move up in project"), this, SLOT(moveUp())); toolbar->addAction(QIcon(QPixmap(const_cast<const char**>(down_xpm))), tr("Move down in project"), this, SLOT(moveDown())); toolbar->addWidget(new toSpacer()); Project = new toListView(this); Project->addColumn(tr("File")); Project->addColumn(tr("Size")); Project->setSelectionMode(toTreeWidget::Single); Project->setRootIsDecorated(true); Project->setSorting(0); connect(Project, SIGNAL(selectionChanged()), this, SLOT(selectionChanged())); vbox->addWidget(Project); setLayout(vbox); update(); }