void receiveFiles(int sid) { int countFiles=0; recv(sid, &countFiles, 1, 0); printf("\nLiczba plików : %d\n",countFiles); printf("\n===== POBIERAM ====="); int i; for(i=0; i<countFiles; i++) { infoFile *file = receiveFile(sid); showFile(file); writeFile(configstruct.rootPath, file); if (file == NULL) { fprintf(stderr, "Cannot receive file\n"); return; } // dataFilesTmp[i] = *file; } // dataFiles=dataFilesTmp; }
void TestWidget::openFile() { QString filePath = QFileDialog::getOpenFileName(this, "Open a text file", QString(), "Text files (*.txt)"); if (filePath.isEmpty()) return; else showFile(filePath); }
void TestWidget::openFile() { QFileDialog fileDialog(this, "Open a Text File"); fileDialog.setAcceptMode(QFileDialog::AcceptOpen); fileDialog.setMimeTypeFilters(TestWidget::supportedMimeTypes()); // Note: The native file dialog creates the frequent/recent entries. if (!ui->actionUse_Native_File_Dialog->isChecked()) fileDialog.setOption(QFileDialog::DontUseNativeDialog); if (fileDialog.exec() == QDialog::Accepted) showFile(fileDialog.selectedFiles().first()); }
bool FileFilterIndex::showFile(FileData* game) { // this shouldn't happen, but just in case let's get it out of the way if (!isFiltered()) return true; // if folder, needs further inspection - i.e. see if folder contains at least one element // that should be shown if (game->getType() == FOLDER) { std::vector<FileData*> children = game->getChildren(); // iterate through all of the children, until there's a match for (std::vector<FileData*>::const_iterator it = children.cbegin(); it != children.cend(); ++it ) { if (showFile(*it)) { return true; } } return false; } bool keepGoing = false; for (std::vector<FilterDataDecl>::const_iterator it = filterDataDecl.cbegin(); it != filterDataDecl.cend(); ++it ) { FilterDataDecl filterData = (*it); if(*(filterData.filteredByRef)) { // try to find a match std::string key = getIndexableKey(game, filterData.type, false); keepGoing = isKeyBeingFilteredBy(key, filterData.type); // if we didn't find a match, try for secondary keys - i.e. publisher and dev, or first genre if (!keepGoing) { if (!filterData.hasSecondaryKey) { return false; } std::string secKey = getIndexableKey(game, filterData.type, true); if (secKey != UNKNOWN_LABEL) { keepGoing = isKeyBeingFilteredBy(secKey, filterData.type); } } // if still nothing, then it's not a match if (!keepGoing) return false; } } return keepGoing; }
void view::mainWidget::codeViewer::highlightFile(QString inputFilePath, QString outPutFilePath) { if (m_enableEditor) showFile(outPutFilePath); else { QString highlight; if (m_wrapLines) { QString foldedInputFilePath = inputFilePath + ".folded"; QString fold = "fold -w 110 " + inputFilePath + " > " + foldedInputFilePath; view::exec(fold); highlight = "/usr/local/bin/pygmentize -f html -l " + m_language + " -O full,style=emacs,linenos=1 -o " + outPutFilePath + " " + foldedInputFilePath; } else highlight = "/usr/local/bin/pygmentize -f html -l " + m_language + " -O full,style=emacs,linenos=1 -o " + outPutFilePath + " " + inputFilePath; view::exec(highlight); showFile(outPutFilePath); } }
void OverwriteDialog::getNext(){ if(files.size() == 0 && overwriteWindow->get_visible()){ overwriteWindow->hide(); }else{ if(files.size() > 0){ actualFile = files.front(); files.pop_front(); showFile(actualFile); if(!overwriteWindow->get_visible()){ overwriteWindow->show(); } } } }
void OverwriteDialog::addFile(MediaFile::MediaFile*& file){ if(files.size() == 0 && actualFile == NULL){ actualFile = file; showFile(actualFile); overwriteWindow->show(); }else{ if(actualFile != file){ auto iter = std::find_if(files.begin(), files.end(), [file](const MediaFile::MediaFile* sec) -> bool { return file == sec; }); if(iter == files.end()){ files.push_back(file); } } } }
void DL_ImageBinary::loadFile() { QString m_curFile; m_curFile=QFileDialog::getOpenFileName(this, tr("选择图像"), "", tr("Images library(*.bin *.*)")); if(m_curFile.isEmpty()) { return; } else { curFilename = m_curFile; QFileInfo curFileInfo(m_curFile); m_DName->setText(curFileInfo.fileName()); showFile(m_curFile); } }
TestWidget::TestWidget(QWidget *parent) : QWidget(parent), ui(new Ui::TestWidget) { ui->setupUi(this); if (QCoreApplication::arguments().contains("-text")) ui->text->setPlainText("Hello, world!"); if (!QCoreApplication::arguments().contains("-fullscreen")) ui->btnClose->hide(); for (int i = 1; i < QCoreApplication::arguments().size(); i++) { const QString arg = QCoreApplication::arguments().at(i); if (!arg.isEmpty() && arg.at(0) != '-' && QFile(arg).exists()) { showFile(arg); break; } } connect(ui->btnUpdate, &QAbstractButton::clicked, this, &TestWidget::updateJumpList); connect(ui->btnOpenFile, &QAbstractButton::clicked, this, &TestWidget::openFile); connect(ui->btnClose, &QAbstractButton::clicked, QCoreApplication::quit); }
void changeListenerCallback (ChangeBroadcaster* source) override { if (source == thumbnail) showFile (thumbnail->getLastDroppedFile()); }
void selectionChanged() override { showFile (fileTreeComp.getSelectedFile()); }
bool Node::aStarVisit(std::deque<Node*>* deque, std::vector<bool>* visitedNodes) { visitedNodes->at(stateNumber) = true; showFile(); if (gameWon()) { return true; } if (Node* n = shiftLeft()) { if (n->notVisited(visitedNodes)) { //n->setHeight(height+1); deque->push_back(n); child.push_back(n); } else { delete n; } } if (Node* n = shiftUp()) { if (n->notVisited(visitedNodes)) { //n->setHeight(height+1); deque->push_back(n); child.push_back(n); } else { delete n; } } if (Node* n = shiftRight()) { if (n->notVisited(visitedNodes)) { //n->setHeight(height+1); deque->push_back(n); child.push_back(n); } else { delete n; } } if (Node* n = shiftDown()) { if (n->notVisited(visitedNodes)) { //n->setHeight(height+1); deque->push_back(n); child.push_back(n); } else { delete n; } } return false; }
int main() { FILE *file; List listDynamic; info reg; char option; printf("/t/t/t/tPrueba Lista Dinamica\n"); if(!openFile(&file,FILE_NAME,"r+b",!MESSAGE_OR_NOT)) { createFile(); if(!openFile(&file,FILE_NAME,"r+b",MESSAGE_OR_NOT)) return 0; } showFile(&file); createList(&listDynamic); fread(®,1,sizeof(info),file); while(!feof(file)) { putTheTopOfTheList(&listDynamic,®); fread(®,1,sizeof(info),file); } fseek(file,0L,SEEK_SET); option = menu(MESS,OPTIONS); while(option != 'i') { switch(option) { case 'b': { bubbleSortList(&listDynamic); puts("Lista ordenada por DNI"); break; } case 'c': { puts("Ingrese el DNI del nodo a eliminar:"); fflush(stdin); scanf("%08ld",®.dni); if(removeFromList(&listDynamic,®,compear) == NOT_FOUND) puts("Nodo no encontrado"); break; } case 'd': { /**DNI**/ printf("DNI:"); fflush(stdin); scanf("%08ld",®.dni); puts(""); if(searchNode(&listDynamic,®,compear) == O_K) showData(®); else puts("Nodo no encontrado"); break; } case 'f': { /**DNI**/ printf("DNI:"); fflush(stdin); scanf("%08ld",®.dni); puts(""); /**APELLIDO**/ printf("APELLIDO:"); fflush(stdin); scanf("%s",reg.surName); puts(""); /**NOMBRE**/ printf("NOMBRE:"); fflush(stdin); scanf("%s",reg.name); puts(""); /**PROMEDIO**/ printf("PROMEDIO:"); fflush(stdin); scanf("%f",®.average); puts(""); if(putTheTopOfTheList(&listDynamic,®) == WITHOUT_MEMORY) puts("Sin memoria"); break; } case 'g': { /**DNI**/ printf("DNI:"); fflush(stdin); scanf("%08ld",®.dni); puts(""); /**APELLIDO**/ printf("APELLIDO:"); fflush(stdin); scanf("%s",reg.surName); puts(""); /**NOMBRE**/ printf("NOMBRE:"); fflush(stdin); scanf("%s",reg.name); puts(""); /**PROMEDIO**/ printf("PROMEDIO:"); fflush(stdin); scanf("%f",®.average); puts(""); if(putAnEndTheList(&listDynamic,®) == WITHOUT_MEMORY) puts("Sin memoria"); break; } case 'h': { /**DNI**/ printf("DNI:"); fflush(stdin); scanf("%08ld",®.dni); puts(""); /**APELLIDO**/ printf("APELLIDO:"); fflush(stdin); scanf("%s",reg.surName); puts(""); /**NOMBRE**/ printf("NOMBRE:"); fflush(stdin); scanf("%s",reg.name); puts(""); /**PROMEDIO**/ printf("PROMEDIO:"); fflush(stdin); scanf("%f",®.average); puts(""); if(putInOrder(&listDynamic,®,compear,accumulate) == WITHOUT_MEMORY) puts("Sin memoria"); break; } } option = menu(MESS,OPTIONS); } putListInFile(&listDynamic,&file); showFile(&file); fclose(file); clearList(&listDynamic); return 0; }
void AudioDemoPlaybackPage::selectionChanged() { showFile (fileTreeComp->getSelectedFile()); }
void nameFilesFolder(int sid) { infoFile **files; int i=0, numberFile=0; DIR *d; struct dirent *dir; d = opendir(configstruct.rootPath); if (d) { while ((dir = readdir(d)) != NULL) { if( strcmp(dir->d_name, ".")!=0 && strcmp(dir->d_name, "..")!=0 ) i++; } } closedir(d); d = opendir(configstruct.rootPath); if (d) { files = (infoFile**) malloc( i*sizeof(infoFile*) ); i=0; while ((dir = readdir(d)) != NULL) { if( strcmp(dir->d_name, ".")!=0 && strcmp(dir->d_name, "..")!=0 ) { files[i] = readFile(configstruct.rootPath, dir->d_name); printf("%2d. %s %lu\n", i, files[i]->name, files[i]->size); i++; } } } closedir(d); printf("\nNumer pliku do wysłania : "); scanf("%d", &numberFile); printf("===== WYSYŁAM ====="); showFile( files[numberFile] ); sendFile(sid, files[numberFile] ); enum odp o; recv(sid, &o, sizeof(enum odp), 0); if (o==NOWY) { printf("%s : Utworzono nowy plik na serwerze\n\n", files[numberFile]->name); } else if (o==NIEZNANY) { printf("%s : Nieznana wersja pliku\n\n", files[numberFile]->name); printf("===== CO CHCZESC ZROBIĆ =====\n"); printf("0 - Anuluj\n"); printf("1 - Zapisz jako najnowszą wersję\n"); printf("2 - Zapisz pod nową nazwą\n"); printf("3 - Pobierz najnowsza wersje (zastąp aktualną)\n"); printf("4 - Pobierz najnowsza wersje pod nową nazwą\n"); while (1==1) { char wybor; scanf("%c", &wybor); if (wybor=='0') { enum odp o2 = NONE; send(sid, &o2, sizeof(enum odp), 0); break; } else if (wybor=='1') { enum odp o2 = NOWA_WERSJA; send(sid, &o2, sizeof(enum odp), 0); break; } else if (wybor=='2') { printf("Nowa nazwa plik : "); scanf("%s", files[numberFile]->name); enum odp o2 = NOWY_PLIK; send(sid, &o2, sizeof(enum odp), 0); sendFile(sid, files[numberFile]); break; } else if (wybor=='3') { enum odp o2 = POBIERZ_PLIK; send(sid, &o2, sizeof(enum odp), 0); infoFile *file2 = receiveFile(sid); showFile(file2); writeFile(configstruct.rootPath, file2); freeFile(file2); break; } else if (wybor=='4') { enum odp o2 = POBIERZ_PLIK_NAZWA; send(sid, &o2, sizeof(enum odp), 0); infoFile *file = receiveFile(sid); printf("Podaj nową nazwę pliku : "); scanf("%s", file->name); writeFile(configstruct.rootPath, file); freeFile(file); break; } } } else if (o==AKTUALNY) { printf("%s : To jest najnowsza wersja pliku\n\n", files[numberFile]->name); } else if (o==STARY) { printf("%s : To jest stara wersja pliku\n\n", files[numberFile]->name); } }
int main() { FILE *fp; tInfo info; Arbol tree; int cont = 0; char op; printf("Ejercicio 2 Arbol Binario\n"); if(!openFile(&fp,"r+b",nameFile,!CON_SIN_MSJ)) { createFile(); if(!openFile(&fp,"r+b",nameFile,CON_SIN_MSJ)) return 0; } showFile(&fp); createTree(&tree); fread(&info,1,sizeof(tInfo),fp); while(!feof(fp) && !isTreeFull(&tree)) { putInTree(&tree,&info,&cont,compear); fread(&info,1,sizeof(tInfo),fp); } op = menuOption(MSJ,OPTION); while(op != 'L') { switch(op) { case 'A': { newInfo(&info); if(!isTreeFull(&tree)) { if(putInTree(&tree,&info,&cont,compear) == CLAV_DUP) puts("Informacion duplicada, no se pudo completar la accion"); else putAtTheEnd(&fp,&info); } break; } case 'B': { printf("Ingrese clave:"); fflush(stdin); scanf("%ld",&info.dni); showInfoByKey(&fp,searchInTree(&tree,&info,compear)); break; } case 'C': { puts("Informacion en orden"); order(&tree,&fp); break; } case 'D': { puts("Informacion en posOrden"); posOrder(&tree,&fp); break; } case 'E': { puts("Informacion en preOrden"); preOrder(&tree,&fp); break; } case 'F': { printf("Hojas: %d",sheetsCounting(&tree)); break; } case 'G': { printf("Nodos: %d",countingNodes(&tree)); break; } case 'H': { if(completeTree(&tree)) puts("Arbol completo"); else puts("Arbol no completo"); break; } case 'I': { if(isAVL(&tree)) puts("Arbol es AVL"); else puts("Arbol no es AVL"); break; } case 'J': { if(balancedTree(&tree)) puts("Arbol es balanceado"); else puts("Arbol no es balanceado"); break; } } op = menuOption(MSJ,OPTION); } fclose(fp); emptyTree(&tree); return 0; }