
Originally Posted by
Md. Kayesh
Yes. I did it but when i am printing using RDebug::Print() as i stated ago, it is missing alternate characters instead of printing "abcdefgh" it is printing "aceg IIIIII". How to avoid this problem?
Note that if you are passing 16-bit descriptors to stream.ReadL, that repeats the issue with TFileText
Another thing is how can i know that i've reached the last line or how to avoid Kerreof while reading last line?
This is why I called it difficult. I do not know about any ready-made solution. TFileText is practically unusable, and the RReadStream::ReadL(buf,delim) variant loses the content following the last delimiter.
You can try opening the RFile yourself, pass it to RFileReadStream::Attach, and record the current file offset after each succesful ReadL (hopefully it is updated, you can get the position via RFile::Seek+ESeekCurrent, just always zero the position beforehand, because it is a two-way argument). After that you should TRAP the entire loop, and at the end (when KErrEof comes), seek back to the last position (ESeekStart and pass the stored position argument), and Read once.
Code:
RFile file;
User::LeaveIfError(file.Open(...));
CleanupClosePushL(file);
TBuf8<100> line;
TInt seek;
TRAPD(err,
RFileReadStream stream;
stream.Attach(file);
stream.PushL();
while(ETrue)
{
seek=0;
User::LeaveIfError(file.Seek(TSeek::ESeekCurrent,seek));
stream.ReadL(line,'\n');
[do something with line]
});
if(err==KErrEof)
{
User::LeaveIfError(file.Seek(TSeek::ESeekStart,seek));
User::LeaveIfError(file.Read(line));
[do something with line]
}
CleanupStack::PopAndDestroy(); // file