void PkgScanner::scan() { QString dirStr("/home/james/catkin_ws/src/test_node"); QDirIterator it(dirStr, QStringList() << "*.cpp", QDir::Files, QDirIterator::Subdirectories); while(it.hasNext() ) { qDebug() << it.next(); } }
void GlogBufferStatsLogger::logPortBufferStat( const std::string& portName, Direction dir, unsigned int cosQ, uint64_t bytesUsed, uint64_t pktsDropeed, const XPEs& xpes) { LOG(INFO) << " Port : " << portName << " " << dirStr(dir) << " cosQ: " << cosQ << " bytes used : " << bytesUsed << " Packets dropped: " << pktsDropeed << " XPEs: " << xpeStr(xpes); }
void Cws_machineEx::updatePathInAddress(const char* address, StringBuffer& addrStr) { addrStr.append(address); StringArray sArray; sArray.appendList(address, ":"); const char* OS = sArray.item(3); const char* Dir = sArray.item(4); if (OS && *OS && Dir && *Dir) { char oldC1 = '/'; char oldC2 = '$'; char newC1 = '\\'; char newC2 = ':'; int os = atoi(OS); if (os == 2) //2: linux { oldC1 = '\\'; oldC2 = ':'; newC1 = '/'; newC2 = '$'; } StringBuffer dirStr(Dir); dirStr.replace(oldC1, newC1); dirStr.replace(oldC2, newC2); if ((os == 2) && (dirStr.charAt(0) != '/')) dirStr.insert(0, '/'); addrStr.clear(); for (unsigned i = 0; i < sArray.length(); i++) { const char* item = sArray.item(i); if (i == 4) addrStr.appendf(":%s", dirStr.str()); else if (item && *item) { if (i == 0) addrStr.append(item); else addrStr.appendf(":%s", item); } } } return; }
bool FileUtils::mkdirs( const String &path ) { bool res = false; ASSERT_D( path.length() > 0 ); #if defined(_WINDOWS) || defined(WIN32) TCHAR abspath[_MAX_PATH]; TCHAR drive[_MAX_DRIVE]; TCHAR dir[_MAX_DIR]; TCHAR fname[_MAX_FNAME]; TCHAR ext[_MAX_EXT]; _tsplitpath_s( _tfullpath( abspath, path.c_str(), _MAX_PATH ), drive, dir, fname, ext ); // remember the current drive int curDrive = _getdrive(); // set the current drive _chdrive( toupper(drive[0]) - 'A' + 1 ); // now start parsing out the path and create all directoried in the // heirarchy String createPath; String dirStr(dir); dirStr += fname; StringUtils::trimBoth( FileUtils::PATH_SEP_PAT, dirStr ); StringTokenizer tok(dirStr, FileUtils::PATH_SEP_PAT); while( tok.hasMoreTokens() ) { createPath += FileUtils::PATH_SEP; createPath += tok.getNextToken(); res = FileUtils::mkdir( createPath ); if ( !res ) { break; } } _chdrive( curDrive ); #else // the first step is to figure out where the path // starts. If the path contains a .. or . prefix, then // we have to calculate the start of the creation path // if it does not contain such prefix, then we'll just create // the directories relative to the current working directory String rootPath; String parsePath; String::size_type startPos = path.find_first_not_of( NTEXT("/.") ); if ( startPos != 0 ) { // there was at least one of these delimiters as a prefix String prefixStr( path, 0, startPos ); rootPath = FileUtils::resolve( prefixStr ); if ( rootPath.length() > 0 ) { if ( rootPath[ rootPath.length() - 1 ] != NTEXT('/') ) { rootPath += FileUtils::PATH_SEP; } } parsePath = path.substr( startPos ); } else { // no delimiters, so just parse the path parsePath = path; } StringTokenizer tok( parsePath, FileUtils::PATH_SEP_PAT ); while( tok.hasMoreTokens() ) { rootPath += tok.getNextToken(); rootPath += FileUtils::PATH_SEP; res = FileUtils::mkdir( rootPath ); if ( !res ) { break; } } #endif return res; }