void CIoFile::IorepReadL(MIoReader& aReader) { TInt fileSize; User::LeaveIfError(iFile.Size(fileSize)); if (iPos < fileSize) { TDes& readBuf = aReader.IorReadBuf(); iTempReadBuf.Zero(); HBufC8* narrowBuf = HBufC8::NewLC(readBuf.MaxLength()); TPtr8 narrowBufPtr(narrowBuf->Des()); User::LeaveIfError(iFile.Read(narrowBufPtr, readBuf.MaxLength())); iPos += narrowBuf->Length(); iTempReadBuf.AppendUtf8L(narrowBufPtr); if (iPos >= fileSize) { iTempReadBuf.FinalizeUtf8(); } readBuf.Copy(iTempReadBuf); aReader.IorDataBuffered(readBuf.Length()); CleanupStack::PopAndDestroy(narrowBuf); if (iPos >= fileSize) { aReader.IorReadComplete(KErrNone); } } else { aReader.IorReadComplete(KErrEof); } }
/** @capability ReadUserData */ HBufC* RContactRemoteView::AllFieldsLC(TInt aIndex,const TDesC& aSeparator) const { // 4 context switches TPckgBuf<TInt>pckg; TIpcArgs args(aIndex,&aSeparator,&pckg); User::LeaveIfError(SendReceive(ECntAllFieldsLength,args)); TInt fieldLength = pckg(); HBufC* buf=HBufC::NewLC(fieldLength); TPtr8 narrowBufPtr((TUint8*)buf->Ptr(),buf->Des().MaxLength()*2); // Note, must call MaxLength because the cell allocated may be larger than aLength. TIpcArgs args2(&narrowBufPtr); User::LeaveIfError(SendReceive(ECntAllFieldsText,args2)); TPtr bufPtr(buf->Des()); bufPtr.SetLength(narrowBufPtr.Length()/2); return buf; }