bool hsStream::ReadLn(char *s, uint32_t maxLen, const char beginComment, const char endComment) { char c; char endCom; endCom = endComment; while( true ) { while( !AtEnd() && strchr("\r\n",c = ReadByte()) ) c = c; ; if( AtEnd() ) return false; if( beginComment != c ) break; // skip to end of comment while( !AtEnd() && (endCom != (c = ReadByte())) ) c= c; ; } s[0] = c; uint32_t k = 1; while( !AtEnd() && !strchr("\r\n",c = ReadByte()) ) { if( k < maxLen ) s[k++] = c; } s[k] = 0; if( (k > 0)&&!stricmp(s, "skip") ) { int depth = 1; while( depth && ReadLn(s, maxLen, beginComment, endCom) ) { if( !stricmp(s, "skip") ) depth++; else if( !stricmp(s, "piks") ) depth--; } return ReadLn(s, maxLen, beginComment, endCom); } return true; }
// --------------------------------------------------------- // CPosTp148::StartL // // (other items were commented in a header). // --------------------------------------------------------- // void CPosTp148::StartL() { BaflUtils::EnsurePathExistsL( iFileSession, KKMZFile ); // Delete the trace file DeleteFileL(KFileTrace); HBufC8* emptyBuffer=NULL; iLog->Log(_L("Test with Tp148KMZFile.kmz")); PrintParsedDataFromEncoderL(KKMZFile, *emptyBuffer, KErrNone, KKmzMimeType ); // Now compare tha trace file against the correct one RFile correctFile; RFile file; iLog->Log(_L(">>>>>>>Comparing files<<<<<")); TFileName filename; CreateCorrectXmlFileL( KCorrectFile, filename ); User::LeaveIfError(correctFile.Open(iFileSession, filename, EFileRead)); CleanupClosePushL(correctFile); User::LeaveIfError(file.Open(iFileSession, KFileTrace, EFileRead)); CleanupClosePushL(file); HBufC* correctLinebuffer = HBufC::NewLC( KBufSize ); TPtr correctLine = correctLinebuffer->Des(); HBufC* linebuffer = HBufC::NewLC( KBufSize ); TPtr line = linebuffer->Des(); TInt err = KErrNone; TBool done = EFalse; TInt lineNr = 0; while (ReadLn(correctFile, correctLine) != KErrEof && !done) { lineNr++; err = ReadLn(file, line); if ( err == KErrEof ) { done = ETrue; } correctLine.Trim(); line.Trim(); if ( correctLine.Compare( line ) != KErrNone ) { HBufC* buf = HBufC::NewLC( 128 ); TPtr buffer = buf->Des(); buffer.Format(_L("ERROR in TraceFile on line %d: "), lineNr); iLog->Log( buffer ); iLog->Log( correctLine ); iLog->Log( line ); iErrorsFound++; CleanupStack::PopAndDestroy( buf ); } } CleanupStack::PopAndDestroy( linebuffer ); CleanupStack::PopAndDestroy( correctLinebuffer ); CleanupStack::PopAndDestroy(&file); CleanupStack::PopAndDestroy(&correctFile); // EOF for trace file was reach before EOF in the correct file if (done) { iLog->Log(_L("ERROR: EOF for Trace file was reached to early")); iErrorsFound++; } DoCancelTestL(); if (iErrorsFound != KErrNone) { iLog->Log(_L("Errors found in TP148")); User::Leave(-1); } }