// load settings from .cvs file, basically, this is the file names void FileNames::loadSettings() { // regular expression to follow format such that "Text <num> = <filename with num> (optional: _ <char><letters>).txt // this is best practice to be sure the file is not having to be exaclty type in as some way boost::regex expression("(\\s*)(Test)(\\s*)[0-9]*(\\s*)(=)(\\s*)[a-zA-Z]*[0-9]*((_)[a-zA-Z]*)?(.txt)(\\s*)"); // instream to get file contents std::fstream input_file; // open up file input_file.open("file_names.csv", std::ios::in); // if error with file if(input_file.fail()) { // error message QMessageBox messageBox; messageBox.critical(0,"Error","File: file_names.csv missing"); messageBox.setFixedSize(500,200); } // file is fine else { // string to get line from file std::string temp = ""; // loop file getting each line while(std::getline(input_file, temp)) { // hold string match results boost::match_results<std::string::const_iterator> results; // get results based off regualr expression if(boost::regex_match(temp, results, expression)) { // set to use string methods // anything after results[0]is for other purposes temp = results[0]; // remove all white spaces from text temp.erase(std::remove_if(temp.begin(), temp.end(), [](char pos){return std::isspace(pos);}), temp.end()); // seperate string into two substrings, test and filename for test // based off = sign boost::regex filename_re("="); // iterator object based off start of vector, end of vector, and the = // can't recall what the -1 was for boost::sregex_token_iterator iter(temp.begin(), temp.end(), filename_re, -1); // since the strings are now seperated as tokens // this returns the test number e.g. test=1,2,3,...etc std::string test_number = (*iter); // get next address (next test value) iter++; // get test name e.g. HapticTask1_Fatigue.txt, etc std::string test_name = (*iter); // no need to iterate here // pass in the test value and name into a pair // this will be used for later // to get values off hashmap to match file name with // proper file that was loaded into program std::pair<std::string, std::string> file_info (test_number, test_name); // insert new pair (into hashmap) this->names.insert(file_info); } } } }
int main(int argc, char *argv[]) { #ifdef HAVE_MPI MPI_Init(&argc, &argv); #endif Info::Interface interface; interface.parse_options(argc, argv); std::string in_type = "exodusII"; codename = argv[0]; size_t ind = codename.find_last_of("/", codename.size()); if (ind != std::string::npos) codename = codename.substr(ind+1, codename.size()); Ioss::Init::Initializer io; #ifndef NO_XDMF_SUPPORT Ioxf::Initializer ioxf; #endif OUTPUT << "Input: '" << interface.filename() << "', Type: " << interface.type() << '\n'; OUTPUT << '\n'; file_info(interface.filename(), interface.type(), interface); OUTPUT << "\n" << codename << " execution successful.\n"; #ifdef HAVE_MPI MPI_Finalize(); #endif return EXIT_SUCCESS; }
void file_free(OBJECT * filename, int is_recursive) { file_info_t * ff; /* do nothing if cache is uninitialized */ if ( !filecache_hash ) return; ff = file_info( filename ); hash_free( filecache_hash, (HASHDATA*)ff ); /* freed directories must free all their files and subdirectories */ if ( ff->is_dir ) { printf( "dir_free: %s\n", filename ); if ( !ff->files ) printf( "directory without files: %s\n", filename ); else { LIST * files = ff->files; for ( ; files; files = list_next( files ) ) if ( is_recursive || file_is_file( files->value ) ) file_free( files->value, is_recursive ); } } else { printf( "file_free: %s\n", filename ); } }
void StlWriter::operate() { try { QFileInfo file_info(GuiMainWindow::pointer()->getFilename()); readOutputFileName(file_info.completeBaseName() + ".stl"); if (isValid()) { EG_VTKSP(vtkGeometryFilter, geometry); geometry->SetInput(m_Grid); EG_VTKSP(vtkTriangleFilter, triangle); triangle->SetInput(geometry->GetOutput()); EG_VTKSP(vtkSTLWriter, write_stl); write_stl->SetInput(triangle->GetOutput()); write_stl->SetFileName(qPrintable(getFileName())); if(m_AsciiFileType) { write_stl->SetFileTypeToASCII(); } else { write_stl->SetFileTypeToBinary(); } write_stl->Write(); }; } catch (Error err) { err.display(); }; };
static void getShaderPath(const char* shd_path, char* out, bool vertex) { Lumix::PathUtils::FileInfo file_info(shd_path); Lumix::copyString(out, Lumix::MAX_PATH_LENGTH, file_info.m_dir); Lumix::catString(out, Lumix::MAX_PATH_LENGTH, file_info.m_basename); Lumix::catString(out, Lumix::MAX_PATH_LENGTH, vertex ? "_vs.sc" : "_fs.sc"); }
file_info_t * file_query( OBJECT * const path ) { /* FIXME: Add tracking for disappearing files (i.e. those that can not be * detected by stat() even though they had been detected successfully * before) and see how they should be handled in the rest of Boost Jam code. * Possibly allow Jamfiles to specify some files as 'volatile' which would * make Boost Jam avoid caching information about those files and instead * ask the OS about them every time. */ int found; file_info_t * const ff = file_info( path, &found ); if ( !found ) { file_query_( ff ); if ( ff->exists ) { /* Set the path's timestamp to 1 in case it is 0 or undetected to avoid * confusion with non-existing paths. */ if ( timestamp_empty( &ff->time ) ) timestamp_init( &ff->time, 1, 0 ); } } if ( !ff->exists ) { return 0; } return ff; }
void MainWindow::on_actionReplay_triggered() { #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) QString location = QDesktopServices::storageLocation(QDesktopServices::HomeLocation); #else QString location = QStandardPaths::writableLocation(QStandardPaths::HomeLocation); #endif QString last_dir = Config.value("LastReplayDir").toString(); if (!last_dir.isEmpty()) location = last_dir; QString filename = QFileDialog::getOpenFileName(this, tr("Select a reply file"), location, tr("QSanguosha Replay File(*.qsgs);; Image replay file (*.png)")); if (filename.isEmpty()) return; QFileInfo file_info(filename); last_dir = file_info.absoluteDir().path(); Config.setValue("LastReplayDir", last_dir); Client *client = new Client(this, filename); connect(client, SIGNAL(server_connected()), SLOT(enterRoom())); client->signup(); }
void MainWindow::on_actionReplay_triggered() { QString location = QDesktopServices::storageLocation(QDesktopServices::HomeLocation); QString last_dir = Config.value("LastReplayDir").toString(); if(!last_dir.isEmpty()) location = last_dir; QString filename = QFileDialog::getOpenFileName(this, tr("Select a reply file"), location, tr("Pure text replay file (*.txt);; Image replay file (*.png)")); if(filename.isEmpty()) return; QFileInfo file_info(filename); last_dir = file_info.absoluteDir().path(); Config.setValue("LastReplayDir", last_dir); Client *client = new Client(this, filename); connect(client, SIGNAL(server_connected()), SLOT(enterRoom())); client->signup(); }
/// /// \brief DataViewer::on_exportToolButton_clicked /// Triggers a save dialog to save the current dataset void DataViewer::on_exportToolButton_clicked() { QString filename = QFileDialog::getSaveFileName(this, tr("Export As..."), directory_, tr("Comma-separated Variables (*.csv);;" "Tab-delimited Text (*.txt);;" "Armadillo Binary (*.arma);;")); QFileInfo file_info(filename); bool success = false; if (filename.isEmpty()) return; workspace->set_directory(file_info.dir().path()); QString extension = file_info.suffix(); if (extension == "arma") success = current_data_->save(filename.toStdString(), arma_binary); else if (extension == "csv") success = current_data_->save(filename.toStdString(), csv_ascii); else success = current_data_->save(filename.toStdString(), raw_ascii); if (success) QMessageBox::information(this, "Success!", "File " + filename + " written successfully!"); else QMessageBox::warning(this, "File Not Saved", "File was not written successfully."); return; }
/** * @brief Slot called when the user attempts to open a file. * @param quest The quest that holds this file. * @param path Path of the file to open. */ void EditorTabs::open_file_requested(Quest& quest, const QString& path) { if (path.isEmpty()) { return; } QFileInfo file_info(path); QString canonical_path = file_info.canonicalFilePath(); if (!quest.is_in_root_path(canonical_path)) { // Not a file of this quest. return; } ResourceType resource_type; QString element_id; if (quest.is_resource_element(canonical_path, resource_type, element_id)) { // A resource element declared in the quest. // Possibly a map data file, an enemy Lua script, // a language directory, etc. open_resource(quest, resource_type, element_id); } else if (quest.is_dialogs_file(canonical_path, element_id)) { open_dialogs_editor(quest, element_id); } else if (quest.is_strings_file(canonical_path, element_id)) { open_strings_editor(quest, element_id); } else if (quest.is_script(canonical_path)) { // A Lua script that is not a resource element. open_text_editor(quest, canonical_path); } else if (quest.is_data_path(canonical_path)) { open_quest_properties_editor(quest); } }
file_info_t * file_query( OBJECT * const path ) { /* FIXME: Add tracking for disappearing files (i.e. those that can not be * detected by stat() even though they had been detected successfully * before) and see how they should be handled in the rest of Boost Jam code. * Possibly allow Jamfiles to specify some files as 'volatile' which would * make Boost Jam avoid caching information about those files and instead * ask the OS about them every time. * * FIXME: Consider returning a clear file_info() result here if * file_query_() fails. Should simplify the caller side error checking and * the caller still can and needs to detect whether the file has not been * successfully detected by the OS, i.e. whether the file_query() call * failed. */ file_info_t * const ff = file_info( path ); if ( timestamp_empty( &ff->time ) ) { if ( file_query_( ff ) < 0 ) return 0; /* Set the path's timestamp to 1 in case it is 0 or undetected to avoid * confusion with non-existing paths. */ if ( timestamp_empty( &ff->time ) ) timestamp_init( &ff->time, 1, 0 ); } return ff; }
void do_ls() { int dev; u32 ino; MINODE* mip; char buf[BLOCK_SIZE]; char temp[BLOCK_SIZE]; char* cp; int i; if (0 == pathName[0]) { printf("ls : current working directory"); ino = running->cwd->ino; dev = running->cwd->dev; } else if (0 == strcmp(pathName, "/")) { printf("ls : root directory"); ino = root->ino; dev = root->dev; } else { printf("ls : "); ino = getino(&dev, pathName); } if ((u32)-1 == ino) { err_printf("ls : it is not a directory\n"); return; } printf("\n"); mip = iget(dev, ino); for (i = 0; i < 12 && (mip->INODE).i_block[i]; i++) { get_block(mip->dev, (mip->INODE).i_block[i], buf); cp = buf; dp = (DIR*)buf; //printf("i_block is %i\n", (int) (mip->INODE).i_block[i]); while (cp < buf + BLOCK_SIZE && dp->rec_len) { if (0 == dp->rec_len) break; strncpy(temp, dp->name, dp->name_len); temp[dp->name_len] = 0; file_info(dev, dp->inode); //printf("%3u %s\n", dp->inode, temp); // with inode printf("%s\n", temp); cp += dp->rec_len; dp = (DIR*)cp; } } iput(mip); }
void MainWindow::openFile(const QString &file) { QFileInfo file_info(file); if (file_info.exists() && !saveChangesBeforeProceeding(tr("Open database"), true)) { addRecent(file_info.absoluteFilePath()); openDB(file_info.absoluteFilePath()); } }
static int info(playa_info_t *info, const char *fname) { if (fname) { return file_info(info, fname); } else { return disk_info(info, 0); } }
int main(int argc, char **argv) { if(parse_options(argc,argv)) { usage(); return 1; } if (return_only) { return 0; } if (version) { std::cout << "Shenidam Version : shenidam-"<< SHENIDAM_VERSION << std::endl; #ifdef SHENIDAM_FFT_THREADED std::cout << "Compiled with threading support for FFTW." << std::endl; #endif #ifdef SHENIDAM_PARALLEL_OMP std::cout << "Compiled with OpenMP support." << std::endl; #endif return 0; } bool has_output = test || send_messages || default_output || out_tracks.size() || can_open_mode; bool has_input = test || in_tracks.size() || can_open_mode; if (quiet && verbose) { verbose = false; } if (!base_set) { fprintf(stderr,"ERROR: A base file is required.\n"); usage(); return 1; } if (!has_output) { fprintf(stderr,"ERROR: No output. One of [-o, -d, -t, -m, -c] is required.\n"); usage(); return 1; } if (!has_input) { fprintf(stderr,"ERROR: No input. One of [-t, -i, -c] is required.\n"); usage(); return 1; } if (test) { return do_test(); } else if (can_open_mode) { return file_info(); } else { return process_audio(); } }
void MainWindow::on_actionOpenFile_triggered(bool) { QString file = QFileDialog::getOpenFileName(this, "Select file", Settings::path("folder"), "All files (*.*);;PNG files(*.png);;JPG files (*.jpg)"); if (file=="") return; QFileInfo file_info(file); Settings::setPath("folder", file_info.canonicalPath()); updateImageList(file_info.canonicalPath(), file_info.fileName()); }
void MainWindow::openFile(const QString &file) { QFileInfo file_info(file); if (rbtnFromFile->isEnabled() && file_info.exists()) { rbtnFromFile->setChecked(true); toggleInputType(rbtnFromFile); DBPathLineEdit->setText(file_info.absoluteFilePath()); loadFile(file_info.absoluteFilePath()); } }
QString Utility::getDirFromFilepath(const QString& path) { QFileInfo file_info(path); QDir dir = file_info.absoluteDir(); QString dirStr = dir.absolutePath(); dirStr.append('/'); QString nativeDir = QDir::toNativeSeparators(dirStr); return nativeDir; }
void TreeLeaf::addAttachments (const QStringList& file_name_list, bool b_delete_files_after, bool b_protect_attachments, unsigned int ui_encrypt_type) { //for preventing second request after click on node m_bIsAttachmentRequestedAlready = true; QSettings settings( g_strCOMPANY, g_str_CNF_APP_NAME ); const unsigned int ui_max_allow_file_size = settings.value(g_str_ATTACH_MAX_SIZE_MB).toInt(); // QStringList::const_iterator constIterator; // for (constIterator = file_name_list.constBegin(); constIterator != file_name_list.constEnd(); ++constIterator) { //check the size of attachment, compare with the max. allow size QFileInfo file_info ((*constIterator)); if ( file_info.exists() ) { const unsigned int ui_current_file_size = file_info.size(); if ( ui_current_file_size/1000000 <= ui_max_allow_file_size) { //create attachment and add it into database Attachment* ptr_new_attachment = new Attachment((*constIterator), this, b_delete_files_after, b_protect_attachments, ui_encrypt_type); m_vAttachments.push_back(ptr_new_attachment); //create new attachments // //QString str_message = placeStatusBarMsg( tr("Importing ") + (*constIterator) + tr("...") ); }else { QString str_message = tr("Attach ") + (*constIterator) + tr(" rejected. Too big."); Logger::getInstance().logIt(en_LOG_ERRORS, str_message ); placeStatusBarMsg( str_message ); }; }; }; //push all attachments object into threadpool, make loading into the dababase { QMutexLocker locker(&m_RequestAttachLocker); Attachment::AttachmentsList::const_iterator itr_attach; // for (itr_attach = m_vAttachments.begin(); itr_attach != m_vAttachments.end(); ++itr_attach) { //add created attachment into database Attachment* ptr_attachment = (*itr_attach); // AdvThreadPool::getInstance().execute(ptr_attachment); //QThreadPool::globalInstance()->start(ptr_attachment); }; }; //inform parent tree (for updating the status of attachments through message) // placeStatusBarMsg( tr("Import done") ); // notifyAboutAttachmentUpdate(true, tr("")); };
int main(int argc, char* argv[]) { file_info(STDIN_FILENO); file_info(STDOUT_FILENO); test_access(); test_faccessat(); test_mode(); test_chown(); test_write_test(); test_unlink(); test_link(); test_mkdir(); test_readdir(); test_openat(); test_ln(); return EXIT_SUCCESS; }
static int check_file(const char *path, const struct stat *info, int typeflag, struct FTW *ftwinfo) { struct tm atime; FILE *f; if (typeflag == FTW_F) { localtime_r(&(info->st_atime), &atime); file_info(f, path, info, &atime); return 0; } return 0; }
int test_main(int /*argc*/, char ** /*argv*/) { { sharp::FileInfo file_info("/foo/bar/baz.txt"); BOOST_CHECK(file_info.get_name() == "baz.txt"); BOOST_CHECK(file_info.get_extension() == ".txt"); } { sharp::FileInfo file_info("/foo/bar/baz."); BOOST_CHECK(file_info.get_name() == "baz."); BOOST_CHECK(file_info.get_extension() == "."); } { sharp::FileInfo file_info("/foo/bar/baz"); BOOST_CHECK(file_info.get_name() == "baz"); BOOST_CHECK(file_info.get_extension() == ""); } { sharp::FileInfo file_info("/foo/bar/.."); BOOST_CHECK(file_info.get_name() == ".."); BOOST_CHECK(file_info.get_extension() == ""); } { sharp::FileInfo file_info("/foo/bar/"); BOOST_CHECK(file_info.get_name() == "bar"); BOOST_CHECK(file_info.get_extension() == ""); } return 0; }
QSharedPointer<QcCachedTileDisk> QcFileTileCache::add_to_disk_cache(const QcTileSpec & tile_spec, const QString & filename) { QSharedPointer<QcCachedTileDisk> tile_directory(new QcCachedTileDisk); tile_directory->tile_spec = tile_spec; tile_directory->filename = filename; tile_directory->cache = this; QFileInfo file_info(filename); int disk_cost = filename.size(); m_disk_cache.insert(tile_spec, tile_directory, disk_cost); return tile_directory; }
void NeutralWriter::operate() { try { QFileInfo file_info(GuiMainWindow::pointer()->getFilename()); readOutputFileName(file_info.completeBaseName() + ".mesh"); if (isValid()) { QFile file(getFileName()); file.open(QIODevice::WriteOnly | QIODevice::Text); QTextStream f(&file); f << m_Grid->GetNumberOfPoints() << "\n"; for (vtkIdType pointId = 0; pointId < m_Grid->GetNumberOfPoints(); ++pointId) { vec3_t x; m_Grid->GetPoints()->GetPoint(pointId, x.data()); f << x[0] << " " << x[1] << " " << x[2] << "\n"; }; vtkIdType Nvol = 0; vtkIdType Nsurf = 0; for (vtkIdType cellId = 0; cellId < m_Grid->GetNumberOfCells(); ++cellId) { vtkIdType cellType = m_Grid->GetCellType(cellId); if ((cellType != VTK_TRIANGLE) && (cellType != VTK_TETRA)) { EG_ERR_RETURN("only simplex elements are allowed for the NEUTRAL format"); }; if (isSurface(cellId, m_Grid)) { ++Nsurf; } else { ++Nvol; }; }; f << Nvol << "\n"; for (vtkIdType cellId = 0; cellId < m_Grid->GetNumberOfCells(); ++cellId) { if (!isSurface(cellId, m_Grid)) { vtkIdType Npts, *pts; m_Grid->GetCellPoints(cellId, Npts, pts); f << "1 " << pts[0]+1 << " " << pts[1]+1 << " " << pts[3]+1 << " " << pts[2]+1 << "\n"; }; }; f << Nsurf << "\n"; EG_VTKDCC(vtkIntArray, cell_code, m_Grid, "cell_code"); for (vtkIdType cellId = 0; cellId < m_Grid->GetNumberOfCells(); ++cellId) { if (isSurface(cellId, m_Grid)) { vtkIdType Npts, *pts; m_Grid->GetCellPoints(cellId, Npts, pts); f << 1;//cell_code->GetValue(cellId); f << " " << pts[2]+1 << " " << pts[1]+1 << " " << pts[0]+1 << "\n"; }; }; }; } catch (Error err) { err.display(); }; };
void removeDirRecursively(const QString &path) { QFileInfo file_info(path); if (file_info.isDir()) { QDir dir(path); QStringList file_list = dir.entryList(); for (int i = 0; i < file_list.count(); ++i) { removeDirRecursively(file_list.at(i)); } removeDirRecursively(path); } else { QFile::remove(path); } }
QString mkvmerge_wrapper::create_output_dir(const QFile &input_file) { QFileInfo file_info(input_file.fileName()); QDir file_dir = file_info.absoluteDir(); QString file_base_name = file_info.baseName(); QString output_dir_name = file_dir.absolutePath() + QDir().separator() + file_base_name + "_output"; if (!QDir(output_dir_name).exists()) { QDir().mkdir(output_dir_name); } return output_dir_name; }
static void file_dirscan_impl( OBJECT * dir, scanback func, void * closure ) { file_info_t * const d = file_query( dir ); if ( !d || !d->is_dir ) return; /* Lazy collect the directory content information. */ if ( list_empty( d->files ) ) { if ( DEBUG_BINDSCAN ) printf( "scan directory %s\n", object_str( d->name ) ); if ( file_collect_dir_content_( d ) < 0 ) return; } /* OS specific part of the file_dirscan operation. */ file_dirscan_( d, func, closure ); /* Report the collected directory content. */ { LISTITER iter = list_begin( d->files ); LISTITER const end = list_end( d->files ); for ( ; iter != end; iter = list_next( iter ) ) { OBJECT * const path = list_item( iter ); file_info_t const * const ffq = file_query( path ); /* The only way a file_query() call can fail is if its internal OS * file information gathering API (e.g. stat()) failed. If that * happens we should treat the file as if it no longer exists. We * then request the raw cached file_info_t structure for that file * and use the file name from there. */ file_info_t const * const ff = ffq ? ffq : file_info( path ); /* Using a file name read from a file_info_t structure allows OS * specific implementations to store some kind of a normalized file * name there. Using such a normalized file name then allows us to * correctly recognize different file paths actually identifying the * same file. For instance, an implementation may: * - convert all file names internally to lower case on a case * insensitive file system * - convert the NTFS paths to their long path variants as that * file system each file system entity may have a long and a * short path variant thus allowing for many different path * strings identifying the same file. */ (*func)( closure, ff->name, 1 /* stat()'ed */, &ff->time ); } } }
int DisplayWindow::add_new_files(const QStringList& files) { #if QT_VERSION >= 0x050400 QString path = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation); #elif QT_VERSION >= 0x050000 QString path = QStandardPaths::writableLocation(QStandardPaths::DataLocation); #else QString path = QDesktopServices::storageLocation(QDesktopServices::DataLocation); #endif path += ("/displays"); QDir dir(path); if (!dir.exists()) if (!dir.mkpath(dir.absolutePath())) return -1; std::vector<QString>& displays = mainwindow->get_displays(); int pos = (int)displays.size(); for (int i = 0; i < files.size(); ++i) { QFileInfo file_info(files[i]); QString name = file_info.completeBaseName(); for (int j = 0; 1; ++j) { QString str; if (!j) str = QString("%1/%2.xsl").arg(dir.absolutePath()).arg(name); else str = QString("%1/%2_%3.xsl").arg(dir.absolutePath()).arg(name).arg(j); QFile info(str); if (info.exists()) continue; QFile::copy(files[i], str); displays.push_back(str); QString script = QString("addUserDisplay('%2');").arg(file_info.completeBaseName()); ((WebPage*)web_view->page())->use_javascript(script); break; } if (i + 1 == files.size()) mainwindow->set_last_load_display_path(file_info.absolutePath().toUtf8().data()); } return pos; }
/** Called by fiwalk main for each extracted file. * the file is created in the /tmp directory. * The plugin outputs a set of name: value pairs on standard output. * This code finds each of those name: value pairs and calls file_info(name,value) * for each. Names and values are passed to file_info as strings. */ void plugin_process(const std::string &fname) { comment("plugin_process",fname.c_str()); static bool first = true; static regex_t ncv; if(first){ if(regcomp(&ncv,"([-a-zA-Z0-9_]+): +(.*)",REG_EXTENDED)) err(1,"regcomp"); first = 0; } if(current_plugin->method=="dgi"){ string cmd = current_plugin->path + " " + fname; FILE *f = popen(cmd.c_str(),"r"); if(!f) err(1,"fopen: %s",cmd.c_str()); char *linebuf=0; size_t linecapp=0; if(getline(&linebuf,&linecapp,f)>0){ char *cc = strchr(linebuf,'\n'); if(cc){ // we found an end-of-line *cc = '\000'; } /* process name: value pairs */ regmatch_t pmatch[4]; memset(pmatch,0,sizeof(pmatch)); if(regexec(&ncv,linebuf,4,pmatch,0)){ fprintf(stderr,"*** FILE: %s line: %u\n",__FILE__,__LINE__); fprintf(stderr,"*** plugin %s returned: '%s'\n", current_plugin->path.c_str(),linebuf); fprintf(stderr,"*** original command line: %s\n",cmd.c_str()); fprintf(stderr,"*** %s will not be deleted.\n",fname.c_str()); exit(1); } linebuf[pmatch[1].rm_eo] = 0; linebuf[pmatch[2].rm_eo] = 0; char *name = linebuf+pmatch[1].rm_so; char *value = linebuf+pmatch[2].rm_so; /* clean any characters in the name */ for(char *cc=name;*cc;cc++){ if (!isalpha(*cc)) *cc='_'; } file_info(name,value); // report each identified name & value free(linebuf); } pclose(f); return; } }
void GMainWindow::OnMenuRecentFile() { QAction* action = qobject_cast<QAction*>(sender()); assert(action); QString filename = action->data().toString(); QFileInfo file_info(filename); if (file_info.exists()) { BootGame(filename.toStdString()); } else { // Display an error message and remove the file from the list. QMessageBox::information(this, tr("File not found"), tr("File \"%1\" not found").arg(filename)); UISettings::values.recent_files.removeOne(filename); UpdateRecentFiles(); } }