int mergeMain(int argc, char** argv) { parseMergeOptions(argc, argv); StringVector inFiles; while(optind < argc) { inFiles.push_back(argv[optind++]); } assert(inFiles.size() == 2); if(inFiles[0] == inFiles[1]) return 0; // avoid self-merge std::string prefix1 = stripFilename(inFiles[0]); std::string prefix2 = stripFilename(inFiles[1]); if(opt::prefix.empty()) { opt::prefix = prefix1 + "." + prefix2; } // Merge the indices if(opt::bMergeForward) { mergeIndependentIndices(inFiles[0], inFiles[1], opt::prefix, BWT_EXT, SAI_EXT, false, opt::numThreads, opt::gapArrayStorage); } // Skip merging the reverse indices if the reverse bwt file does not exist. std::string rbwt_filename_1 = prefix1 + RBWT_EXT; std::string rbwt_filename_2 = prefix2 + RBWT_EXT; struct stat file_s_1; struct stat file_s_2; int ret1 = stat(rbwt_filename_1.c_str(), &file_s_1); int ret2 = stat(rbwt_filename_2.c_str(), &file_s_2); if((ret1 == 0 || ret2 == 0) && opt::bMergeReverse) { mergeIndependentIndices(inFiles[0], inFiles[1], opt::prefix, RBWT_EXT, RSAI_EXT, true, opt::numThreads, opt::gapArrayStorage); } // Merge the read files if(opt::bMergeSequence) { mergeReadFiles(inFiles[0], inFiles[1], opt::prefix); } if(opt::bRemove) { // Delete the original reads, bwt and sai files removeFiles(inFiles[0]); removeFiles(inFiles[1]); } return 0; }
void CDiskWriteSlaveActivityBase::close() { try { if (out) { uncompressedBytesWritten = out->getPosition(); if (calcFileCrc) { if (diskHelperBase->getFlags() & TDWextend) { assertex(!"TBD need to merge CRC"); } else out->flush(&fileCRC); } else if (!abortSoon) out->flush(); out.clear(); } else if (outraw) { outraw->flush(); uncompressedBytesWritten = outraw->tell(); outraw.clear(); } { CriticalBlock block(statsCs); mergeStats(fileStats, outputIO); outputIO.clear(); } if (!rfsQueryParallel && dlfn.isExternal() && !lastNode()) { rowcount_t rows = processed & THORDATALINK_COUNT_MASK; ActPrintLog("External write done, signalling next (row count = %" RCPF "d)", rows); CMessageBuffer msg; msg.append(rows); msg.append(tempExternalName); queryJobChannel().queryJobComm().send(msg, queryJobChannel().queryMyRank()+1, mpTag); } } catch (IException *e) { ActPrintLogEx(&queryContainer(), e, thorlog_null, MCwarning, "Error closing file: %s", fName.get()); abortSoon = true; removeFiles(); throw e; } if (abortSoon) removeFiles(); }
Upload::Upload(QWidget *parent) : QDialog(parent), ui(new Ui::Upload) { ui->setupUi(this); ui->immediatleyButton->setChecked(true); connect(ui->addButton, SIGNAL(clicked()), this, SLOT(addClicked())); connect(ui->deleteButton, SIGNAL(clicked()), this, SLOT(deleteClicked())); connect(ui->transmitButton, SIGNAL(clicked()), this, SLOT(transmitClicked())); connect(this, SIGNAL(removeFiles(QString, QStringList)), parentWidget(), SLOT(removeFiles(QString, QStringList))); connect(this, SIGNAL(uploadFiles(QString, QStringList)), parentWidget(), SLOT(uploadFiles(QString, QStringList))); fileSizeMap.clear(); }
Error Plot::renderFromDisplay() { // we can use our cached representation if we don't need an update and our // rendered size is the same as the current graphics device size if ( !needsUpdate_ && (renderedSize() == graphicsDevice_.displaySize()) ) { return Success(); } // generate a new storage uuid std::string storageUuid = core::system::generateUuid(); // generate snapshot and image files Error error = graphicsDevice_.saveSnapshot(snapshotFilePath(storageUuid), imageFilePath(storageUuid)); if (error) return Error(errc::PlotRenderingError, error, ERROR_LOCATION); // save rendered size renderedSize_ = graphicsDevice_.displaySize(); // save manipulator (if any) saveManipulator(storageUuid); // delete existing files (if any) Error removeError = removeFiles(); // update state storageUuid_ = storageUuid; needsUpdate_ = false; // return error status return removeError; }
void backupfsExit (bkupInfo* info, int exitStatus) { assert(info); closeFiles(info); removeFiles(info); moveFile(info->oldJpath, info->jpath); exit(exitStatus); }
ThreadHandler::ThreadHandler(QObject *parent) : QObject(parent) { aui = new ApplicationUpdateInterface(this); requestHandler = new RequestHandler(this); blackList = new BlackList(this); thumbnailRemoverThread = new QThread(); thumbnailRemover = new ThumbnailRemover(); thumbnailRemover->moveToThread(thumbnailRemoverThread); connect(thumbnailRemoverThread, SIGNAL(started()), thumbnailRemover, SLOT(removeOutdated())); thumbnailRemoverThread->start(QThread::LowPriority); connect(this, SIGNAL(removeFiles(QStringList)), thumbnailRemover, SLOT(removeFiles(QStringList))); settings = new QSettings("settings.ini", QSettings::IniFormat); loadSettings(); connect(requestHandler, SIGNAL(response(QUrl,QByteArray,bool)), this, SLOT(processRequestResponse(QUrl,QByteArray,bool))); connect(requestHandler, SIGNAL(responseError(QUrl,int)), this, SLOT(handleRequestError(QUrl,int))); // connect(downloadManager, SIGNAL(error(QString)), ui->statusBar, SLOT(showMessage(QString))); // connect(downloadManager, SIGNAL(finishedRequestsChanged(int)), this, SLOT(updateDownloadProgress())); // connect(downloadManager, SIGNAL(totalRequestsChanged(int)), this, SLOT(updateDownloadProgress())); connect(aui, SIGNAL(connectionEstablished()), this, SLOT(updaterConnected())); connect(aui, SIGNAL(updateFinished()), this, SLOT(updateFinished())); connect(aui, SIGNAL(updaterVersionSent(QString)), this, SLOT(setUpdaterVersion(QString))); createComponentList(); #ifdef __DEBUG__ createSupervisedDownload(QUrl(QString::fromUtf8("file:d:/Qt/fourchan-dl/webupdate.xml")); #else createSupervisedDownload(QUrl(QString::fromUtf8("http://www.sourceforge.net/projects/fourchan-dl/files/webupdate/webupdate.xml/download"))); #endif autosaveTimer = new QTimer(this); autosaveTimer->setInterval(1000*60*10); // 10 Minutes autosaveTimer->setSingleShot(false); connect(autosaveTimer, SIGNAL(timeout()), this, SLOT(saveSettings())); }
void TagEditor::createActions(){ connect(LoadScriptButton,SIGNAL(clicked()),this,SLOT(loadScript())); connect(SaveScriptButton,SIGNAL(clicked()),this,SLOT(saveScript())); connect(RunScriptButton,SIGNAL(clicked()),this, SLOT(runScript())); QAction* searchOnlineAction = new QAction(tr("Search for selected file/album in online musicdatabases..."), this); searchOnlineAction->setShortcut(tr("Ctrl+S")); connect(searchOnlineAction, SIGNAL(triggered()), this, SLOT(searchOnline())); QAction* searchForFilesAction = new QAction(tr("Search for files to add to workspace..."), this); //searchForFilesAction->setShortcut(tr("Ctrl+S")); connect(searchForFilesAction, SIGNAL(triggered()), this, SLOT(searchAndAddFiles())); TreeView->setContextMenuPolicy(Qt::ActionsContextMenu); TreeView->addAction(searchOnlineAction); TreeView->addAction(searchForFilesAction); connect( TreeView, SIGNAL( expanded( const QModelIndex & ) ), this, SLOT( resizeColumn() ) ); connect( TreeView, SIGNAL( collapsed( const QModelIndex & ) ), this, SLOT( resizeColumn() ) ); //connect( TreeWidget_, SIGNAL( currentRowChanged( int ) ), this, SLOT( showTagInfo(int) ) ); connect( TreeWidget_, SIGNAL( itemSelectionChanged() ), this, SLOT( showTagInfo() ) ); connect( AddButton, SIGNAL( clicked() ), this, SLOT(addFiles() ) ); connect( RemoveButton, SIGNAL( clicked() ), this, SLOT(removeFiles() ) ); connect( ClearButton, SIGNAL( clicked() ), this, SLOT(removeAllFiles() ) ); connect( SaveButton, SIGNAL( clicked() ), this, SLOT(saveTag() ) ); connect( ChooseDirButton, SIGNAL( clicked() ), this, SLOT(chooseDir() ) ); connect( actionSettings, SIGNAL( triggered() ), this, SLOT( showSettings() ) ); connect( actionRewriteTag, SIGNAL( triggered() ), this, SLOT( rewriteTag() ) ); connect( actionRenameFiles, SIGNAL( triggered() ), this, SLOT( renameFiles() ) ); connect( actionReplaceTags, SIGNAL( triggered() ), this, SLOT( replaceTags() ) ); connect( actionSerialize, SIGNAL( triggered() ), this, SLOT( serialize() ) ); connect( actionClearTags, SIGNAL( triggered() ), this, SLOT( clearTags() ) ); //connect( actionRemoveFrames, SIGNAL( triggered() ), this, SLOT( removeFrames() ) ); //styles QSignalMapper *styleMapper = new QSignalMapper(this); QStringList styles = QStyleFactory::keys(); for(int i=0;i<styles.size();i++){ QAction *a = new QAction(styles[i],menuStyle); a->setCheckable(true); connect(a, SIGNAL(triggered()), styleMapper, SLOT(map())); styleMapper->setMapping(a, styles[i]); menuStyle->addAction(a); } menuStyle->addSeparator(); QAction *actionCustomStyleSheet = new QAction("Custom...",menuStyle); actionCustomStyleSheet->setCheckable(true); connect(actionCustomStyleSheet, SIGNAL(triggered()), this, SLOT(openStyleSheet())); menuStyle->addAction( actionCustomStyleSheet ); connect(styleMapper, SIGNAL(mapped(const QString &)), this, SLOT(setGUIStyle(const QString &))); }
uint64_t createFinalStream(std::ostream & out) { flush(); // number of symbols ::libmaus::serialize::Serialize<uint64_t>::serialize(out,symbols); // number of bits per symbol ::libmaus::serialize::Serialize<uint64_t>::serialize(out,b); out.flush(); concatenateBitVectors(filenames,out); removeFiles(); return symbols; }
FileSystemWatcher::~FileSystemWatcher() { if (!d->m_files.isEmpty()) removeFiles(files()); if (!d->m_directories.isEmpty()) removeDirectories(directories()); if (--(d->m_staticData->m_objectCount) == 0) { delete d->m_staticData->m_watcher; d->m_staticData->m_watcher = 0; d->m_staticData->m_fileCount.clear(); d->m_staticData->m_directoryCount.clear(); if (debug) qDebug() << this << "Deleted watcher" << d->m_id; } delete d; }
void UIImageOverview::closeEvent(QCloseEvent *event) { if (running) stop(); // Delete all thumbnails QStringList fileList; for (int i=0; i<ui->listWidget->count(); i++) { fileList.append(tnt->getCacheFile( ui->listWidget->item(i)->text() ) ); } emit removeFiles(fileList); event->accept(); }
void close(IPartDescriptor &partDesc, unsigned &crc, bool addMeta=false) { StringBuffer partFname; getPartFilename(partDesc, 0, partFname); Owned<IException> e; try { if (builder) { if (addMeta && metadata) { builder->finish(metadata, &crc); } else builder->finish(&crc); } } catch (IException *_e) { ActPrintLog(_e, "Error closing file: %s", partFname.str()); abortSoon = true; e.setown(_e); } catch (CATCHALL) { abortSoon = true; e.setown(MakeActivityException(this, 0, "INDEXWRITE: Error closing file: %s - unknown exception", partFname.str())); } try { metadata.clear(); builder.clear(); } catch (IException *_e) { ActPrintLog(_e, "Error closing file: %s", partFname.str()); _e->Release(); } if (abortSoon) removeFiles(partDesc); if (e) throw LINK(e); }
void Upload::transmitClicked() { int i; //remove file from removeList emit removeFiles(ui->directoryText->text(), removeList); //upload file from fileList contains ":/" for(i=0;i<ui->fileList->count();i++) { if(ui->fileList->item(i)->text().contains(":/") || ui->fileList->item(i)->text().startsWith("/")) uploadList<<ui->fileList->item(i)->text(); } makePlaylist(); uploadList << "playlist.txt"; emit uploadFiles(ui->directoryText->text(), uploadList); //TODO change button text to "Cancel" }
WidgetFilesList::WidgetFilesList(QFileInfoList & filesList,QWidget *parent,QString filter,QString infos,bool editable): QWidget(parent),_filesList(filesList), _ui(new Ui::WidgetFilesListClass) { _ui->setupUi(this); _filter = filter; for(int i=0;i<_filesList.size();i++) _ui->filesList->addItem(_filesList.at(i).absoluteFilePath()); setInfos(infos); _editable = editable; if(!editable) { _ui->pushAddFiles->hide(); _ui->pushRemoveFiles->hide(); } connect(_ui->pushAddFiles,SIGNAL(clicked()),this,SLOT(addFiles())); connect(_ui->pushRemoveFiles,SIGNAL(clicked()),this,SLOT(removeFiles())); }
void UIImageOverview::deleteFile(void) { QFile f; QString filename; QString uri; QString cacheFile; filename = ui->listWidget->currentItem()->text(); if (filename != "") { f.setFileName(filename); if (f.exists()) { f.remove(); ui->listWidget->takeItem(ui->listWidget->currentRow()); } if (getUrlOfFilename(filename, &uri)) blackList->add(uri); } cacheFile = tnt->getCacheFile(filename); emit removeFiles(QStringList(cacheFile)); }
int QPlayer::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QMainWindow::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: on_MuButton_clicked(); break; case 1: on_RemoveButton_clicked(); break; case 2: on_pushButton_clicked(); break; case 3: on_StyleButton_clicked(); break; case 4: on_PrevButton_clicked(); break; case 5: on_NextButton_clicked(); break; case 6: on_PauseButton_clicked(); break; case 7: on_StopButton_clicked(); break; case 8: on_PlayButton_clicked(); break; case 9: on_AddButton_clicked(); break; case 10: addFiles(); break; case 11: nextFile(); break; case 12: prevFile(); break; case 13: aboutToFinish(); break; case 14: finished(); break; case 15: tick((*reinterpret_cast< qint64(*)>(_a[1]))); break; case 16: rndFile(); break; case 17: stateChanged((*reinterpret_cast< Phonon::State(*)>(_a[1])),(*reinterpret_cast< Phonon::State(*)>(_a[2]))); break; case 18: metaStateChanged((*reinterpret_cast< Phonon::State(*)>(_a[1])),(*reinterpret_cast< Phonon::State(*)>(_a[2]))); break; case 19: sourceChanged((*reinterpret_cast< const Phonon::MediaSource(*)>(_a[1]))); break; case 20: tableClicked((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break; case 21: setupActions(); break; case 22: removeFiles(); break; default: ; } _id -= 23; } return _id; }
Error Plot::renderFromDisplaySnapshot(SEXP snapshot) { // generate a new storage uuid std::string storageUuid = core::system::generateUuid(); // generate snapshot file FilePath snapshotFile = snapshotFilePath(storageUuid); Error error = r::exec::RFunction(".rs.saveGraphicsSnapshot", snapshot, snapshotFile.absolutePath()).call(); if (error) return error ; // // we can't generate an image file by calling graphicsDevice_.saveAsImageFile // because the GraphicsDevice has already moved on to the next page. this is // OK though because we simply set needsUpdate_ = true below and the next // time renderFromDisplay is called it will be rendered // // save rendered size renderedSize_ = graphicsDevice_.displaySize(); // save manipulator (if any) saveManipulator(storageUuid); // delete existing files (if any) Error removeError = removeFiles(); // update state storageUuid_ = storageUuid; needsUpdate_ = true; // return error status return removeError; }
Status Config::updateSource(const std::string& source, const std::string& json) { // Compute a 'synthesized' hash using the content before it is parsed. hashSource(source, json); // Remove all packs from this source. schedule_->removeAll(source); // Remove all files from this source. removeFiles(source); // load the config (source.second) into a pt::ptree pt::ptree tree; try { auto clone = json; stripConfigComments(clone); std::stringstream json_stream; json_stream << clone; pt::read_json(json_stream, tree); } catch (const pt::json_parser::json_parser_error& /* e */) { return Status(1, "Error parsing the config JSON"); } // extract the "schedule" key and store it as the main pack if (tree.count("schedule") > 0 && !Registry::external()) { auto& schedule = tree.get_child("schedule"); pt::ptree main_pack; main_pack.add_child("queries", schedule); addPack("main", source, main_pack); } if (tree.count("scheduledQueries") > 0 && !Registry::external()) { auto& scheduled_queries = tree.get_child("scheduledQueries"); pt::ptree queries; for (const std::pair<std::string, pt::ptree>& query : scheduled_queries) { auto query_name = query.second.get<std::string>("name", ""); if (query_name.empty()) { return Status(1, "Error getting name from legacy scheduled query"); } queries.add_child(query_name, query.second); } pt::ptree legacy_pack; legacy_pack.add_child("queries", queries); addPack("legacy_main", source, legacy_pack); } // extract the "packs" key into additional pack objects if (tree.count("packs") > 0 && !Registry::external()) { auto& packs = tree.get_child("packs"); for (const auto& pack : packs) { auto value = packs.get<std::string>(pack.first, ""); if (value.empty()) { // The pack is a JSON object, treat the content as pack data. addPack(pack.first, source, pack.second); } else { genPack(pack.first, source, value); } } } applyParsers(source, tree, false); return Status(0, "OK"); }
void FileSystemWatcher::removeFile(const QString &file) { removeFiles(QStringList(file)); }
int main (int argc, char* argv[]) { bkupInfo info; bkupType type; int len; int rst; /* return status */ if (getuid() != ROOT_UID) { fprintf(stderr, "must be root\n"); exit(1); } if (argc <= 2) { usage(); } umask(defUmask); memset(&info, 0, sizeof(info)); info.dest = argv[2]; info.src = index(argv[1], ':'); if (info.src) { info.host = index(argv[1], '@'); if (!info.host || info.host > info.src) { /* no user specified, or `@' appeared after `:' */ info.host = argv[1]; info.user = DefaultUser; } else { *info.host = '\0'; ++info.host; info.user = argv[1]; } *info.src = '\0'; ++info.src; } else { info.src = argv[1]; } if (*info.src != '/') goto errorExit; /* src must be full path */ if (*info.dest != '/') goto errorExit; /* dest must be full path */ len = strlen(info.src) - 1; if (info.src[len] == '/') { /* strip tail '/' */ info.src[len] = '\0'; } len = strlen(info.dest) - 1; if (info.dest[len] == '/') { info.dest[len] = '\0'; } if (info.host) { makeSshKey(&info); } chkDest(&info); if (info.host) { exit(doRemote(&info)); } type = chkSource(&info); openFilesLocal(&info); switch (type) { case bkupFirstTime: info.func = firstTimeBackup; break; case bkupRecurrent: info.func = recurrentBackup; break; default: errExit(("wrong bkup type (%d)", type)); } rst = dirwalk(info.src, &info); closeFiles(&info); if ((type == bkupRecurrent) && unlink(info.oldJpath)) { errSysRet(("unlink(%s)", info.oldJpath)); } rst = runCommands(&info); removeFiles(&info); if (type == bkupFirstTime && !rst) { if (info.jpath && unlink(info.jpath)) { errSysRet(("unlink(%s)", info.jpath)); } } exit(!rst); errorExit: fprintf(stderr, "Source and Destination directories must be full path\n"); exit(1); return 0; /* to make gcc happy */ }
int main(int argc, const char* argv[]){ int listener, fdmax, newfd, nbytes; struct sockaddr_in myAddr, clientAddr; char recvBuff[MAXBUFSIZE]; char sendBuff[MAXBUFSIZE]; char command; struct listEntry masterFileList[MAXFILES]; int numOfClients = 0; int numOfFiles = 0; fd_set master; // master file descriptor list fd_set readfds; // temp file descriptor list for select() socklen_t addrlen; FD_ZERO(&master); // clear the master and temp sets FD_ZERO(&readfds); //check command line arguments if(argc !=2){ printf("Usage: ./server_PFS <Port_Number>\n"); return -1; } //Open Listening port for clients listener=socket(AF_INET,SOCK_STREAM,0); if(listener < 0){ printf("Error creating socket!\n"); return -1; } bzero(&myAddr,sizeof(myAddr)); //zero the struct myAddr.sin_family = AF_INET; //address family myAddr.sin_port = htons(atoi(argv[1])); //htons() sets the port # to network byte order myAddr.sin_addr.s_addr = INADDR_ANY; //supplies the IP address of the local machine if(bind(listener, (struct sockaddr *)&myAddr, sizeof(myAddr))<0){ printf("Could not bind to port %s\n", argv[1]); return -1; } if(listen(listener, MAXCLIENTS) == -1) { printf("listen fail!\n"); return -1; } // add the listener to the master set FD_SET(listener, &master); // keep track of the biggest file descriptor fdmax = listener; // main loop for(;;) { readfds = master; // copy it if (select(fdmax+1, &readfds, NULL, NULL, NULL) == -1) { printf("select fail!\n"); return -1; } //run through all connections int i; for(i = 0; i <= fdmax; i++) { if (FD_ISSET(i, &readfds)) { // we got one!! //clear buffers for saftey bzero(&sendBuff, sizeof(sendBuff)); bzero(&recvBuff, sizeof(recvBuff)); //new connection if (i == listener) { addrlen = sizeof clientAddr; newfd = accept(listener, (struct sockaddr *)&clientAddr, &addrlen); if(newfd < 0){ printf("error accepting client\n"); } else { //client has connected FD_SET(newfd, &master); //add it to master set if(newfd > fdmax){ //keep track of maxfd fdmax = newfd; } printf("Server: New client has connected.\n"); numOfClients++; } } else { // handle data from an existing client if ((nbytes = recv(i, recvBuff, sizeof(recvBuff), 0)) <= 0) { if(nbytes == 0){ //closed Connection printf("Server: Client disconnected improperly, file list is probably corrupt!\n"); }else{ printf("Server: error on recv()\n"); } close(i); FD_CLR(i, &master); } else { //we got data from a client //deserialize packet int edgeCase = 0; int rows = (nbytes)/sizeof(struct listEntry); struct listEntry temp[rows]; memcpy(temp, &recvBuff[0], nbytes); command = temp[0].command; if(command == 'a'){ //check if client name is in use. char response; if(isClient(temp[0].clientName, masterFileList, numOfFiles) == 0){ printf("Server: Accepting client %s!\n", temp[0].clientName); response = 'y'; if(strcmp(temp[0].filename, "") == 0){ edgeCase = 1; } if(edgeCase == 0){ //add files to master list int i = 0; for(i = 0; i < rows; i++){ masterFileList[numOfFiles] = temp[i]; numOfFiles++; } } printf("Server: Master file list updated, sending to all clients.\n"); //send master list to all clients //serialize memcpy(&sendBuff[0], &masterFileList[0], numOfFiles*sizeof(struct listEntry)); //send to all other clients except listener and ourselves int j; for(j = 0; j <= fdmax; j++){ if(FD_ISSET(j, &master)){ if(j != listener){ nbytes = send(j, sendBuff, numOfFiles*sizeof(struct listEntry), 0); } } } }else{ //reject client printf("Client %s already exists, rejecting!\n", temp[0].clientName); response = 'n'; //send reject response to client memcpy(&sendBuff, &response, 1); if(send(i, sendBuff, 1, 0) < 1){ printf("error on send!\n"); } close(i); FD_CLR(i, &master); } }else if(command == 'b'){ printf("Server: Received LS packet!\n"); //send master list to client memcpy(&sendBuff[0], &masterFileList[0], numOfFiles*sizeof(struct listEntry)); nbytes = send(i, sendBuff, numOfFiles*sizeof(struct listEntry), 0); }else if(command == 'c'){ printf("Server: Received exit packet. Disconnecting client %s, and sending new list to remaining clients.\n", temp[0].clientName); //disconnect from client close(i); FD_CLR(i, &master); //remove their files from master list numOfFiles = removeFiles(temp[0].clientName, masterFileList, numOfFiles); //send master list to clients //serialize memcpy(&sendBuff[0], &masterFileList[0], numOfFiles*sizeof(struct listEntry)); //send to all other clients except listener and ourselves int j; for(j = 0; j <= fdmax; j++){ if(FD_ISSET(j, &master)){ if(j != listener){ nbytes = send(j, sendBuff, numOfFiles*sizeof(struct listEntry), 0); } } } }else { printf("Bad packet? =< \n"); } } }//End Handle data from client }// End FD_ISSET() }//End connections loop }//End Main Loop } //End Main
void WorkerThread::runTest() { emit(beginRunTest()); emit(stageEvent("Checking files and paths")); bool error = false; if(!QFileInfo(m_emuFileName).exists()) { emit(errorEvent("Specified winuae.exe not found (" + m_emuFileName + ")")); error = true; } if(!QFileInfo(m_gameFileName).exists()) { emit(errorEvent("Specified game pack not found (" + m_gameFileName + ")")); error = true; } if(!QFileInfo(m_configFileName).exists()) { emit(errorEvent("Specified config file not found (" + m_configFileName + ")")); error = true; } if(!QFileInfo(m_startupFileName).exists()) { emit(errorEvent("Specified user-startup not found (" + m_startupFileName + ")")); error = true; } bool tempError = false; QFileInfo tempPathInfo(m_tempPath); m_lockFile.setFileName(m_tempPath + "/" __WHDRun__LockFileName); if(tempPathInfo.exists()) { if(!tempPathInfo.isDir()) { emit(errorEvent("Temp path is an already existing file (" + m_tempPath +")")); tempError = true; } else { QDir tempDir(m_tempPath); if(tempDir.entryList(QDir::AllEntries | QDir::NoDotAndDotDot).count() > 0) { if(!m_lockFile.exists()) { errorEvent("Temp path already contains files apparently not created by WHDRun (" + m_tempPath + ")"); tempError = true; } else if (!m_lockFile.remove()) { errorEvent("Temp path already in use by another instance of WHDRun (" + m_tempPath + ")"); tempError = true; } } } } if(!tempError) { if(!removeFiles(m_tempPath)) { emit(errorEvent("Error while removing old files in temp path (" + m_tempPath + ")")); error = true; } QDir::current().mkpath(m_tempPath); tempPathInfo = QFileInfo(m_tempPath); if(!tempPathInfo.exists() || !tempPathInfo.isDir()) { emit(errorEvent("Temp path is invalid and/or could not be created (" + m_tempPath + ")")); error = true; } if(!m_lockFile.open(QIODevice::ReadWrite)) { emit(errorEvent("Could not create lock file in temp path (" + m_lockFile.fileName() + ")")); error = true; } } else error = true; QFileInfo dataDirInfo(m_dataPath); if(!dataDirInfo.exists() || !dataDirInfo.isDir()) { QDir::current().mkpath(m_dataPath); dataDirInfo = QFileInfo(m_dataPath); if(!dataDirInfo.exists() || !dataDirInfo.isDir()) { emit(errorEvent("Data path is invalid and/or could not be created (" + m_dataPath + ")")); error = true; error = true; } } if(error) m_die = true; }
int main() { printf("A - Bubble Sort\nB - Insertion Sort\nC - Selection Sort\nD - Merge Sort\nE - QuickSort\nR-Radix Sort\nF - All Sorting Algorithms\nX - Remove Files\nN - Change constants\nQ - Quit\n"); initFunctions(); char choice; while(1) { printf("Choice: "); choice = getch(); printf("\n"); switch(choice) { case 'A': inPlaceSort(inPlaceSortingFunctions[BUBBLE], BUBBLE); break; case 'B': inPlaceSort(inPlaceSortingFunctions[INSERTION], INSERTION); break; case 'C': inPlaceSort(inPlaceSortingFunctions[SELECTION], SELECTION); break; case 'D': outOfPlaceSort(outOfPlaceSortingFunctions[MERGESORT], MERGESORT); break; case 'E': inPlaceSort(inPlaceSortingFunctions[QUICKSORT], QUICKSORT); break; case 'R': outOfPlaceSort(outOfPlaceSortingFunctions[RADIXSORT],RADIXSORT); break; case 'F': inPlaceSort(inPlaceSortingFunctions[BUBBLE], BUBBLE); inPlaceSort(inPlaceSortingFunctions[INSERTION], INSERTION); inPlaceSort(inPlaceSortingFunctions[SELECTION], SELECTION); outOfPlaceSort(outOfPlaceSortingFunctions[MERGESORT], MERGESORT); inPlaceSort(inPlaceSortingFunctions[QUICKSORT], QUICKSORT); outOfPlaceSort(outOfPlaceSortingFunctions[RADIXSORT],RADIXSORT); break; case 'X': removeFiles(); break; case 'N': changeConstants(); break; case 'Q': exit(0); break; default: printf("Bad Operation!\n"); break; } } return 0; }
void AntProjectPart::slotRemoveFromProject() { QStringList fileList; fileList.append ( m_contextFileName ); removeFiles ( fileList ); }
// IThorSlaveProcess overloaded methods void CDiskWriteSlaveActivityBase::kill() { ProcessSlaveActivity::kill(); if (abortSoon) removeFiles(); }
ExternalDiffProc::~ExternalDiffProc() { terminate(); removeFiles(); }
Status Config::updateSource(const std::string& name, const std::string& json) { // Compute a 'synthesized' hash using the content before it is parsed. hashSource(name, json); // Remove all packs from this source. schedule_->removeAll(name); // Remove all files from this source. removeFiles(name); // load the config (source.second) into a pt::ptree pt::ptree tree; try { auto clone = json; stripConfigComments(clone); std::stringstream json_stream; json_stream << clone; pt::read_json(json_stream, tree); } catch (const pt::json_parser::json_parser_error& e) { return Status(1, "Error parsing the config JSON"); } // extract the "schedule" key and store it as the main pack if (tree.count("schedule") > 0 && !Registry::external()) { auto& schedule = tree.get_child("schedule"); pt::ptree main_pack; main_pack.add_child("queries", schedule); addPack("main", name, main_pack); } if (tree.count("scheduledQueries") > 0 && !Registry::external()) { auto& scheduled_queries = tree.get_child("scheduledQueries"); pt::ptree queries; for (const std::pair<std::string, pt::ptree>& query : scheduled_queries) { auto query_name = query.second.get<std::string>("name", ""); if (query_name.empty()) { return Status(1, "Error getting name from legacy scheduled query"); } queries.add_child(query_name, query.second); } pt::ptree legacy_pack; legacy_pack.add_child("queries", queries); addPack("legacy_main", name, legacy_pack); } // extract the "packs" key into additional pack objects if (tree.count("packs") > 0 && !Registry::external()) { auto& packs = tree.get_child("packs"); for (const auto& pack : packs) { auto value = packs.get<std::string>(pack.first, ""); if (value.empty()) { // The pack is a JSON object, treat the content as pack data. addPack(pack.first, name, pack.second); } else { // If the pack value is a string (and not a JSON object) then it is a // resource to be handled by the config plugin. PluginResponse response; PluginRequest request = { {"action", "genPack"}, {"name", pack.first}, {"value", value}}; Registry::call("config", request, response); if (response.size() == 0 || response[0].count(pack.first) == 0) { continue; } try { pt::ptree pack_tree; std::stringstream pack_stream; pack_stream << response[0][pack.first]; pt::read_json(pack_stream, pack_tree); addPack(pack.first, name, pack_tree); } catch (const pt::json_parser::json_parser_error& e) { LOG(WARNING) << "Error parsing the pack JSON: " << pack.first; } } } } applyParsers(name, tree, false); return Status(0, "OK"); }
void ImportImages::setupConnections() { connect(importButton, SIGNAL(clicked()), this, SLOT(importPressed())); connect(cancelButton, SIGNAL(clicked()), this, SLOT(cancelPressed())); connect(imageListWidget, SIGNAL(removeSelected(QList<int>)), this, SLOT(removeFiles(QList<int>))); }
virtual void process() override { ActPrintLog("INDEXWRITE: Start"); init(); IRowStream *stream = inputStream; ThorDataLinkMetaInfo info; input->getMetaInfo(info); outRowAllocator.setown(getRowAllocator(helper->queryDiskRecordSize())); start(); if (refactor) { assertex(isLocal); if (active) { unsigned targetWidth = partDesc->queryOwner().numParts()-(buildTlk?1:0); assertex(0 == container.queryJob().querySlaves() % targetWidth); unsigned partsPerNode = container.queryJob().querySlaves() / targetWidth; unsigned myPart = queryJobChannel().queryMyRank(); IArrayOf<IRowStream> streams; streams.append(*LINK(stream)); --partsPerNode; // Should this be merging 1,11,21,31 etc. unsigned p=0; unsigned fromPart = targetWidth+1 + (partsPerNode * (myPart-1)); for (; p<partsPerNode; p++) { streams.append(*createRowStreamFromNode(*this, fromPart++, queryJobChannel().queryJobComm(), mpTag, abortSoon)); } ICompare *icompare = helper->queryCompare(); assertex(icompare); Owned<IRowLinkCounter> linkCounter = new CThorRowLinkCounter; myInputStream.setown(createRowStreamMerger(streams.ordinality(), streams.getArray(), icompare, false, linkCounter)); stream = myInputStream; } else // serve nodes, creating merged parts rowServer.setown(createRowServer(this, stream, queryJobChannel().queryJobComm(), mpTag)); } processed = THORDATALINK_STARTED; // single part key support // has to serially pull all data fron nodes 2-N // nodes 2-N, could/should start pushing some data (as it's supposed to be small) to cut down on serial nature. unsigned node = queryJobChannel().queryMyRank(); if (singlePartKey) { if (1 == node) { try { open(*partDesc, false, helper->queryDiskRecordSize()->isVariableSize()); for (;;) { OwnedConstThorRow row = inputStream->ungroupedNextRow(); if (!row) break; if (abortSoon) return; processRow(row); } unsigned node = 2; while (node <= container.queryJob().querySlaves()) { Linked<IOutputRowDeserializer> deserializer = ::queryRowDeserializer(input); CMessageBuffer mb; Owned<ISerialStream> stream = createMemoryBufferSerialStream(mb); CThorStreamDeserializerSource rowSource; rowSource.setStream(stream); bool successSR; for (;;) { { BooleanOnOff tf(receivingTag2); successSR = queryJobChannel().queryJobComm().sendRecv(mb, node, mpTag2); } if (successSR) { if (rowSource.eos()) break; Linked<IEngineRowAllocator> allocator = ::queryRowAllocator(input); do { RtlDynamicRowBuilder rowBuilder(allocator); size32_t sz = deserializer->deserialize(rowBuilder, rowSource); OwnedConstThorRow fRow = rowBuilder.finalizeRowClear(sz); processRow(fRow); } while (!rowSource.eos()); } } node++; } } catch (CATCHALL) { close(*partDesc, partCrc, true); throw; } close(*partDesc, partCrc, true); stop(); } else { CMessageBuffer mb; CMemoryRowSerializer mbs(mb); Linked<IOutputRowSerializer> serializer = ::queryRowSerializer(input); for (;;) { BooleanOnOff tf(receivingTag2); if (queryJobChannel().queryJobComm().recv(mb, 1, mpTag2)) // node 1 asking for more.. { if (abortSoon) break; mb.clear(); do { OwnedConstThorRow row = inputStream->ungroupedNextRow(); if (!row) break; serializer->serialize(mbs, (const byte *)row.get()); } while (mb.length() < SINGLEPART_KEY_TRANSFER_SIZE); // NB: at least one row if (!queryJobChannel().queryJobComm().reply(mb)) throw MakeThorException(0, "Failed to send index data to node 1, from node %d", node); if (0 == mb.length()) break; } } } } else { if (!refactor || active) { try { StringBuffer partFname; getPartFilename(*partDesc, 0, partFname); ActPrintLog("INDEXWRITE: process: handling fname : %s", partFname.str()); open(*partDesc, false, helper->queryDiskRecordSize()->isVariableSize()); ActPrintLog("INDEXWRITE: write"); BooleanOnOff tf(receiving); if (!refactor || !active) receiving = false; do { OwnedConstThorRow row = inputStream->ungroupedNextRow(); if (!row) break; processRow(row); } while (!abortSoon); ActPrintLog("INDEXWRITE: write level 0 complete"); } catch (CATCHALL) { close(*partDesc, partCrc, isLocal && !buildTlk && 1 == node); throw; } close(*partDesc, partCrc, isLocal && !buildTlk && 1 == node); stop(); ActPrintLog("INDEXWRITE: Wrote %" RCPF "d records", processed & THORDATALINK_COUNT_MASK); if (buildTlk) { ActPrintLog("INDEXWRITE: sending rows"); NodeInfoArray tlkRows; CMessageBuffer msg; if (firstNode()) { if (processed & THORDATALINK_COUNT_MASK) { if (enableTlkPart0) tlkRows.append(* new CNodeInfo(0, firstRow.get(), firstRowSize, totalCount)); tlkRows.append(* new CNodeInfo(1, lastRow.get(), lastRowSize, totalCount)); } } else { if (processed & THORDATALINK_COUNT_MASK) { CNodeInfo row(queryJobChannel().queryMyRank(), lastRow.get(), lastRowSize, totalCount); row.serialize(msg); } queryJobChannel().queryJobComm().send(msg, 1, mpTag); } if (firstNode()) { ActPrintLog("INDEXWRITE: Waiting on tlk to complete"); // JCSMORE if refactor==true, is rowsToReceive here right?? unsigned rowsToReceive = (refactor ? (tlkDesc->queryOwner().numParts()-1) : container.queryJob().querySlaves()) -1; // -1 'cos got my own in array already ActPrintLog("INDEXWRITE: will wait for info from %d slaves before writing TLK", rowsToReceive); while (rowsToReceive--) { msg.clear(); receiveMsg(msg, RANK_ALL, mpTag); // NH->JCS RANK_ALL_OTHER not supported for recv if (abortSoon) return; if (msg.length()) { CNodeInfo *ni = new CNodeInfo(); ni->deserialize(msg); tlkRows.append(*ni); } } tlkRows.sort(CNodeInfo::compare); StringBuffer path; getPartFilename(*tlkDesc, 0, path); ActPrintLog("INDEXWRITE: creating toplevel key file : %s", path.str()); try { open(*tlkDesc, true, helper->queryDiskRecordSize()->isVariableSize()); if (tlkRows.length()) { CNodeInfo &lastNode = tlkRows.item(tlkRows.length()-1); memset(lastNode.value, 0xff, lastNode.size); } ForEachItemIn(idx, tlkRows) { CNodeInfo &info = tlkRows.item(idx); builder->processKeyData((char *)info.value, info.pos, info.size); } close(*tlkDesc, tlkCrc, true); } catch (CATCHALL) { abortSoon = true; close(*tlkDesc, tlkCrc, true); removeFiles(*partDesc); throw; } } } else if (!isLocal && firstNode())