void update(void) { StatRec stats; if (check_mnt_table()) get_mnt_table(); cur_changed = False; root_modified = check(rootdir); cur_modified = dirModified(curdir); shelf_modified = dirModified(shelfdir); if (!root_modified && !cur_modified && !shelf_modified) return; if (root_modified || shelf_modified || !dirIsReadable(shelfdir) && !stat(dirName(shelfdir), &stats) && S_ISDIR(stats.st_mode)) WaitMsg("Updating view, please wait ..."); else Wait(); if (root_modified) dirUpdate(rootdir); if (shelf_modified) dirUpdate(shelfdir); else if (!dirIsReadable(shelfdir) && !stat(dirName(shelfdir), &stats) && S_ISDIR(stats.st_mode)) { /* force shelf to be reread */ dirReread(shelfdir); dirReadFileInfo(shelfdir); shelf_modified = True; } cur_check(); Done(); }
Boolean shelf_push(int i, Boolean absolute, Boolean pushdir) { FilePtr file = dirFile(shelfdir, i); String action; char path1[MAXPATHLEN+1], path2[MAXPATHLEN+1]; root_modified = cur_modified = shelf_modified = cur_changed = False; if (file) if (!((action = push_action(fileType(file))) && *action) && S_ISDIR(fileStats(file)->st_mode)) { return cur_chdir(resolve(path1, pathname(path2, dirName(shelfdir), fileName(file)))); } else { Boolean ret = filePush(shelfdir, i, (pushdir && (fileStats(file)->st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))? dirName(curdir):NULL, absolute, True); update(); return ret; } else return False; }
void ZealDocsetsRegistry::addDocset(const QString& path) { auto dir = QDir(path); auto name = dir.dirName().replace(".docset", ""); auto db = QSqlDatabase::addDatabase("QSQLITE", name); if(QFile::exists(dir.filePath("index.sqlite"))) { db.setDatabaseName(dir.filePath("index.sqlite")); db.open(); types.insert(name, ZEAL); } else { auto dashFile = QDir(QDir(dir.filePath("Contents")).filePath("Resources")).filePath("docSet.dsidx"); db.setDatabaseName(dashFile); db.open(); auto q = db.exec("select name from sqlite_master where type='table'"); QStringList tables; while(q.next()) { tables.append(q.value(0).toString()); } if(tables.contains("searchIndex")) { types.insert(name, DASH); } else { types.insert(name, ZDASH); } } dbs.insert(name, db); dirs.insert(name, dir); }
string ModelWriter::getMaterialFile(const string& objFile) { ifstream file(objFile); if(!file.good()) { cerr << "Error examining file " << objFile; exit(1); } char buffer[400]; while(!file.eof()) { file.getline(buffer,sizeof(buffer)); if(strncmp(buffer,"mtllib",6) == 0){ string file = buffer+7; if(file[0] == '.' && file[1] == '/') file = file.substr(2); return dirName(objFile) + file; } } return ""; }
set<string> ModelWriter::getTextures(const string& mtlFile) { set<string> ret; ifstream file(mtlFile); if(!file.good()) { cerr << "ERROR: Could not read material file: " << mtlFile << endl; return set<string>(); } char buffer[300]; while(!file.eof()) { file.getline(buffer,sizeof(buffer)); if(strncmp(buffer,"map_Kd",6) == 0){ string file = buffer+7; if(file[0] == '.' && file[1] == '/') file = file.substr(2); ret.insert(dirName(mtlFile) + file); } } return ret; }
BevelView() : fShapeBounds(SkRect::MakeWH(kShapeBoundsSize, kShapeBoundsSize)) , fControlPanel(kCtrlRange) { this->setBGColor(0xFF666868); // Slightly colorized gray for contrast // Controls fBevelWidth = 25.0f; fBevelHeight = 25.0f; fBevelType = 0; int currLight = 0; fLightDefs[currLight++] = {SkVector::Make(0.0f, 1.0f), 1.0f, SkColor3f::Make(0.6f, 0.45f, 0.3f)}; fLightDefs[currLight++] = {SkVector::Make(0.0f, -1.0f), 1.0f, SkColor3f::Make(0.3f, 0.45f, 0.6f)}; fLightDefs[currLight++] = {SkVector::Make(1.0f, 0.0f), 1.0f, SkColor3f::Make(0.0f, 0.0f, 0.0f)}; // Making sure we initialized all lights SkASSERT(currLight == kNumLights); fControlPanel.add(ContinuousSliderControl::Make(SkString("BevelWidth"), &fBevelWidth, 1.0f, kShapeBoundsSize)); fControlPanel.add(ContinuousSliderControl::Make(SkString("BevelHeight"), &fBevelHeight, -50.0f, 50.0f)); fControlPanel.add(DiscreteSliderControl::Make(SkString("BevelType"), &fBevelType, 0, 2)); sk_sp<ParentControl> lightCtrlSelector = ControlSwitcher::Make(SkString("SelectedLight")); for (int i = 0; i < kNumLights; i++) { SkString name("Light"); name.appendS32(i); sk_sp<ParentControl> currLightPanel = ControlPanel::Make(); SkString dirName(name); dirName.append("Dir"); currLightPanel->add(RadialDirectionControl::Make(dirName, &(fLightDefs[i].fDirXY))); SkString heightName(name); heightName.append("Height"); currLightPanel->add(ContinuousSliderControl::Make(heightName, &(fLightDefs[i].fDirZ), 0.0f, 2.0f)); SkString redName(name); redName.append("Red"); currLightPanel->add(ContinuousSliderControl::Make(redName, &(fLightDefs[i].fColor.fX), 0.0f, 1.0f)); SkString greenName(name); greenName.append("Green"); currLightPanel->add(ContinuousSliderControl::Make(greenName, &(fLightDefs[i].fColor.fY), 0.0f, 1.0f)); SkString blueName(name); blueName.append("Blue"); currLightPanel->add(ContinuousSliderControl::Make(blueName, &(fLightDefs[i].fColor.fZ), 0.0f, 1.0f)); currLightPanel->add(ColorDisplay::Make(&(fLightDefs[i].fColor))); lightCtrlSelector->add(currLightPanel); } fControlPanel.add(lightCtrlSelector); fControlPanelSelected = false; fDirtyNormalSource = true; fLabelTypeface = sk_tool_utils::create_portable_typeface("sans-serif", SkFontStyle()); }
bool Profile::remove() { QStringList dirs = KGlobal::dirs()->findDirs("data", "kdevelop/profiles" + dirName()); if ((dirs.count() == 1) && dirs[0].startsWith(QDir::homeDirPath())) return KIO::NetAccess::del(KURL::fromPathOrURL(dirs[0]), 0); return false; }
void EditBookmarkDialog::changed() { QString dirName(dir()); QDir dirInfo(dirName); // do we have a bookmark at all? bool ok = !dirName.isEmpty(); // does the directory exist if (!ok) ui->labelMessage->setText(tr("Please enter or select a git repository directory")); else { ok = dirInfo.exists(); if (!ok) ui->labelMessage->setText(tr("The directory you entered does not exist")); } // and does it contain a .git directory? if (ok) { QDir gitDir(dirName + "/.git"); ok = gitDir.exists(); if (!ok) ui->labelMessage->setText(tr("The directory you entered is not the base of a git repository")); } if (ok) ui->labelMessage->clear(); QPushButton * okButton = ui->buttonBox->button(QDialogButtonBox::Ok); okButton->setEnabled(ok); }
void FillHistograms(TString SAMPLE) { cout<<"Processing sample "<<SAMPLE<<endl; //TString PATH("root://eoscms//eos/cms/store/cmst3/user/kkousour/ttH/flat/"); TString PATH("/afs/cern.ch/work/k/kkousour/private/CMSSW_7_4_12/src/KKousour/TopAnalysis/prod/ttH/"); TFile *inf = TFile::Open(PATH+"flatTree_"+SAMPLE+".root"); TFile *outf = TFile::Open(TString::Format("Histo_%s.root",SAMPLE.Data()),"RECREATE"); TIter nextKey(inf->GetListOfKeys()); TKey *key; while ((key = (TKey*)nextKey())) { TString dirName(key->GetName()); cout<<"Found directory "<<dirName<<endl; TH1F *hPass = (TH1F*)inf->Get(dirName+"/TriggerPass"); outf->mkdir(dirName); TDirectory *dir = (TDirectory*)outf->Get(dirName); TTree *tr = (TTree*)inf->Get(dirName+"/events"); TreeClass myTree(tr); dir->cd(); hPass->Write("TriggerPass"); myTree.Loop(dir); cout<<"Loop finished"<<endl; dir->Close(); delete tr; } outf->Close(); inf->Close(); }
//Borrara todos los archivos de la carpeta y, en caso de que quede vacia, la carpeta fisica del fileSystem tambien bool ManejadorArchivosYMetadatos::eliminarCarpeta (string username, string path) { string pathConFS = this->pathFileSystem + "/" + path; DIR* dir; struct dirent* ent; if ((dir = opendir(pathConFS.c_str())) == NULL) { Logger::logWarn("No existe el directorio " + path); return false; } while ((ent = readdir(dir)) != NULL) { string dirName(ent->d_name); if (dirName == "." or dirName == "..") continue; string pathInterno = path + "/" + dirName; string pathInternoConFS = this->pathFileSystem + "/" + pathInterno; if (pathInterno.find(RESERVED_CHAR) != string::npos) // es un archivo con nro de version pathInterno = ParserURI::pathSinNroSecuencia(pathInterno); this->eliminar(username, pathInterno); } closedir(dir); if (validador.carpetaVacia(pathConFS)) return manejadorArchivos.deleteCarpeta(pathConFS); else return false; }
bool OS::findFirst(const char* inFindName, FindDataT& outFindData) { char searchName[MAX_PATH]; if (!os_path2native(inFindName, searchName, MAX_PATH)) { return false; // illegal characters } outFindData.privateData = new PrivateFindData; PrivateFindData* pData = static_cast<PrivateFindData*>(outFindData.privateData); // terminate the string at the last path separator to get the directory name std::string dirName(""); std::string fileName(""); const char* end = std::strrchr(inFindName, '/'); // find the last path separator if (end != 0) { char* start = (char*)inFindName; if (start[0] == '/') { dirName = '/'; } while(start != end) { dirName += *start; start++; } end++; //points to start of filename fileName = end; } else { fileName = (char*)inFindName; } dirName = os_makeCanonicalPath(dirName.c_str()); std::strncpy(pData->searchName,fileName.c_str(),FindDataT::MAX_NODE_NAME_SIZE); MAKE_STRING_BUFFER_SAFE(pData->searchName, FindDataT::MAX_NODE_NAME_SIZE); pData->findData = PosixAPI::opendir(dirName.c_str()); if (0 == pData->findData) { return false; } // search for first occurance of file that matches the find criteria pData->entry = PosixAPI::readdir(pData->findData); while (pData->entry != 0) { if (PosixAPI::fnmatch(fileName.c_str(), pData->entry->d_name, FNM_FILE_NAME )==0) { // copy results of find into our platform independent struct if (pData->entry->d_type == DT_DIR) { outFindData.isDirectory = true; } else { outFindData.isDirectory = false; } std::strncpy(const_cast<char*>(outFindData.nodeName), pData->entry->d_name, FindDataT::MAX_NODE_NAME_SIZE); MAKE_STRING_BUFFER_SAFE(const_cast<char*>(outFindData.nodeName), FindDataT::MAX_NODE_NAME_SIZE); break; } pData->entry = PosixAPI::readdir(pData->findData); } return (pData->entry != NULL); }
void saveAllToPicture(std::string fileName, std::string pictureType, std::string directory) { TFile* file = new TFile(fileName.c_str(),"READ"); std::cout<< "begin : saving graphics" <<std::endl; std::string directoryToBeSavedIn; if(directory == "") { // no input directory was given. TString dirName(file->GetName()); dirName.ReplaceAll(".root",""); gSystem->mkdir(dirName,true); directoryToBeSavedIn=dirName.Data(); } else { directoryToBeSavedIn = directory.c_str(); } saveAllHistogramsToPicture (file, pictureType.c_str(), directoryToBeSavedIn); saveAllGraphsToPicture (file, pictureType.c_str(), directoryToBeSavedIn); saveAllCanvasesToPicture (file, pictureType.c_str(), directoryToBeSavedIn); std::cout<< "end : saving graphics" <<std::endl; file->Close(); std::cout<< "input file has been closed" <<std::endl; }
void MainWidget::handleSatelliteMessage( const QByteArray &msg ) { QStringList src( Satellite::split( msg ) ); if( src.size() > 0 ) { if( src.at(0) == "p0p" ) { if( mpFollowPartyman->isChecked() && (src.size() > 1) ) { QFileInfo info( src.at(1) ); QString dirName( info.absolutePath() ); if( info.exists() ) { QModelIndex qmi; for( int i = 1; i >= 0; i = dirName.indexOf( "/", i + 1 ) ) { qmi = mpFileSysModel->index( dirName.left( i ) ); mpFileSysTree->expand( qmi ); } qmi = mpFileSysModel->index( dirName ); mpFileSysTree->setCurrentIndex( qmi ); entryClicked( qmi ); } } } } }
PythonJobInterface::PythonJobInterface( Calamares::PythonJob* parent ) : m_parent( parent ) { auto moduleDir = QDir( m_parent->m_workingPath ); moduleName = moduleDir.dirName().toStdString(); prettyName = m_parent->prettyName().toStdString(); workingPath = m_parent->m_workingPath.toStdString(); configuration = CalamaresPython::variantMapToPyDict( m_parent->m_configurationMap ); }
static SkString make_in_dir_name(int dirIndex) { SkString dirName(IN_DIR); dirName.appendf("%d", dirIndex); if (!sk_exists(dirName.c_str())) { SkDebugf("could not read dir %s\n", dirName.c_str()); return SkString(); } return dirName; }
void cur_check(void) { cur_changed = dirFindSubdir(rootdir, save_cur_path, &curdir) == NULL; if (!curdir) curdir = rootdir; if (cur_changed) update_cur_path(dirName(curdir)); if (!dirHasFileInfo(curdir)) { if (dirIsReadable(curdir) || dirDev(curdir) == NONE && !(dirOptions(curdir) & NOMOUNT)) { int l = strlen(dirName(curdir)) + 8; String msg = alloca((l+1) * sizeof(char)); sprintf(msg, "Reading %s", dirName(curdir)); WaitMsg(msg); } if (dirReadFileInfo(curdir)) cur_modified = True; } }
/////////////////////////////////////////////////////////////////////////////// // Results-file access utilities /////////////////////////////////////////////////////////////////////////////// string Environment::resultFileName(string& dbName, string& testName) { # if defined(__UNIX__) string dirName(dbName + '/' + testName); if (mkdir(dirName.c_str(), 0755)) { if (errno != EEXIST) throw DBCantOpen(dirName); } string fileName(dirName + "/results"); # elif defined(__MS__) string dirName(dbName + '/' + testName); if (!CreateDirectory(dirName.c_str(),0)) { if (GetLastError() != ERROR_ALREADY_EXISTS) throw DBCantOpen(dirName); } string fileName(dirName + "/results"); # endif return fileName; } // Environment::resultFileName
BOOL OpenFileDlg::Exec(char *target, int targ_size, char *title, char *filter, char *defaultDir, char *defaultExt) { if (targ_size <= 1) return FALSE; OPENFILENAME ofn; U8str fileName(targ_size); U8str dirName(targ_size); char *fname = NULL; if (*target && GetFullPathNameU8(target, targ_size, dirName.Buf(), &fname) != 0 && fname) { *(fname -1) = 0; strncpyz(fileName.Buf(), fname, targ_size); } else if (defaultDir) { strncpyz(dirName.Buf(), defaultDir, targ_size); } memset(&ofn, 0, sizeof(ofn)); ofn.lStructSize = sizeof(OPENFILENAME); ofn.hwndOwner = parent ? parent->hWnd : NULL; ofn.lpstrFilter = filter; ofn.nFilterIndex = filter ? 1 : 0; ofn.lpstrFile = fileName.Buf(); ofn.lpstrDefExt = defaultExt; ofn.nMaxFile = targ_size; ofn.lpstrTitle = title; ofn.lpstrInitialDir = dirName.Buf(); ofn.lpfnHook = hook; ofn.Flags = OFN_HIDEREADONLY|OFN_EXPLORER|(hook ? OFN_ENABLEHOOK : 0); if (mode == OPEN || mode == MULTI_OPEN) ofn.Flags |= OFN_FILEMUSTEXIST | (mode == MULTI_OPEN ? OFN_ALLOWMULTISELECT : 0); else ofn.Flags |= (mode == NODEREF_SAVE ? OFN_NODEREFERENCELINKS : 0); ofn.Flags |= flags; U8str dirNameBak(targ_size); GetCurrentDirectoryU8(targ_size, dirNameBak.Buf()); BOOL ret = (mode == OPEN || mode == MULTI_OPEN) ? GetOpenFileNameU8(&ofn) : GetSaveFileNameU8(&ofn); SetCurrentDirectoryU8(dirNameBak.Buf()); if (ret) { if (mode == MULTI_OPEN) { memcpy(target, fileName.Buf(), targ_size); } else { strncpyz(target, ofn.lpstrFile, targ_size); } if (defaultDir) strncpyz(defaultDir, ofn.lpstrFile, ofn.nFileOffset); } return ret; }
// -------------------------------------------------------------------------- // // Function // Name: BackupStoreAccounts::Create(int32_t, int, int64_t, int64_t, const std::string &) // Purpose: Create a new account on the specified disc set. // If rAsUsername is not empty, then the account information will be written under the // username specified. // Created: 2003/08/21 // // -------------------------------------------------------------------------- void BackupStoreAccounts::Create(int32_t ID, int DiscSet, int64_t SizeSoftLimit, int64_t SizeHardLimit, const std::string &rAsUsername) { // Create the entry in the database BackupStoreAccountDatabase::Entry Entry(mrDatabase.AddEntry(ID, DiscSet)); { // Become the user specified in the config file? std::auto_ptr<UnixUser> user; if(!rAsUsername.empty()) { // Username specified, change... user.reset(new UnixUser(rAsUsername.c_str())); user->ChangeProcessUser(true /* temporary */); // Change will be undone at the end of this function } // Get directory name std::string dirName(MakeAccountRootDir(ID, DiscSet)); // Create a directory on disc RaidFileWrite::CreateDirectory(DiscSet, dirName, true /* recursive */); // Create an info file BackupStoreInfo::CreateNew(ID, dirName, DiscSet, SizeSoftLimit, SizeHardLimit); // And an empty directory BackupStoreDirectory rootDir(BACKUPSTORE_ROOT_DIRECTORY_ID, BACKUPSTORE_ROOT_DIRECTORY_ID); int64_t rootDirSize = 0; // Write it, knowing the directory scheme { RaidFileWrite rf(DiscSet, dirName + "o01"); rf.Open(); rootDir.WriteToStream(rf); rootDirSize = rf.GetDiscUsageInBlocks(); rf.Commit(true); } // Update the store info to reflect the size of the root directory std::auto_ptr<BackupStoreInfo> info(BackupStoreInfo::Load(ID, dirName, DiscSet, false /* ReadWrite */)); info->ChangeBlocksUsed(rootDirSize); info->ChangeBlocksInDirectories(rootDirSize); info->AdjustNumDirectories(1); // Save it back info->Save(); // Create the refcount database BackupStoreRefCountDatabase::Create(Entry)->Commit(); } // As the original user... // Write the database back mrDatabase.Write(); }
Boolean cur_drop(int i, int op, SelPtr sel, Boolean absolute, Boolean dirtarget) { Boolean ret; FilePtr file = dirFile(curdir, i); String action; char path[MAXPATHLEN+1]; if (i != NONE) if (!((action = drop_action(fileType(file))) && *action) && S_ISDIR(fileStats(file)->st_mode)) ret = fileMov(op)(sel, pathname(path, dirName(curdir), fileName(file)), absolute); else ret = fileDrop(curdir, i, sel, absolute, dirtarget, False); else ret = fileMov(op)(sel, dirName(curdir), absolute); update(); return ret; }
void ZealDocsetsRegistry::addDocset(const QString& path) { auto dir = QDir(path); auto name = dir.dirName().replace(".docset", ""); QSqlDatabase db; docsetEntry entry; if(QFile::exists(dir.filePath("index.sqlite"))) { db = QSqlDatabase::addDatabase("QSQLITE", name); db.setDatabaseName(dir.filePath("index.sqlite")); db.open(); entry.name = name; entry.prefix = name; entry.type = ZEAL; } else { QDir contentsDir(dir.filePath("Contents")); entry.info.readDocset(contentsDir.absoluteFilePath("Info.plist")); if (entry.info.family == "cheatsheet") { name = QString("%1_cheats").arg(name); } entry.name = name; auto dashFile = QDir(contentsDir.filePath("Resources")).filePath("docSet.dsidx"); db = QSqlDatabase::addDatabase("QSQLITE", name); db.setDatabaseName(dashFile); db.open(); auto q = db.exec("select name from sqlite_master where type='table'"); QStringList tables; while(q.next()) { tables.append(q.value(0).toString()); } if(tables.contains("searchIndex")) { entry.type = DASH; } else { entry.type = ZDASH; } } if(docs.contains(name)){ remove(name); } entry.prefix = entry.info.bundleName.isEmpty() ? name : entry.info.bundleName; entry.db = db; entry.dir = dir; // Read metadata ZealDocsetMetadata meta; meta.read(path+"/meta.json"); entry.metadata = meta; docs[name] = entry; }
bool Process::getLocalSaveDirectory() { QDir dir(m_jobInfo->get(JobInfo::LocalWorkingDirectory)); dir.setFilter(QDir::NoDotAndDotDot | QDir::Files | QDir::Dirs); while (1) { QString dirName(dir.dirName()); dir.cdUp(); QString dirPath(dir.path()); qDebug() << "LocalServer::getSaveDirectory() dirPath: " << dirPath; qDebug() << "LocalServer::getSaveDirectory() dirName: " << dirName; QFileDialog dialog(0, "Save As", dirPath); dialog.selectFile(dirName); dialog.setOption(QFileDialog::ShowDirsOnly, true); // dialog.setFileMode(QFileDialog::DirectoryOnly); dialog.setFileMode(QFileDialog::Directory); if (dialog.exec() == QDialog::Rejected) return false; QStringList list(dialog.selectedFiles()); if (list.isEmpty()) return false; dir.setPath(list.first()); if (dir.path().isEmpty()) return false; if (dir.dirName().contains(" ")) { QMsgBox::warning(0, "IQmol", "Directory name cannot contain spaces"); }else { if (dir.count() == 0) break; QString msg("Directory "); msg += dir.dirName() + " exists, overwrite?"; if (QMsgBox::question(0, "IQmol", msg, QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) { break; } } } QString dirPath(dir.path()); while (dirPath.endsWith("/")) { dirPath.chop(1); } m_jobInfo->set(JobInfo::LocalWorkingDirectory, dirPath); QFileInfo info(dir, m_jobInfo->get(JobInfo::InputFileName)); Preferences::LastFileAccessed(info.filePath()); return true; }
string Buscador::obtenerEstructuraCarpeta (string path, bool esRecursivo, function<bool (MetadatoArchivo&)> predicate) { if ( path.find(RESERVED_STR + "permisos") != string::npos ) return this->obtenerEstructuraCompartidos(path); string pathCompleto = this->pathFileSystem + "/" + path; DIR* dir; if ((dir = opendir(pathCompleto.c_str())) == NULL) { Logger::logWarn("No existe el directorio " + path); return ""; } map<string, string> mapa; struct dirent* ent; while ((ent = readdir(dir)) != NULL) { string dirName(ent->d_name); if ( dirName == "." or dirName == ".." or (esRecursivo and dirName == TRASH) ) continue; string pathInterno = path + "/" + ent->d_name; string pathInternoConFS = this->pathFileSystem + "/" + pathInterno; if (validador.existeCarpeta(pathInternoConFS)) { if (esRecursivo) { string jsonEstructura = obtenerEstructuraCarpeta(pathInterno, true, predicate); mapa = ParserJson::deserializarMapa( ParserJson::estructurasMerge( mapa, jsonEstructura ) ); } else { vector<string> directorios = ParserURI::parsear(pathInterno, '/'); int size = directorios.size(); string foldername = directorios[size - 1]; mapa.insert(pair<string, string>(pathInterno, foldername + "." + FOLDER)); } } else { //Es un archivo pathInterno = ParserURI::pathSinNroSecuencia(pathInterno); if (not dbMetadatos->contains(pathInterno)) { Logger::logWarn("Se quiso obtener los metadatos del archivo " + path + " pero este no existe."); return ""; } string jsonMetadatos = this->dbMetadatos->get(pathInterno); MetadatoArchivo metadato = ParserJson::deserializarMetadatoArchivo(jsonMetadatos); string nombre = metadato.nombre; if (metadato.extension != "") nombre += "." + metadato.extension; nombre += RESERVED_STR + to_string(metadato.ultimaVersion); if ( predicate(metadato) ) { mapa.insert(pair<string, string>(pathInterno, nombre)); } } } closedir(dir); return ParserJson::serializarMapa(mapa); }
/*! \internal Use this to replace all occurences of '*' with directory candidates (if applicable). This method will not work correctly when date tags are still present in path. You should run getOutputFilePath() first. \sa getOutputFilePath */ QString SpdrImportPrivate::substituteStarsInPath(const QString &outputFilePath) const { Q_Q(const SpdrImport); QChar star('*'); if (!outputFilePath.contains(star)) { return outputFilePath; } QStringList outputPathSegments(outputFilePath.split(mPathSeparatorRegularExpression, QString::KeepEmptyParts)); // Go through every segment, see if dir exists, see if there is a name match, // fix the segment. QString pathBuilder; foreach(const QString &segment, outputPathSegments) { if (!pathBuilder.isEmpty()) { pathBuilder.append("/"); } // else if (pathBuilder.isEmpty() && q->outputPath().startsWith('/')) { // pathBuilder.append("/"); // } // Get existing directory names, look for a candidate if (segment.contains(star)) { QDir currentDirectory(pathBuilder); QFileInfoList dirs(currentDirectory.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot)); QString regExpString(segment); // "*" + dirName + "*" QRegularExpression regExp(regExpString); q->log(QCoreApplication::translate("SpdrImportPrivate", "Star matching regular expression set to: %1").arg(regExpString), Spdr::Debug); bool found = false; foreach (const QFileInfo &dirInfo, dirs) { QString dirName(dirInfo.fileName()); if (regExp.match(dirName).hasMatch()) { pathBuilder.append(dirName); found = true; q->log(QCoreApplication::translate("SpdrImportPrivate", "An existing directory that matches wildcard has been found: %1") .arg(dirName), Spdr::ExcessiveLogging); break; } } if (!found) { QString plainDir(segment); pathBuilder.append(plainDir.remove('*')); } } else {
Boolean cur_chdir(String name) { DirPtr newdir; StatRec stats; root_modified = cur_modified = shelf_modified = cur_changed = False; if (!strcmp(dirName(curdir), name) && dirIsReadable(curdir)) return True; else { Wait(); root_modified = True; if (!dirSearchSubdir(rootdir, name, &newdir) || strcmp(dirName(newdir), name)) { if (!newdir) root_modified = False; Done(); return False; } else if (curdir != newdir || !dirIsReadable(curdir)) { int l = strlen(dirName(newdir)) + 8; String msg = alloca((l+1) * sizeof(char)); sprintf(msg, "Reading %s", dirName(newdir)); WaitMsg(msg); cur_modified = cur_changed = True; dirFreeFileInfo(curdir); curdir = newdir; if (dirOptions(curdir) & NOMOUNT) /* force remount */ dirRestat(curdir); if (dirModified(curdir) && dirHasSubdirInfo(curdir)) dirUpdateSubdirInfo(curdir); dirReadFileInfo(curdir); update_cur_path(dirName(curdir)); Done(); return True; } } }
static void FileUtilTest() { WCHAR *path1 = L"C:\\Program Files\\SumatraPDF\\SumatraPDF.exe"; const WCHAR *baseName = path::GetBaseName(path1); assert(str::Eq(baseName, L"SumatraPDF.exe")); ScopedMem<WCHAR> dirName(path::GetDir(path1)); assert(str::Eq(dirName, L"C:\\Program Files\\SumatraPDF")); baseName = path::GetBaseName(dirName); assert(str::Eq(baseName, L"SumatraPDF")); dirName.Set(path::GetDir(L"C:\\Program Files")); assert(str::Eq(dirName, L"C:\\")); dirName.Set(path::GetDir(dirName)); assert(str::Eq(dirName, L"C:\\")); dirName.Set(path::GetDir(L"\\\\server")); assert(str::Eq(dirName, L"\\\\server")); dirName.Set(path::GetDir(L"file.exe")); assert(str::Eq(dirName, L".")); dirName.Set(path::GetDir(L"/etc")); assert(str::Eq(dirName, L"/")); path1 = L"C:\\Program Files"; WCHAR *path2 = path::Join(L"C:\\", L"Program Files"); assert(str::Eq(path1, path2)); free(path2); path2 = path::Join(path1, L"SumatraPDF"); assert(str::Eq(path2, L"C:\\Program Files\\SumatraPDF")); free(path2); path2 = path::Join(L"C:\\", L"\\Windows"); assert(str::Eq(path2, L"C:\\Windows")); free(path2); assert(path::Match(L"C:\\file.pdf", L"*.pdf")); assert(path::Match(L"C:\\file.pdf", L"file.*")); assert(path::Match(L"C:\\file.pdf", L"*.xps;*.pdf")); assert(path::Match(L"C:\\file.pdf", L"*.xps;*.pdf;*.djvu")); assert(path::Match(L"C:\\file.pdf", L"f??e.p?f")); assert(!path::Match(L"C:\\file.pdf", L"*.xps;*.djvu")); assert(!path::Match(L"C:\\dir.xps\\file.pdf", L"*.xps;*.djvu")); assert(!path::Match(L"C:\\file.pdf", L"f??f.p?f")); assert(!path::Match(L"C:\\.pdf", L"?.pdf")); }
void FillHistograms(TString SAMPLE) { cout<<"Processing sample "<<SAMPLE<<endl; TString PATH("../../prod/ttbar/"); TFile *inf = TFile::Open(PATH+"flatTree_"+SAMPLE+".root"); TFile *outf = TFile::Open(TString::Format("Histo_%s.root",SAMPLE.Data()),"RECREATE"); TIter nextKey(inf->GetListOfKeys()); TKey *key; while ((key = (TKey*)nextKey())) { TString dirName(key->GetName()); cout<<"Found directory "<<dirName<<endl; TH1F *hPass = (TH1F*)inf->Get(dirName+"/TriggerPass"); outf->mkdir(dirName); TDirectory *dir = (TDirectory*)outf->Get(dirName); TTree *tr = (TTree*)inf->Get(dirName+"/events"); if (dirName.Contains("Boost")) { TreeClassBoosted myTree(tr); dir->cd(); hPass->Write("TriggerPass"); myTree.Loop(dir); cout<<"Loop finished"<<endl; dir->Close(); cout<<"directory closed"<<endl; delete tr; cout<<"Tree deleted"<<endl; } else { TreeClassResolved myTree(tr); dir->cd(); hPass->Write("TriggerPass"); myTree.Loop(dir); cout<<"Loop finished"<<endl; dir->Close(); cout<<"directory closed"<<endl; delete tr; cout<<"Tree deleted"<<endl; } } outf->Close(); inf->Close(); }
void XMLEditCodeGeneratorWindow::generateOne() { static const char *xmlTools[] = {"xml2atts", "xml2java", "xml2python", "xml2window", "xml2cmake", "xml2info", "xml2avt"}; cleanupProcess(); if(useTools[toolIndex]) { // Create a new process. currentProcess = new QProcess(this); QString xmlTool(PathToVisIt() + xmlTools[toolIndex]); QStringList arguments; arguments << "-clobber"; arguments << xmlFile; // Set the process's working directory. QDir d(xmlFile); QString fullName(d.filePath(d.absolutePath())); int slash = fullName.lastIndexOf("/"); if(slash == -1) slash = fullName.lastIndexOf("\\"); if(slash != -1) { QString dirName(fullName.left(slash)); currentProcess->setWorkingDirectory(dirName); } connect(currentProcess, SIGNAL(readyReadStandardOutput()), this, SLOT(readProcessStdout())); connect(currentProcess, SIGNAL(readyReadStandardError()), this, SLOT(readProcessStderr())); if(toolIndex < ID_XML2AVT) { connect(currentProcess, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(generateOne())); } else {
void Profile::save() { QString profileConfig = locateLocal("data", "kdevelop/profiles" + dirName() + "/profile.config"); KConfig config(profileConfig); config.setGroup("Information"); config.writeEntry("GenericName", m_genericName); config.writeEntry("Description", m_description); config.setGroup("Properties"); config.writeEntry("List", m_properties); config.setGroup("Enable"); config.writeEntry("List", m_explicitEnable); config.setGroup("Disable"); config.writeEntry("List", m_explicitDisable); config.sync(); }
KURL::List Profile::resources(const QString &nameFilter) { QStringList resources; QStringList resourceDirs = KGlobal::dirs()->resourceDirs("data"); for (QStringList::const_iterator it = resourceDirs.begin(); it != resourceDirs.end(); ++it) { QString dir = *it; dir = dir + "kdevelop/profiles" + dirName(); QDir d(dir); const QFileInfoList *infoList = d.entryInfoList(nameFilter, QDir::Files); if (!infoList) continue; for (QFileInfoList::const_iterator infoIt = infoList->constBegin(); infoIt != infoList->constEnd(); ++ infoIt) resources.append((*infoIt)->absFilePath()); } return KURL::List(resources); }