bool CommandDir::execute() { fs::directory_iterator end_iter; const char* fullPathBuff; // command recognized sock->writeline("0"); if(choosenDirectory.size() == 0) fullPathBuff = string(Settings::getInstance().getCwd()).c_str(); else fullPathBuff = string(Settings::getInstance().getCwd()).append(choosenDirectory).c_str(); // check if path exists and is a directory if(!fs::exists(fullPathBuff) || !fs::is_directory(fullPathBuff)) { sock->writeline("1"); return true; } for( fs::directory_iterator dir_iter(fullPathBuff) ; dir_iter != end_iter ; ++dir_iter) { if (fs::is_regular_file(dir_iter->status()) || fs::is_directory(dir_iter->status()) ) { std::string buff(":"); sock->writeline(buff.append(dir_iter->path().filename().c_str()).c_str()); } } sock->writeline("0"); return true; }
void MainWidget::setIconWidgetPath(QString path) { QStandardItemModel* fModel = qobject_cast<QStandardItemModel*>(iView->model()); if(!fModel) { fModel = new QStandardItemModel; iView->setModel(fModel); } fModel->clear(); QStringList filter; filter<<QString("*.jpeg")<<QString("*.jpg")<<QString("*.png")<<QString("*.gif")<<QString("*.bmp"); QDirIterator dir_iter(path, filter, QDir::Files | QDir::NoSymLinks, QDirIterator::NoIteratorFlags); if(dir_iter.hasNext()){ while(dir_iter.hasNext()){ dir_iter.next(); QString file = dir_iter.fileInfo().absoluteFilePath(); QImage img(file); if(!img.isNull()){ QPixmap pix = QPixmap::fromImage(img); if(pix.size().width() > 300 || pix.size().height()>300){ pix = pix.scaled(200,200, Qt::KeepAspectRatio); //,Qt::SmoothTransformation) } QStandardItem* item = new QStandardItem(QIcon(pix),file.mid(file.lastIndexOf("/")+1)); item->setData(QVariant(file),Qt::WhatsThisRole); fModel->appendRow(item); } } } }
void ExpressionClassifier::setup(std::string appPath) { boost::filesystem::path expressionsFolder(appPath + "/Contents/Resources/Expressions"); std::cout << expressionsFolder; boost::filesystem::directory_iterator end_iter; if ( boost::filesystem::exists(expressionsFolder) && boost::filesystem::is_directory(expressionsFolder)) { std::cout << "Known expressions: " << std::endl; for( boost::filesystem::directory_iterator dir_iter(expressionsFolder) ; dir_iter != end_iter ; ++dir_iter) { if (boost::filesystem::is_regular_file(dir_iter->status()) && !(dir_iter->path().filename().string().compare(".DS_Store") == 0)) { std::cout << *dir_iter << std::endl; ci::XmlTree doc( ci::loadFile( *dir_iter )); ci::XmlTree expression = doc.getChild("expression"); std::map<std::string, std::string> expressionDoc; for( ci::XmlTree::Iter child = expression.begin(); child != expression.end(); ++child ) expressionDoc[child->getTag()] = child->getValue(); knownExpressions.push_back(Expression(dir_iter->path().filename().string(), boost::lexical_cast<float>(expressionDoc["mouthWidth"]), boost::lexical_cast<float>(expressionDoc["mouthHeight"]), boost::lexical_cast<float>(expressionDoc["eyebrowLeft"]), boost::lexical_cast<float>(expressionDoc["eyebrowRight"]), boost::lexical_cast<float>(expressionDoc["eyeLeft"]), boost::lexical_cast<float>(expressionDoc["eyeRight"]), boost::lexical_cast<float>(expressionDoc["jaw"]), boost::lexical_cast<float>(expressionDoc["nostrils"]))); } } } }
bool init_unit_test_suite() { if(!boost::filesystem::is_directory(test_dir.c_str())) { return false; } std::vector<std::string> test_files; boost::filesystem::directory_iterator dir_iter(test_dir); boost::filesystem::directory_iterator end_dir_iter; std::for_each( dir_iter, end_dir_iter , [&test_files](boost::filesystem::path file) { if(file.extension() == ".input") { file.replace_extension(""); test_files.push_back(file.string()); } } ); std::cout << "Found " << test_files.size() << " test cases." << std::endl; for(auto & test : test_files) { std::cout << " " << test << std::endl; } boost::unit_test::framework::master_test_suite().add( BOOST_PARAM_TEST_CASE( &test_parse , test_files.begin() , test_files.end() ) ); return true; }
void FileFinder::findFiles(fs::path aDir, file_path_list_t& cwd_paths, bool as_thread) { typedef std::list<file_path_list_t> child_paths_t; typedef std::list<file_path_list_t>::iterator child_paths_iterator_t; child_paths_t child_paths; if ( fs::exists(aDir) && fs::is_directory(aDir)) { boost::thread_group threads; fs::directory_iterator end_iter; for( fs::directory_iterator dir_iter(aDir) ; dir_iter != end_iter ; ++dir_iter) { if (fs::is_regular_file(dir_iter->status()) ) { if (fileExtMatch(dir_iter->path())) { cwd_paths.push_back(dir_iter->path()); } } else if (fs::is_directory(dir_iter->status())) { file_path_list_t child; child_paths.push_back(child); if (p_thread_counter->TryInc()) { threads.create_thread( boost::bind(&FileFinder::findFiles, this, dir_iter->path(), boost::ref(child_paths.back()),true)); } else { findFiles(dir_iter->path(), boost::ref(child_paths.back()), false); } } else { std::cerr << "Skipping: " << dir_iter->path() << std::endl; } } threads.join_all(); //cwd_paths.sort(); if (child_paths.size()) { child_paths_iterator_t child_end = child_paths.end(); child_paths_iterator_t child_itr = child_paths.begin(); while(child_itr != child_end) { cwd_paths.merge(*child_itr); ++child_itr; } } } if (as_thread) { p_thread_counter->Dec(); } }
/** * @brief Read descriptors folder to memory * * @param data_path data path * @param data data in cv::Mat format * @param labels in cv::Mat format */ static void GetBaseDataSet(const fs::path &data_path, cv::Mat *data, cv::Mat *labels) { fs::directory_iterator eod; boost::smatch what; boost::regex filter(".*dat"); // collect all action descriptors for(fs::directory_iterator dir_iter(data_path) ; (dir_iter != eod); ++dir_iter) { if ((fs::is_regular_file(*dir_iter)) && (boost::regex_match(dir_iter->path().string(), what, filter))) { MatReader mr; std::string filename; cv::Mat desc; float label = -1; filename = fs::basename(dir_iter->path()); for (int action_type = 0; action_type < ACTIONS_NUM; action_type++) { if (filename.find(ActionClassifier::actions_names_[action_type]) != std::string::npos) { label = (float)action_type; break; } } if (label < 0) continue; LOGI() << "Extracting descriptors from " << filename << std::endl; CHECK(mr.Init(dir_iter->path().string()) == 0); while (mr.Read(&desc) == 0) { for (int desc_idx = 0; desc_idx < desc.cols; desc_idx++) { data->push_back(desc.col(desc_idx).reshape(1,1)); labels->push_back(label); } } } } }
void ScintillaEditor::enumerateColorSchemesInPath(ScintillaEditor::colorscheme_set_t &result_set, const fs::path path) { const fs::path color_schemes = path / "color-schemes" / "editor"; fs::directory_iterator end_iter; if (fs::exists(color_schemes) && fs::is_directory(color_schemes)) { for (fs::directory_iterator dir_iter(color_schemes); dir_iter != end_iter; ++dir_iter) { if (!fs::is_regular_file(dir_iter->status())) { continue; } const fs::path path = (*dir_iter).path(); if (!(path.extension() == ".json")) { continue; } EditorColorScheme *colorScheme = new EditorColorScheme(path); if (colorScheme->valid()) { result_set.insert(colorscheme_set_t::value_type(colorScheme->index(), shared_ptr<EditorColorScheme>(colorScheme))); } else { delete colorScheme; } } } }
void CleanFolder(const fs::path& rPath, bool isTop) { assert(fs::is_directory(rPath)); fs::directory_iterator end_iter; // First recursively remove the children for (fs::directory_iterator dir_iter(rPath); dir_iter != end_iter; ++dir_iter) { if (fs::is_directory(dir_iter->status())) { CleanFolder(dir_iter->path(), false); } else { const fs::path& r_item_path(dir_iter->path()); if (!isTop || PATH_LEAF_NAME(r_item_path)[0] != '.') { fs::remove(r_item_path); } } } // Now remove the folder itself, if not top if (!isTop) { fs::remove(rPath); } }
void LLImageFiltersManager::loadFiltersFromDir(const std::string& dir) { mFiltersList.clear(); LLDirIterator dir_iter(dir, "*.xml"); while (1) { std::string file_name; if (!dir_iter.next(file_name)) { break; // no more files } // Get the ".xml" out of the file name to get the filter name. That's the one known in strings.xml std::string filter_name_untranslated = file_name.substr(0,file_name.length()-4); // Get the localized name for the filter std::string filter_name_translated; bool translated = LLTrans::findString(filter_name_translated, filter_name_untranslated); std::string filter_name = (translated ? filter_name_translated: filter_name_untranslated); // Store the filter in the list with its associated file name mFiltersList[filter_name] = file_name; } }
bool Replay::load(){ data.clear(); std::string file_to_load; if(ptr_record->get_last_saved_file() == ""){ ROS_INFO("record_folder: %s",record_folder.c_str()); boost::filesystem::path save_dir(record_folder); boost::filesystem::directory_iterator end_iter; if (boost::filesystem::exists(save_dir) && boost::filesystem::is_directory(save_dir)){ for( boost::filesystem::directory_iterator dir_iter(save_dir) ; dir_iter != end_iter ; ++dir_iter){ if (boost::filesystem::is_regular_file(dir_iter->status()) ){ file_to_load = (*dir_iter).path().string(); break; } } } }else{ file_to_load = ptr_record->get_last_saved_file(); } std::ifstream file(file_to_load, std::ios_base::in); if(file.is_open()){ ROS_INFO("loading: %s",boost::filesystem::path(file_to_load).stem().string().c_str()); while (!file.eof()){ file >> data_t.x >> data_t.y >> data_t.z >> data_t.roll >> data_t.pitch >> data_t.yaw; data.push_back(data_t); } file.close(); // ROS_INFO("number samples ===> %d",data.size()); return true; }else{
//This gets the path/time of creation for a given directory void fill_directory_map(fs::path dir_path, result_map &map){ fs::directory_iterator end_iter; for(fs::directory_iterator dir_iter(dir_path); dir_iter != end_iter ; ++dir_iter){ if(fs::is_regular_file(dir_iter->status()) && dir_iter->path().filename().string() != METADATA){ map.insert(result_map::value_type(fs::last_write_time(dir_iter->path()), *dir_iter)); } } }
void StackComponentManager::addRepository(std::string repoPath) { while(!repoPath.empty()) { //Extract paths from the repository string size_t pos = repoPath.find_first_of(';'); string str(repoPath, 0, pos); repoPath.erase(0, pos); // break out of the while if str is empty (e.g. with a repos="/path/to/1;") if (str.empty()) break; bfs::path currentPath(str); //Check that the path exists and is a directory if(!bfs::exists(currentPath) || !bfs::is_directory(currentPath)) { LOG(LFATAL) << "Could not add repository " << str << " path does not exist or is not a directory."; throw ResourceNotFoundException("Could not add repository " + str + " path does not exist or is not a directory."); } //Create a repository object Repository tmp; tmp.path = currentPath; //Go through files in the repository and add to the repository vector of component libraries bfs::directory_iterator dir_iter(currentPath), dir_end; for(;dir_iter != dir_end; ++dir_iter) { //Check that the file path contains the system library extension #if BOOST_FILESYSTEM_VERSION == 2 string filename = dir_iter->path().leaf(); #else string filename = dir_iter->path().filename().string(); #endif size_t pos = filename.find_last_of('.'); if(pos != string::npos) { string extension = filename.substr(pos); if(extension == SharedLibrary::getSystemExtension()) { size_t pre = SharedLibrary::getSystemPrefix().length(); string stem = filename.substr(pre,pos-pre); //Remove library prefix and postfix ComponentLibrary current; current.path = dir_iter->path(); current.name = stem; boost::to_lower(current.name); tmp.componentLibs.push_back(current); } } } //Add to vector of repository paths repositories_.push_back(tmp); } }
int run_lexer_on_directory( const std::string & directory ) { // iterate over the directory looking for all .cpp files llvm::error_code ec; for( llvm::sys::fs::directory_iterator dir_iter( directory, ec ), end; dir_iter != end; dir_iter.increment( ec ) ) { if( ".cpp" == llvm::sys::path::extension( dir_iter->path() ).str() ) run_lexer_on_file( dir_iter->path() ); } return 0; }
void SoundManager::MP3Lookup(boost::filesystem::path dir) { boost::filesystem::directory_iterator dir_iter(dir), dir_end; std::string mp3extension = ".mp3"; for(;dir_iter != dir_end; dir_iter++) { if(boost::filesystem::extension(*dir_iter) == mp3extension) { files.push_back(*dir_iter); } } }
int SplitDataSet(const char *base_path_char, const char *split_path_char, float split_ratio) { RandGen rand_gen; fs::path base_path(base_path_char), split_path(split_path_char), desc_base_path[DESCRIPTORS_NUM], desc_split_path[DESCRIPTORS_NUM]; fs::directory_iterator eod; boost::smatch what; boost::regex filter(".*dat"); CHECK(fs::exists(base_path)); // if doesn't exist create a split folder try { if (fs::is_directory(split_path) == false) fs::create_directories(split_path); } catch(boost::filesystem::filesystem_error e) { LOGF() << "Failed to create split folder: " << split_path << std::endl; return -1; } for (int desc_type = 0; desc_type < DESCRIPTORS_NUM; desc_type++) { desc_base_path[desc_type] = base_path/fs::path(ActionClassifier::desc_names_[desc_type]); desc_split_path[desc_type] = split_path/fs::path(ActionClassifier::desc_names_[desc_type]); CHECK(fs::exists(desc_base_path[desc_type])); // if doesn't exist create a split folder try { if (fs::is_directory(desc_split_path[desc_type]) == false) fs::create_directories(desc_split_path[desc_type]); } catch(boost::filesystem::filesystem_error e) { LOGF() << "Failed to create split folder: " << desc_split_path[desc_type] << std::endl; return -1; } } for(fs::directory_iterator dir_iter(desc_base_path[TRJ]) ; (dir_iter != eod); ++dir_iter) { if ((fs::is_regular_file(*dir_iter)) && (boost::regex_match(dir_iter->path().string(), what, filter))) { // randomly split base folder, move ALL descriptors for a specific action if (rand_gen.RandFloat(1.0f) < split_ratio) { std::string filename = dir_iter->path().filename().string(); for (int desc_type = 0; desc_type < DESCRIPTORS_NUM; desc_type++) { fs::path org_path = desc_base_path[desc_type]/fs::path(filename); fs::path new_path = desc_split_path[desc_type]/fs::path(filename); LOGI() << "Moving " << org_path.string() << " to " << new_path.string() << std::endl; fs::rename(org_path, new_path); } } } } return 0; }
void FSPanelPrefs::populateCloudCombo() { LLComboBox* cloud_combo = findChild<LLComboBox>("cloud_combo"); if (cloud_combo) { const std::string cloudDir(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight" + gDirUtilp->getDirDelimiter() + "clouds")); LLDirIterator dir_iter(cloudDir, "*.tga"); std::string file; while (dir_iter.next(file)) { cloud_combo->add(file); } cloud_combo->setSimple(gSavedSettings.getString("FSCloudTexture")); } }
void BuildFilesList( fs::path Dir, PathVector& Elems ) { if( !fs::exists( Dir ) || !fs::is_directory( Dir ) ) { return; } for( fs::recursive_directory_iterator dir_iter( Dir ), end_iter; dir_iter != end_iter; ++dir_iter ) { if( !fs::is_regular_file( dir_iter->status() ) ) { continue; } const fs::path& p = *dir_iter; Elems.push_back( p ); } }
void StylesheetManager::startStylesheetObserving(const shared_ptr<RequestManager>& manager) { this->manager = manager; parsedStylesheets[".fallback"] = StylesheetManager::makeFallbackStylesheet(manager->getGeodata()); fs::directory_iterator end_iter; boost::unique_lock<boost::shared_mutex> writeLock(stylesheetsLock); for( fs::directory_iterator dir_iter(stylesheetFolder) ; dir_iter != end_iter ; ++dir_iter) { if (fs::is_regular_file(dir_iter->status()) && dir_iter->path().extension() == ".mapcss" ) { StylesheetManager::onNewStylesheet(dir_iter->path().stem()); } } monitorService->add_directory(config->get<string>(opt::server::style_source)); monitorService->async_monitor(boost::bind(&StylesheetManager::onFileSystemEvent, shared_from_this(), _1, _2)); monitorThread = boost::thread(boost::bind(&boost::asio::io_service::run, &ioService)); }
PluginManager::PluginManager(string plugin_dir) { fs::path pluginDir(plugin_dir); if (!fs::exists(pluginDir) || !fs::is_directory(pluginDir)) throw PluginException(plugin_dir + " is not a directory"); fs::directory_iterator end_iter; for(fs::directory_iterator dir_iter(pluginDir); dir_iter != end_iter; ++dir_iter) { if(fs::is_regular_file(dir_iter->status()) ) { string filename = (*dir_iter).path().filename().string(); loadPlugin(filename); } } watcher = new FileWatcher(plugin_dir, boost::bind(&PluginManager::fileChanged, this, _1, _2, _3)); }
void clean_prev_instalations() { #ifdef _WIN32 wchar_t exe_name[1025]; if (::GetModuleFileName(0, exe_name, 1024)) { boost::filesystem::wpath file_path(exe_name); boost::filesystem::wpath current_path = file_path.parent_path(); boost::filesystem::wpath parent_path = file_path.parent_path().parent_path(); std::wstring current_leaf = current_path.leaf().wstring(); if (!tools::is_number(tools::from_utf16(current_leaf))) return; boost::filesystem::directory_iterator end_iter; for (boost::filesystem::directory_iterator dir_iter(parent_path); dir_iter != end_iter ; ++dir_iter) { if (!boost::filesystem::is_directory(dir_iter->status())) continue; if (current_path == dir_iter->path()) continue; std::wstring leaf = dir_iter->path().leaf().wstring(); if (!tools::is_number(tools::from_utf16(leaf))) continue; int32_t current_num = std::stoi(current_leaf); int32_t num = std::stoi(leaf); if (current_num < num) continue; boost::filesystem::remove_all(dir_iter->path()); } } #endif //_WIN32 }
void LLWLParamManager::loadPresetsFromDir(const std::string& dir) { LL_INFOS2("AppInit", "Shaders") << "Loading sky presets from " << dir << LL_ENDL; LLDirIterator dir_iter(dir, "*.xml"); while (1) { std::string file; if (!dir_iter.next(file)) { break; // no more files } std::string path = dir + file; if (!loadPreset(path)) { llwarns << "Error loading sky preset from " << path << llendl; } } }
Catagory::Catagory(std::string catagoreysFolder) : _CatagorysFolder(catagoreysFolder) { namespace fs = boost::filesystem; fs::path pluginDirectory(_CatagorysFolder); fs::directory_iterator end_iter; for( fs::directory_iterator dir_iter(pluginDirectory) ; dir_iter != end_iter ; ++dir_iter) { if (fs::is_directory( *dir_iter )) { fs::path path = dir_iter->path(); std::string subCatFolder = path.string(); std::string subCatFolderName(path.leaf().string()); _SubCatagories.push_back(SubCatagory(subCatFolder, subCatFolderName)); } } }
void LLWaterParamManager::loadPresetsFromDir(const std::string& dir) { LL_INFOS("AppInit", "Shaders") << "Loading water presets from " << dir << LL_ENDL; LLDirIterator dir_iter(dir, "*.xml"); while (1) { std::string file; if (!dir_iter.next(file)) { break; // no more files } std::string path = gDirUtilp->add(dir, file); if (!loadPreset(path)) { LL_WARNS() << "Error loading water preset from " << path << LL_ENDL; } } }
void TreeIterator::Next() { if(m_curr.GetPathType() == PATH_ROOT || m_curr.GetPathType() == PATH_DIR) { std::wstring path; bool res = m_curr.GetPath(path); assert(res); try{ DirectoryIterator dir_iter(path); std::string name; for(dir_iter.First(); !dir_iter.IsDone(); dir_iter.Next()) { name.clear(); const Path &ref_path = dir_iter.Current(); res = ref_path.GetName(name); assert(res); if((name != ".") && (name != "..")) { m_queue.push(ref_path); } } }catch(const ExceptionSpace::FileException &expt) { DEBUG_PRINT1("UnKnow exception == %s\n", expt.what()); if(!m_ignore_error) { throw; } } } if(!m_queue.empty()) { m_curr = m_queue.front(); m_queue.pop(); }else { m_curr.Reset(""); } }
bool Gmm_classifier::get_folders_in_dir(const std::string& path_to_parameters, std::vector<boost::filesystem::path>& paths_to_gmm){ namespace fs = boost::filesystem; fs::path someDir(path_to_parameters); fs::directory_iterator end_iter; if(!fs::exists(someDir) && !fs::is_directory(someDir)){ std::cerr << "Gmm_classifier::get_folders_in_dir no such directory: " << path_to_parameters << std::endl; return false; } if ( fs::exists(someDir) && fs::is_directory(someDir)) { for( fs::directory_iterator dir_iter(someDir) ; dir_iter != end_iter ; ++dir_iter) { paths_to_gmm.push_back(dir_iter->path()); } } return true; }
void TreeIterator::First() { clear(); PathType pt = m_root.GetPathType(); assert(pt != INVALID_PATH); if(pt == PATH_DIR || pt == PATH_ROOT) { std::wstring path; bool res = m_root.GetPath(path); assert(res); DirectoryIterator dir_iter(path); std::string name; for(dir_iter.First(); !dir_iter.IsDone(); dir_iter.Next()) { name.clear(); const Path &ref_path = dir_iter.Current(); bool res = ref_path.GetName(name); assert(res); if(name != "." && name != "..") { m_queue.push(ref_path); } } }else { m_queue.push(m_root); } if(!m_queue.empty()) { m_curr = m_queue.front(); m_queue.pop(); }else { m_curr.Reset(""); } }
void getListOfFilesInFolder(const std::string& path, const std::string& extension, std::vector<std::string>& baseFileNames) { baseFileNames.clear(); const int extensionLength = extension.length(); boost::filesystem::directory_iterator end_iter; for (boost::filesystem::directory_iterator dir_iter(path); dir_iter != end_iter; ++dir_iter) { if (boost::filesystem::is_regular_file(dir_iter->status())) { std::string filename = dir_iter->path().filename().string(); if (boost::algorithm::ends_with(filename, extension)) { std::string basename = filename.substr(0, filename.length() - extensionLength); baseFileNames.push_back(basename); } } } std::sort(baseFileNames.begin(), baseFileNames.end()); }
bool directoryManager::initialize() { // Get list of files in directory! std::string full_dir = string(input_directory) + "/"; #ifdef _USING_BOOST_ fs::path someDir(full_dir); if ( fs::exists(someDir) && fs::is_directory(someDir)) { fs::directory_iterator end_iter; for( fs::directory_iterator dir_iter(someDir) ; dir_iter != end_iter ; ++dir_iter) { if (fs::is_regular_file(dir_iter->status()) ) { std::stringstream temp; temp << dir_iter->path().filename(); string name; name = temp.str(); boost::replace_all(name, "\"", ""); if ((name == ".") || (name == "..") || (name[0] == '.') || (name.size() < 5)) continue; if (name.size() > 5) { if ((name[name.size()-4] != '.') && (name[name.size()-5] != '.')) continue; } else { if (name[name.size()-4] != '.') continue; } file_list.push_back(name); } } } else return false; return true; #else return false; #endif }
bool BTree::recover(){ fs::directory_iterator end_iter; Block* tmp = NULL; char* tmp_name = NULL; char* tmp_end = NULL; for( fs::directory_iterator dir_iter( fs_path ) ; dir_iter != end_iter ; ++dir_iter){ if( fs::is_regular_file(dir_iter->status()) ){ tmp_name = strdup(dir_iter->path().filename().string().c_str()); tmp_end = tmp_name+sizeof(uint64_t); tmp = new Block( path.c_str(), strtoull(tmp_name, &tmp_end, 0)); root->add_block( tmp, tmp->get_id()); if( root->is_full() ){ BNode* right = root->split(); BNode* left = root; root = new BNode(path.c_str(), left, right); } free( tmp_name); } } return true; }
Status storeTestFrameworkOptions(const moe::Environment& params, const std::vector<std::string>& args) { if (params.count("dbpath")) { frameworkGlobalParams.dbpathSpec = params["dbpath"].as<string>(); } if (params.count("seed")) { frameworkGlobalParams.seed = params["seed"].as<unsigned long long>(); } if (params.count("runs")) { frameworkGlobalParams.runsPerTest = params["runs"].as<int>(); } if (params.count("perfHist")) { frameworkGlobalParams.perfHist = params["perfHist"].as<unsigned>(); } bool nodur = false; if( params.count("nodur") ) { nodur = true; storageGlobalParams.dur = false; } if( params.count("dur") || storageGlobalParams.dur ) { storageGlobalParams.dur = true; } if( params.count("nopreallocj") ) { storageGlobalParams.preallocj = false; } if (params.count("debug") || params.count("verbose") ) { logger::globalLogDomain()->setMinimumLoggedSeverity(logger::LogSeverity::Debug(1)); } boost::filesystem::path p(frameworkGlobalParams.dbpathSpec); /* remove the contents of the test directory if it exists. */ try { if (boost::filesystem::exists(p)) { if (!boost::filesystem::is_directory(p)) { StringBuilder sb; sb << "ERROR: path \"" << p.string() << "\" is not a directory"; sb << getTestFrameworkHelp(args[0], moe::startupOptions); return Status(ErrorCodes::BadValue, sb.str()); } boost::filesystem::directory_iterator end_iter; for (boost::filesystem::directory_iterator dir_iter(p); dir_iter != end_iter; ++dir_iter) { boost::filesystem::remove_all(*dir_iter); } } else { boost::filesystem::create_directory(p); } } catch (const boost::filesystem::filesystem_error& e) { StringBuilder sb; sb << "boost::filesystem threw exception: " << e.what(); return Status(ErrorCodes::BadValue, sb.str()); } string dbpathString = p.string(); storageGlobalParams.dbpath = dbpathString.c_str(); storageGlobalParams.prealloc = false; // dbtest defaults to smallfiles storageGlobalParams.smallfiles = true; if( params.count("bigfiles") ) { storageGlobalParams.dur = true; } replSettings.oplogSize = 10 * 1024 * 1024; DEV log() << "_DEBUG build" << endl; if( sizeof(void*)==4 ) log() << "32bit" << endl; log() << "random seed: " << frameworkGlobalParams.seed << endl; if( time(0) % 3 == 0 && !nodur ) { if (!storageGlobalParams.dur) { storageGlobalParams.dur = true; log() << "****************" << endl; log() << "running with journaling enabled to test that. dbtests will do this " << "occasionally even if --dur is not specified." << endl; log() << "****************" << endl; } } if (params.count("suites")) { frameworkGlobalParams.suites = params["suites"].as< vector<string> >(); } frameworkGlobalParams.filter = ""; if ( params.count( "filter" ) ) { frameworkGlobalParams.filter = params["filter"].as<string>(); } if (debug && storageGlobalParams.dur) { log() << "_DEBUG: automatically enabling storageGlobalParams.durOptions=8 " << "(DurParanoid)" << endl; // this was commented out. why too slow or something? storageGlobalParams.durOptions |= 8; } return Status::OK(); }