Now i want this structure to be written to a file and read back. Can anyone help me in solving this problem? lease provide some code so it will be clear.
maybe you could have a look into streams, such as RFileReadStream & RFileWriteStream. I'm quite sure there are also example applications utilizing them.
My requirement is to read a file one line at a time. I have the following code however when I read the last line (which contains EOF) the program halts with epoc error. I cannot TRAP. Any ideas?
Thanks,
RE
TInt fSize;
TInt iReadBytes = 0;
RFile file;
RFs fsSession;
_LIT( KContactFile,"\\system\\Apps\\PSCLIENT\\contacts.txt");
User::LeaveIfError(fsSession.Connect());
TInt err = file.Open(fsSession,KContactFile, EFileRead);
if (err != KErrNotFound)
{
// read the Contact file
file.Size(fSize);
RFile f = file;
RFileReadStream stream(f);
TBuf8<128> *buf = new(ELeave)TBuf8<128>;
do {
TRAPD(err, stream.ReadL(*buf,(TChar)'\n'));
if (err == KErrEof)
{
int i = 1;
}
iReadBytes += buf->Length();
buf->Delete(0, 128);
} while (iReadBytes < fSize);
stream.Close();
fsSession.Close();
}
TLicenseLocal in this instance is really not a T class/struct but rather a C class/struct. This is because is contains (owns) a C class which requires proper destruction.
I suggest you implement a new class called CLicenseLocal deriving from CBase. Add to this InternalizeL() and ExternalizeL() functions as well as a destructor that properly deletes all members.
In the InternalizeL and ExternalizeL you'll need to iteratively write each plugin data to the file. You'd probably also want to write the count so that you are able to easily InternalizeL.