void CTestUTCParse::ReadDataL(CImRecvConvert* aRecvConvert, TFileName aFileName)
	{
	// open the file
	RFile file;

	TInt error = file.Open(iTestUtils->FileSession(), aFileName, EFileShareAny);
	if(error != KErrNone)
		{
		ERR_PRINTF2(TRefByValue<const TDesC>_L("\r\nFile open error %d"), error);
		User::Leave(KErrNotFound);
		}

	INFO_PRINTF2(TRefByValue<const TDesC>_L("Data from %s...\r\n"), aFileName.PtrZ());		

	// read the file into the conversion object
	HBufC8* lineBuffer = HBufC8::NewLC(1024);
	TPtr8 line = lineBuffer->Des();

	TBuf8<1> theChar;
	TBool finished = EFalse;

	aRecvConvert->ResetL();
	// supply a new attachment path since previous one is discarded by call to Reset()

	do {
		line.FillZ();
		line.SetLength(0);
		// compile a line one char at a time
		do {
			file.Read(theChar, 1);
			if(theChar.Length())
				line.Append(theChar);
			else
				finished = ETrue;
			// stop at the end of line or no more data
			} while(theChar.Length() && theChar[0] != 0x0A);
			if(!line.Length())
				break;
			
			aRecvConvert->ParseNextField(line); // This function doesnt actually leave, any leaves are relayed to the MessageCompleteL() function

		} while(!finished);

	TRAPD(err, aRecvConvert->MessageCompleteL());
	if(err!=KErrNone)
		{
		// At this point the message should be deleted and CImRecvConvert should be Reset()
		ERR_PRINTF3(TRefByValue<const TDesC>_L("\r\nError %d occured during the conversion of Message %d"), err, aRecvConvert->EntryId());
		}
	CleanupStack::PopAndDestroy(lineBuffer); 

	file.Close();
	}
Example #2
0
const wchar *C_dir::ScanGet(dword *atts, dword *size, S_date_time *dt){

   if(!find_data)
      return NULL;

   S_scan_data *sd = (S_scan_data*)find_data;
   if(sd->index >= sd->count)
      return NULL;

   const TEntry &e = (*sd->list)[sd->index++];
   if(atts){
      *atts = 0;
      if(e.IsArchive()) *atts |= C_file::ATT_ARCHIVE;
      if(e.IsHidden()) *atts |= C_file::ATT_HIDDEN;
      if(e.IsReadOnly()) *atts |= C_file::ATT_READ_ONLY;
      if(e.IsSystem()) *atts |= C_file::ATT_SYSTEM;
      if(e.IsDir()) *atts |= C_file::ATT_DIRECTORY;
   }
   if(size)
      *size = e.iSize;
   if(dt){
      const TDateTime st = e.iModified.DateTime();
      dt->year = word(st.Year());
      dt->month = word(st.Month());
      dt->day = word(st.Day());
      dt->hour = word(st.Hour());
      dt->minute = word(st.Minute());
      dt->second = word(st.Second());

      dt->sort_value = dt->GetSeconds() + dt->GetTimeZoneMinuteShift()*60;
      dt->SetFromSeconds(dt->sort_value);
      dt->sort_value = dt->GetSeconds();
   }
   TFileName fn = e.iName;
   sd->tmp = (const wchar*)fn.PtrZ();
   return sd->tmp;
}