void saveRootIt(int iteration) { std::ofstream itFile (iterationFileName.c_str()); if (itFile.is_open()) { itFile << iteration; itFile.close(); } }
void TestMain::CheckInstallation(std::unordered_map<std::wstring, std::wstring>& expectedContent) { boost::filesystem::directory_iterator itEnd; for (boost::filesystem::directory_iterator itFile(datadirPath_ / L"install-test1"); itFile != itEnd; ++itFile) { lhWinAPI::TextFile tf(itFile->path().wstring(), GENERIC_READ, 0, OPEN_EXISTING); std::wstring txt; tf.ReadText(txt, lhWinAPI::TextFile::UTF8); std::wstringstream txtStream(txt); std::wstring fstLine; std::getline(txtStream, fstLine); bool foundFile = false; for (auto itMap = expectedContent.begin(); itMap != expectedContent.end(); ++itMap) { if (boost::iequals(itFile->path().filename().wstring(), itMap->first)) { foundFile = true; if (boost::iequals(fstLine, itMap->second)) { expectedContent.erase(itMap); break; } else { throw lhstd::exception(L"wrong version of " + itMap->first + L"\n" + L"Content was: " + fstLine + L"\nExpected: " + itMap->second); } } } if (!foundFile) { throw lhstd::exception(L"unknown file " + itFile->path().filename().wstring()); } } if (!expectedContent.empty()) { throw lhstd::exception(L"map not empty - " + expectedContent.begin()->first); } }
void loadRootIt() { std::ifstream itFile (iterationFileName.c_str()); std::string line; if (itFile.is_open()) { getline(itFile,line); rootIt = atoi(line.c_str()); itFile.close(); } }
void SofaConfiguration::processDirectory(const QString &dir) { QDir d(QString(path.c_str())+dir); d.setFilter( QDir::Dirs | QDir::Hidden | QDir::NoSymLinks ); std::vector< QString > subDir; const QFileInfoList &listDirectories = #ifdef SOFA_QT4 d.entryInfoList(); QStringList filters; filters << "*.h" << "*.hpp" << "*.cpp" << "*.inl"<< "*.c" << "*.cu" << "*.cuh" << "*.pro" ; d.setNameFilters(filters); for (int j = 0; j < listDirectories.size(); ++j) { QFileInfo fileInfo=listDirectories.at(j); #else *(d.entryInfoList()); QString filters="*.h *.hpp *.cpp *.inl *.c *.cu *.cuh *.pro"; d.setNameFilter(filters); QFileInfoListIterator itDir( listDirectories ); while ( (itDir.current()) != 0 ) { QFileInfo fileInfo=*(itDir.current()); #endif subDir.push_back(fileInfo.fileName()); #ifndef SOFA_QT4 ++itDir; #endif } d.setFilter( QDir::Files | QDir::Hidden | QDir::NoSymLinks ); std::vector< QString > filesInside; const QFileInfoList &listFiles = #ifdef SOFA_QT4 d.entryInfoList(); for (int j = 0; j < listFiles.size(); ++j) { QFileInfo fileInfo=listFiles.at(j); #else *(d.entryInfoList()); QFileInfoListIterator itFile( listFiles ); while ( (itFile.current()) != 0 ) { QFileInfo fileInfo=*(itFile.current()); #endif filesInside.push_back(fileInfo.fileName()); processFile(fileInfo); #ifndef SOFA_QT4 ++itFile; #endif } for (unsigned int i=0; i<subDir.size(); ++i) { if (subDir[i].left(1) == QString(".")) continue; if (subDir[i] == QString("OBJ")) continue; QString nextDir=dir+QString("/")+subDir[i]; processDirectory(nextDir); } } void SofaConfiguration::processFile(const QFileInfo &info) { std::fstream file; file.open(info.absFilePath(), std::ios::in | std::ios::out); std::string line; while (std::getline(file, line)) { std::set< QWidget *>::iterator it; for (it=optionsModified.begin(); it!=optionsModified.end(); it++) { std::string option((*it)->name()); if (line.find(option.c_str()) != std::string::npos) { //Touch the file file.seekg(0); char space; file.get(space); file.seekg(0); file.put(space); std::cout << " found in " << info.absFilePath().ascii() << std::endl; return; } } } file.close(); } }