Open a RFileWriteStream for appending

Login to reply to this topic.
Sat, 2007-01-27 16:52
Joined: 2005-11-16
Forum posts: 63
Hi,

I want to open an existing file as a stream for appending. How can I solve this?

RFileWriteStream.Open/Create/Replace seems to be only for overwriting. (Am I wrong?)

SDK says: "The stream will be written to offset zero in the file." How can I change this?

regards
Martin



Sat, 2007-01-27 17:32
Joined: 2005-11-20
Forum posts: 1246
Re: Open a RFileWriteStream for appending
After opening, with 'iWriteStream' being your stream and 'aPos' the position that you want to write to, try something like:
Code:
    iWriteStream.Sink()->SeekL(MStreamBuf::EWrite,TStreamPos(aPos));

René Brunner

Sun, 2007-01-28 16:00
Joined: 2005-11-16
Forum posts: 63
Re: Open a RFileWriteStream for appending
Thanks this works:

Code:
// 1) open the file
RFile fh;
fh.Open(iFs, *iLogFileName, EFileShareAny|EFileStream|EFileRead);
CleanupClosePushL(fh);

// 2) seek the EOF
TInt offset = 0;
fh.Seek(ESeekEnd, offset);

// 3) cleanup
CleanupStack::PopAndDestroy(&fh);

// move the position of the write mark in the stream by the specified offset
iFileWriteStream.Sink()->SeekL(MStreamBuf::EWrite, TStreamPos(offset));

regards
Martin
  • Login to reply to this topic.