void BenchmarkSet::parseDirectory(const fs::path& dir) { try { // does p actually exist? if(fs::exists(dir)) { if (fs::is_directory(dir)) { // If it is a directory, we add all the contents BENCHMAX_LOG_DEBUG("benchmax", dir << " is a directory."); for (auto it = fs::directory_iterator(dir); it != fs::directory_iterator(); it++) { parseDirectory(*it); } } else if (fs::is_symlink(dir)) { // A symlink. Resolve symlink and call recursively. fs::path r = fs::read_symlink(dir); BENCHMAX_LOG_DEBUG("benchmax", dir << " is a symlink to " << r); parseDirectory(r); } else { // Not a directory, so (we assume?) it is a file. mFilesList.push_back(dir); } } else BENCHMAX_LOG_WARN("benchmax", dir << " does not exist."); } catch(const fs::filesystem_error& ex) { BENCHMAX_LOG_ERROR("benchmax", "Filesystem error: " << ex.what()); } }
void SubComponentManager::parseDirectories() { if (!m_filePath.isEmpty()) { const QString file = m_filePath.toLocalFile(); QFileInfo dirInfo = QFileInfo(QFileInfo(file).path()); if (dirInfo.exists() && dirInfo.isDir()) parseDirectory(dirInfo.canonicalFilePath()); foreach (const QString &subDir, QDir(QFileInfo(file).path()).entryList(QDir::Dirs | QDir::NoDot | QDir::NoDotDot)) { parseDirectory(dirInfo.canonicalFilePath() + "/" + subDir, true, subDir.toUtf8()); } } foreach (const Import &import, m_imports) { if (import.isFileImport()) { QFileInfo dirInfo = QFileInfo(m_filePath.resolved(import.file()).toLocalFile()); if (dirInfo.exists() && dirInfo.isDir()) parseDirectory(dirInfo.canonicalFilePath(), true, dirInfo.baseName().toUtf8()); } else { QString url = import.url(); url.replace(QLatin1Char('.'), QLatin1Char('/')); QFileInfo dirInfo = QFileInfo(url); foreach (const QString &path, importPaths()) { QString fullUrl = path + QLatin1Char('/') + url; dirInfo = QFileInfo(fullUrl); if (dirInfo.exists() && dirInfo.isDir()) { //### todo full qualified names QString nameSpace = import.uri(); parseDirectory(dirInfo.canonicalFilePath(), false); } } } }
ThemeRepository::ThemeRepository( intf_thread_t *pIntf ): SkinObject( pIntf ) { vlc_value_t val, text; // Create a variable to add items in wxwindows popup menu var_Create( pIntf, "intf-skins", VLC_VAR_STRING | VLC_VAR_HASCHOICE | VLC_VAR_ISCOMMAND ); text.psz_string = _("Select skin"); var_Change( pIntf, "intf-skins", VLC_VAR_SETTEXT, &text, NULL ); // Scan vlt files in the resource path OSFactory *pOsFactory = OSFactory::instance( pIntf ); list<string> resPath = pOsFactory->getResourcePath(); list<string>::const_iterator it; for( it = resPath.begin(); it != resPath.end(); it++ ) { parseDirectory( *it ); } // Set the callback var_AddCallback( pIntf, "intf-skins", changeSkin, this ); // variable for opening a dialog box to change skins var_Create( pIntf, "intf-skins-interactive", VLC_VAR_VOID | VLC_VAR_ISCOMMAND ); text.psz_string = _("Open skin ..."); var_Change( pIntf, "intf-skins-interactive", VLC_VAR_SETTEXT, &text, NULL ); // Set the callback var_AddCallback( pIntf, "intf-skins-interactive", changeSkin, this ); }
void MainWindow::on_actionConvertDirectory_triggered() { QString dirName; /* request directory name from user */ dirName = QFileDialog::getExistingDirectory(this,tr("Parse and convert Directory")); if(dirName.isEmpty()) { /* no directory selected, return */ return; } /* create progress dialog */ QProgressDialog progress("Convert Directory...", "Abort converting", 0, 100, this); progress.setWindowModality(Qt::WindowModal); /* go through all files in the directory */ if(!parseDirectory(dirName,parseTypeMessages,true,true,progress)) { QMessageBox::warning(this,"Converte Directory",parser.getLastError()); return; } /* update tree */ updateTree(); /* information about end of operation */ QMessageBox::information(0, QString("DLT Parser"), QString("Parsing and converting directory finished!")); }
ParseFile::ParseFile(QString const& filePath, QString const& filter) { m_filePath = filePath; QFileInfo info(filePath); if (info.isDir()) { parseDirectory(filePath, filter); }else { m_name = info.completeBaseName(); m_filePaths.append(filePath); } }
int main() { Tree * testTree; int (*compare)(void *, void *, void*, void*); void (*destroy)(void *); compare = &comparePointer; destroy = &destroyPointer; testTree = createAVLTree(compare,destroy); parseDirectory("testdir/", testTree); findInTree(testTree, "file.c"); removeFromTree(testTree, "testdir/", "file.c"); destroyAVLTree(testTree); return(0); }
bool MainWindow::parseDirectory(QString dirName, parseType type,bool convert,bool create,QProgressDialog &progress) { QFileInfoList list; QStringList filter; QDir dir(dirName); /* create filter list for files */ filter.append(QString("*.h")); filter.append(QString("*.c")); filter.append(QString("*.cpp")); filter.append(QString("*.cxx")); /* parse files in current directory */ list = dir.entryInfoList(filter,QDir::Files); progress.setMaximum(progress.maximum()+list.size()); for(int i = 0;i<list.size();i++) { /* increase progress bar */ progress.setValue(progress.value()+1); if(convert) { if(!parser.converteFile(list.at(i).absoluteFilePath())) return false; } else { if(!parser.parseFile(list.at(i).absoluteFilePath())) return false; } progress.setLabelText(list.at(i).absoluteFilePath()); } /* go recursive through all the subdiectories */ list = dir.entryInfoList(QDir::Dirs|QDir::NoDotAndDotDot); for(int i = 0;i<list.size();i++) { if(!parseDirectory(list.at(i).absoluteFilePath(),type,convert,create,progress)) return false; } return true; }
void parse(File file, VolumeEntry *vol) { if ( file.isDirectory( ) == true ) { vol->name = file.getName(); for(size_t i = 0; i < vol->name.size(); i++) { if ( changeCase == 1 ) vol->name[i] = to_upper( vol->name[i] ); else if(changeCase == 2) vol->name[i] = to_lower( vol->name[i] ); } printf("+ %s\n", vol->name.c_str()); vol->type = 0; parseDirectory(file, vol); } else { //printf("\"%s\"\n", file.getName().c_str()); vol->name = file.getName(); for(size_t i = 0; i < vol->name.size(); i++) { if ( changeCase == 1 ) vol->name[i] = to_upper( vol->name[i] ); else if ( changeCase == 2 ) vol->name[i] = to_lower( vol->name[i] ); } printf("++ %s\n", vol->name.c_str()); vol->type = 1; vol->dataOffset = fileDataPtr; vol->dataLength = readFile(file.getAbsolutePath().c_str()); return; } }
void MainWindow::on_actionParseDirectory_triggered() { QString dirName; /* request directory name from user */ dirName = QFileDialog::getExistingDirectory(this,tr("Parse Directory")); if(dirName.isEmpty()) { /* no directory selected, return */ return; } /* create progress dialog */ QProgressDialog progress("Parsing Directory...", "Abort parsing", 0, 100, this); progress.setWindowModality(Qt::WindowModal); progress.setMinimumDuration(1000); /* go through all files in the directory */ if(!parseDirectory(dirName,parseTypeContexts,false,true,progress)) { progress.close(); QMessageBox::warning(this,"Parse Directory",parser.getLastError()); return; } progress.close(); // update message ids and application/context ids if(!parser.parseCheck()) { QMessageBox::warning(this,"Parse Directory",parser.getLastError()); return; } /* update tree */ updateTree(); }
void parseDirectory( Driver& driver, QDir& dir, bool rec, bool parseAllFiles ) { QStringList fileList; if ( parseAllFiles ) fileList = dir.entryList( QDir::Files ); else fileList = dir.entryList( "*.h;*.H;*.hh;*.hxx;*.hpp;*.tlh" ); QStringList::Iterator it = fileList.begin(); while ( it != fileList.end() ) { QString fn = dir.path() + "/" + ( *it ); ++it; driver.parseFile( fn ); } if ( rec ) { QStringList fileList = dir.entryList( QDir::Dirs ); QStringList::Iterator it = fileList.begin(); while ( it != fileList.end() ) { if ( ( *it ).startsWith( "." ) ) { ++it; continue; } QDir subdir( dir.path() + "/" + ( *it ) ); ++it; parseDirectory( driver, subdir, rec, parseAllFiles ); } } }
int main(int argc, char **argv) { if(argc<2) { printf( "MAUtil::MAFS Bundle tool\n\n" "This tool is used to build a binary image of a folder on a desktop computer.\n\n" "Usage:\n" "bundle <parameters>\n\n" "Parameters:\n" " -in <input file or folder> the input files or folders to add to the\n" " image (multiple -in directives may be added).\n" " -out <output file> the name of the image to be created (only one).\n" " -toUpper/-toLower change case of all file names to upper or lower\n" " case.\n\n" "Example:\n" " bundle -in data -out anotherworld.bun -toLower\n" ); } for(int i = 1; i < argc; i++) { if(strcmp(argv[i], "-in")==0) { i++; if(i>=argc) { printf("not enough parameters for -in"); return 1; } inFiles.push_back(argv[i]); } else if(strcmp(argv[i], "-out")==0) { if(outFile) { printf("cannot have multiple out files."); return 1; } i++; if(i>=argc) { printf("not enough parameters for -out"); return 1; } outFile = fopen(argv[i], "wb"); } else if(strcmp(argv[i], "-toUpper")==0) { changeCase = 1; } else if(strcmp(argv[i], "-toLower")==0) { changeCase = 2; } else { printf("invalid argument"); return 1; } } if(inFiles.size()==0) return 1; if(!outFile) return 1; VolumeEntry* root = new VolumeEntry; root->name = "Root"; root->type = 0; // directory for(size_t i = 0; i < inFiles.size(); i++) { File file(inFiles[i]); if(file.isDirectory()) { parseDirectory(file, root); } else { VolumeEntry *child = new VolumeEntry; root->children.push_back(child); parse(file, child); } } fseek(outFile, START_OF_VOLUME_ENTRIES, SEEK_SET); saveVolumeEntries(root); saveFileData(); writeHeader(); fclose(outFile); return 0; }
ThemeRepository::ThemeRepository( intf_thread_t *pIntf ): SkinObject( pIntf ) { vlc_value_t val, text; // Create a variable to add items in wxwindows popup menu var_Create( pIntf, "intf-skins", VLC_VAR_STRING | VLC_VAR_HASCHOICE | VLC_VAR_ISCOMMAND ); text.psz_string = _("Select skin"); var_Change( pIntf, "intf-skins", VLC_VAR_SETTEXT, &text, NULL ); // Scan vlt files in the resource path OSFactory *pOsFactory = OSFactory::instance( pIntf ); list<string> resPath = pOsFactory->getResourcePath(); list<string>::const_iterator it; for( it = resPath.begin(); it != resPath.end(); ++it ) { parseDirectory( *it ); } // retrieve skins from skins directories and locate default skins map<string,string>::const_iterator itmap, itdefault; for( itmap = m_skinsMap.begin(); itmap != m_skinsMap.end(); ++itmap ) { string name = itmap->first; string path = itmap->second; val.psz_string = (char*) path.c_str(); text.psz_string = (char*) name.c_str(); var_Change( getIntf(), "intf-skins", VLC_VAR_ADDCHOICE, &val, &text ); if( name == "Default" ) itdefault = itmap; } // retrieve last skins stored or skins requested by user char* psz_current = var_InheritString( getIntf(), "skins2-last" ); string current = string( psz_current ? psz_current : "" ); free( psz_current ); // check if skins exists and is readable bool b_readable = !ifstream( current.c_str() ).fail(); msg_Dbg( getIntf(), "requested skins %s is %s accessible", current.c_str(), b_readable ? "" : "NOT" ); // set the default skins if given skins not accessible if( !b_readable ) current = itdefault->second; // save this valid skins for reuse config_PutPsz( getIntf(), "skins2-last", current.c_str() ); // Update repository updateRepository(); // Set the callback var_AddCallback( pIntf, "intf-skins", changeSkin, this ); // variable for opening a dialog box to change skins var_Create( pIntf, "intf-skins-interactive", VLC_VAR_VOID | VLC_VAR_ISCOMMAND ); text.psz_string = _("Open skin ..."); var_Change( pIntf, "intf-skins-interactive", VLC_VAR_SETTEXT, &text, NULL ); // Set the callback var_AddCallback( pIntf, "intf-skins-interactive", changeSkin, this ); }
int MainWindow::argsParser() { if(!argReadFibex.isEmpty()) { /* read Fibex */ parser.readFibex(argWriteFibex); } if(!argParseCfg.isEmpty()) { if(!parser.parseConfiguration(argParseCfg)) { std::cout << "Error: Parse Cfg: "<< parser.getLastError().toLatin1().data() << std::endl; return -1; } // update message ids and application/context ids if(!parser.parseCheck()) { std::cout << "Error: Parse Cfg: "<< parser.getLastError().toLatin1().data() << std::endl; return -1; } if(!noGui) /* update tree */ updateTree(); } if(!argParseFile.isEmpty()) { /* parse file */ if(!parser.parseFile(argParseFile)) { std::cout << "Error: Parse File: "<< parser.getLastError().toLatin1().data() << std::endl; return -1; } // update message ids and application/context ids if(!parser.parseCheck()) { std::cout << "Error: Parse File: "<< parser.getLastError().toLatin1().data() << std::endl; return -1; } if(!noGui) /* update tree */ updateTree(); } if(!argParseDir.isEmpty()) { /* create progress dialog */ QProgressDialog progress("Parsing Directory...", "Abort parsing", 0, 100, this); progress.setWindowModality(Qt::WindowModal); progress.setMinimumDuration(1000); /* go through all files in the directory */ if(!parseDirectory(argParseDir,parseTypeContexts,false,true,progress)) { progress.close(); std::cout << "Error: Parse Directory: "<< parser.getLastError().toLatin1().data() << std::endl; return -1; } progress.close(); // update message ids and application/context ids if(!parser.parseCheck()) { std::cout << "Error: Parse Directory: "<< parser.getLastError().toLatin1().data() << std::endl; return -1; } if(!noGui) /* update tree */ updateTree(); progress.close(); } if(!argConverteFile.isEmpty()) { /* parse file */ if(!parser.converteFile(argConverteFile)) { std::cout << "Error: Converte File: "<< parser.getLastError().toLatin1().data() << std::endl; return -1; } } if(!argConverteDir.isEmpty()) { /* create progress dialog */ QProgressDialog progress("Parsing Directory...", "Abort parsing", 0, 100, this); progress.setWindowModality(Qt::WindowModal); progress.setMinimumDuration(1000); /* go through all files in the directory */ if(!parseDirectory(argConverteDir,parseTypeContexts,true,true,progress)) { progress.close(); std::cout << "Error: Converte Directory: "<< parser.getLastError().toLatin1().data() << std::endl; return -1; } progress.close(); } if(!argUpdateIdStart.isEmpty() && !argUpdateIdEnd.isEmpty()) { /* update Ids */ if(!parser.generateId(argUpdateIdStart.toUInt(),argUpdateIdEnd.toUInt(),false)) { std::cout << "Error: Update IDs: "<< parser.getLastError().toLatin1().data() << std::endl; return -1; } } if(!argUpdateIdAppStart.isEmpty() && !argUpdateIdAppEnd.isEmpty()) { /* update Ids App */ if(!parser.generateId(argUpdateIdAppStart.toUInt(),argUpdateIdAppEnd.toUInt(),true)) { std::cout << "Error: Update IDs App: "<< parser.getLastError().toLatin1().data() << std::endl; return -1; } } if(checkDouble) { /* check for double Ids */ QString text; if(!parser.checkDoubleIds(text,false)) { std::cout << "Error: Check Double: "<< parser.getLastError().toLatin1().data() << std::endl; std::cout << "Double Ids: "<< text.toLatin1().data() << std::endl; return -1; } } if(checkDoubleApp) { /* check for double Ids App */ QString text; if(!parser.checkDoubleIds(text,true)) { std::cout << "Error: Check Double IDs App: "<< parser.getLastError().toLatin1().data() << std::endl; std::cout << "Double Ids: "<< text.toLatin1().data() << std::endl; return -1; } } if(!argWriteFibex.isEmpty()) { /* write Fibex */ if(!parser.writeFibex(argWriteFibex)) { std::cout << "Error: Write Fibex: "<< parser.getLastError().toLatin1().data() << std::endl; return -1; } } if(!argWriteCsv.isEmpty()) { /* write CSV */ if(!parser.writeCsv(argWriteCsv)) { std::cout << "Error: Write CSV: "<< parser.getLastError().toLatin1().data() << std::endl; return -1; } } if(!argWriteId.isEmpty()) { /* write IDs Header */ if(!parser.writeIdHeader(argWriteId,false)) { std::cout << "Error: Write IDs Header: "<< parser.getLastError().toLatin1().data() << std::endl; return -1; } } if(!argWriteIdApp.isEmpty()) { /* write IDs Header App */ if(!parser.writeIdHeader(argWriteIdApp,true)) { std::cout << "Error: Write IDs Header App: "<< parser.getLastError().toLatin1().data() << std::endl; return -1; } } return 0; }
BenchmarkSet::BenchmarkSet(const fs::path& baseDir): mFilesList() { parseDirectory(baseDir); }
int main( int argc, char* argv[] ) { KStandardDirs stddir; if ( argc < 3 ) { std::cerr << "usage: r++ dbname directories..." << std::endl << std::endl; return -1; } bool rec = false; bool parseAllFiles = false; QString datadir = stddir.localkdedir() + "/" + KStandardDirs::kde_default( "data" ); if ( ! KStandardDirs::makeDir( datadir + "/kdevcppsupport/pcs/" ) ) { kdWarning() << "*error* " << "could not create " << datadir + "/kdevcppsupport/pcs/" << endl << endl; return -1; } if ( !QFile::exists( datadir + "/kdevcppsupport/pcs/" ) ) { kdWarning() << "*error* " << datadir + "/kdevcppsupport/pcs/" << " doesn't exists!!" << endl << endl; return -1; } QString dbFileName = datadir + "/kdevcppsupport/pcs/" + argv[ 1 ] + ".db"; // std::cout << "dbFileName = " << dbFileName << std::endl; if ( QFile::exists( dbFileName ) ) { kdWarning() << "*error* " << "database " << dbFileName << " already exists!" << endl << endl; return -1; } Catalog catalog; catalog.open( dbFileName ); catalog.addIndex( "kind" ); catalog.addIndex( "name" ); catalog.addIndex( "scope" ); catalog.addIndex( "fileName" ); RppDriver driver( &catalog ); driver.setResolveDependencesEnabled( true ); for ( int i = 2; i < argc; ++i ) { QString s( argv[ i ] ); if ( s == "-r" || s == "--recursive" ) { rec = true; continue; } else if ( s == "-a" || s == "--all" ) { parseAllFiles = true; continue; } else if ( s == "-f" || s == "--fast" ) { driver.setResolveDependencesEnabled( false ); continue; } else if ( s == "-c" || s == "--check-only" ) { driver.setGenerateTags( false ); continue; } else if ( s.startsWith( "-d" ) ) { driver.addDocDirectory( s.mid( 2 ) ); continue; } QDir dir( s ); if ( !dir.exists() ) { kdWarning() << "*error* " << "the directory " << dir.path() << " doesn't exists!" << endl << endl; continue; } parseDirectory( driver, dir, rec, parseAllFiles ); } return 0; }