本文整理汇总了C++中FindFile::fileCount方法的典型用法代码示例。如果您正苦于以下问题:C++ FindFile::fileCount方法的具体用法?C++ FindFile::fileCount怎么用?C++ FindFile::fileCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FindFile
的用法示例。
在下文中一共展示了FindFile::fileCount方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: searchLogFiles
//----------------------------------------------------------------------------
CharString ProcessServer::searchLogFiles( CharString sFilemask, CharString sSearch, bool bRegExp, char nSearchLevel,
bool bResolveClients )
{
CharString sResult;
RegExpM rxSearch;
RegExpM rxClientId, rxLogin;
Tree< unsigned int, String > trClientLookup;
sSearch.lower(); // all search is performed case insensitive
if( bRegExp )
rxSearch.regComp( sSearch );
if( bResolveClients )
rxClientId.regComp( STR("[Cc]lient ([0-9]+)[, ]") );
FindFile ff;
CharString sMask = CharString().format("./Logs/%s.log",sFilemask.cstr());
ff.findFiles( sMask, false, false ); // sorted by date
int nTotalFoundSize = 0;
int nTotalSearchedSize = 0;
int nTotalFilesSearched = 0;
CharString sLine;
dword tStart = Time::seconds();
bool bAbort = false;
// search through all found files
for( int i = 0 ; i < ff.fileCount() && !bAbort ; i++ )
{
CharString sLocalFile( ff.file( i ) );
if( nSearchLevel == 2 ) // only list the files, not search them ?
{
CharString sFile = CharString().format("./Logs/%s", sLocalFile.cstr()) ;
sResult += String().format("*** [%s] *** %s\r\n", Time::format( FileDisk::fileDate( sFile ),"%c").cstr(), sLocalFile.cstr() );
continue;
}
bool fileNamePrintedYet = false;
CharString sText;
CharString sTextOrig;
int nCurPos = 0;
try {
CharString sFile = CharString().format("./Logs/%s",sLocalFile.cstr() );
char * pTemp = FileDisk::loadTextFile( sFile );
sText.copy( pTemp ).lower(); // pText is all lowercase, as it's used for case insensitive search
sTextOrig = CharString().format("%s", pTemp ); // pTextOrig is orig-case, as it's used to build sResult
delete pTemp;
int nTextLen = sText.length();
nTotalSearchedSize += nTextLen;
nTotalFilesSearched++;
int pos = -1;
// loop to find all occurences of the string
while( nCurPos < nTextLen && ( pos = findString( sText, nCurPos, sSearch, &rxSearch, bRegExp ) ) >= 0 )
{
if( !fileNamePrintedYet )
{
if( nSearchLevel == 0 )
sResult += STR("\r\n\r\n");
CharString sFile = CharString().format("./Logs/%s", sLocalFile.cstr()) ;
sResult += String().format("*** [%s] *** %s\r\n", Time::format( FileDisk::fileDate( sFile ),"%c").cstr(), sLocalFile.cstr() );
fileNamePrintedYet = true;
}
if( nSearchLevel == 1 ) // only check if there is a match in the file at all ?
break;
// find the matching line, this time in the original-case text
nCurPos = findMatchingLine( sTextOrig, nCurPos + pos, sLine );
// need to resolve clientIds when found ?
if( bResolveClients )
{
int nClientIdPos = rxClientId.regFind( sLine );
if( nClientIdPos >= 0 ) // line holds a clientId ?
{
int nClientIdLen = rxClientId.getFindLen() - 8; // match length - static chars
// extract the clientId
CharString sClientId = sLine;
sClientId.right( sClientId.length() - ( nClientIdPos + 7 ) );
sClientId.left( nClientIdLen );
int nClientId = CharString::strint(sClientId);
CharString sResolvedClient(STR(""));
if( trClientLookup.find( nClientId ).valid() ) // know this clientId already ?
{
sResolvedClient = trClientLookup[ nClientId ];
}
else
{
//.........这里部分代码省略.........