03.01.2013 Views

Chapter 1

Chapter 1

Chapter 1

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

file.Close();<br />

// Finished with user interaction: communicate parameters<br />

and return<br />

delete iAppUi->iFileName;<br />

iAppUi->iFileName = fileName;<br />

delete iAppUi->iText;<br />

iAppUi->iText = text;<br />

CleanupStack::Pop(2); // text, fileName<br />

return ETrue;<br />

}<br />

I start by closing the file because that's no longer needed here. I then set the HBufC pointers<br />

in the app UI to refer to the new strings and make sure that whatever was there before is<br />

deleted. Finally, I pop both the new string pointers from the cleanup stack because they are<br />

stored safely as member variables now.<br />

The scene of processing now returns to my WriteFileL() function:<br />

void CExampleAppUi::WriteFileL()<br />

{<br />

// Create a write stream on the file<br />

RFileWriteStream writer;<br />

writer.PushL(); // Writer on cleanup stack<br />

User::LeaveIfError(writer.Replace(iCoeEnv->FsSession(),<br />

// Write the text<br />

writer

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!