<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xml:base="http://www.newlc.com" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
 <title>NewLC - RFile or file stream - Comments</title>
 <link>http://www.newlc.com/topic-567</link>
 <description>Comments for &quot;RFile or file stream&quot;</description>
 <language>en</language>
<item>
 <title>Re: RFile or file stream</title>
 <link>http://www.newlc.com/topic-567#comment-44633</link>
 <description>&lt;p&gt;Use TFileText:&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://www.symbian.com/Developer/techlib/v70sdocs/doc_source/reference/cpp/FileServerClientSide/TFileTextClass.html&quot;&gt;http://www.symbian.com/Developer/techlib/v70sdocs/doc_source/reference/cpp/FileServerClientSide/TFileTextClass.html&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Or, just stream your descriptors to the stream:&lt;/p&gt;

&lt;p&gt;&lt;div class=&quot;codeblock&quot;&gt;&lt;code&gt;TBuf&amp;lt;10&amp;gt; buf;&lt;br /&gt;// Put something to buf, have stream ready -- write to it&lt;br /&gt;aStream &amp;lt;&amp;lt; buf;&lt;br /&gt;// The same with HBufC:&lt;br /&gt;aStream &amp;lt;&amp;lt; *myHBufC;&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;

&lt;p&gt;Or, if using RFile, copy the 16 bit descriptor data to a 8 bit descriptor and write it to the file:&lt;br /&gt;
&lt;div class=&quot;codeblock&quot;&gt;&lt;code&gt;TBuf8&amp;lt;20&amp;gt; my8BitBuf;&lt;br /&gt;my8BitBuf.Copy(a16BitBuf);&lt;br /&gt;myFile.Write(my8BitBuf);&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;</description>
 <pubDate>Tue, 19 Feb 2008 08:23:13 +0100</pubDate>
 <dc:creator>Andreas</dc:creator>
 <guid isPermaLink="false">comment 44633 at http://www.newlc.com</guid>
</item>
<item>
 <title>Re: RFile or file stream</title>
 <link>http://www.newlc.com/topic-567#comment-44625</link>
 <description>&lt;p&gt;hi,&lt;br /&gt;
I am trying to read and write Unicode data (16-bits) into file..... how i do it?&lt;/p&gt;

&lt;p&gt;thanx in advance &lt;/p&gt;</description>
 <pubDate>Tue, 19 Feb 2008 05:15:14 +0100</pubDate>
 <dc:creator>kalpesh.deo</dc:creator>
 <guid isPermaLink="false">comment 44625 at http://www.newlc.com</guid>
</item>
<item>
 <title>Re: RFile or file stream</title>
 <link>http://www.newlc.com/topic-567#comment-4570</link>
 <description>&lt;div class=&quot;smf-content&quot;&gt;And here you go for stores.&amp;nbsp; This is a pretty simple example, that demonstrates the fact that unlike streams, you can load any object from the store when you want it.&amp;nbsp; It doesn&amp;#039;t demonstrate defered loading (TSwizzle&amp;#039;s + CStoreMap)&lt;br /&gt;&lt;br /&gt;&lt;div class=&quot;codeheader&quot;&gt;Code:&lt;/div&gt;&lt;div class=&quot;code&quot;&gt;//&lt;br /&gt;// A class for correct cleanup of RPointerArrays&lt;br /&gt;template &amp;lt;class T&amp;gt;&lt;br /&gt;class CleanupResetAndDestroyClose&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;{&lt;br /&gt;public:&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;inline static void PushL(T&amp;amp; aRef)&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;{CleanupStack::PushL(TCleanupItem(&amp;amp;Close,&amp;amp;aRef));}&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;static void Close(TAny *aPtr)&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;{&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;(STATIC_CAST(T*,aPtr))-&amp;gt;ResetAndDestroy();&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;(STATIC_CAST(T*,aPtr))-&amp;gt;Close();&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;}&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;};&lt;br /&gt;&lt;br /&gt;template &amp;lt;class T&amp;gt;&lt;br /&gt;inline void CleanupResetAndDestroyClosePushL(T&amp;amp; aRef)&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;{CleanupResetAndDestroyClose&amp;lt;T&amp;gt;::PushL(aRef);}&lt;br /&gt;&lt;br /&gt;//&lt;br /&gt;// A class we wish to put into the store&lt;br /&gt;class CFoo : public CBase&lt;br /&gt;{&lt;br /&gt;public:&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;CFoo() {}&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;TBuf&amp;lt;20&amp;gt; iName;&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;TInt iSomeData;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;TStreamId StoreL(CStreamStore&amp;amp; aStore) const;&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;void ExternalizeL(RWriteStream&amp;amp; aStream) const;&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;void RestoreL(CStreamStore&amp;amp; aStore,TStreamId anId);&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;void InternalizeL(RReadStream&amp;amp; aStream);&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;//&lt;br /&gt;// Create a stream, and externilize ourselfs into it&lt;br /&gt;TStreamId CFoo::StoreL(CStreamStore&amp;amp; aStore) const&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;{&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;RStoreWriteStream outstream;&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;TStreamId id = outstream.CreateLC(aStore);&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;ExternalizeL(outstream);&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;outstream.CommitL();&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;CleanupStack::PopAndDestroy(&amp;amp;outstream);&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;return id;&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;}&lt;br /&gt;&lt;br /&gt;void CFoo::ExternalizeL(RWriteStream&amp;amp; aStream) const&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;{&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;aStream &amp;lt;&amp;lt; iName;&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;aStream.WriteInt16L(iSomeData);&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;}&lt;br /&gt;&lt;br /&gt;//&lt;br /&gt;// Open up the given stream, and restore from it&lt;br /&gt;void CFoo::RestoreL(CStreamStore&amp;amp; aStore,TStreamId anId)&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;{&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;RStoreReadStream stream;&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;stream.OpenLC(aStore,anId);&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;InternalizeL(stream);&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;CleanupStack::PopAndDestroy(&amp;amp;stream);&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;}&lt;br /&gt;&lt;br /&gt;void CFoo::InternalizeL(RReadStream&amp;amp; aStream)&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;{&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;aStream &amp;gt;&amp;gt; iName;&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;iSomeData = aStream.ReadInt16L();&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;}&lt;br /&gt;&lt;br /&gt;//&lt;br /&gt;// Add each record to the store&lt;br /&gt;void DoSaveToStoreL(CFileStore* aStore)&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;{&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;RPointerArray&amp;lt;CFoo&amp;gt; rObs;&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;CleanupResetAndDestroyClosePushL(rObs);&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;CFoo* pFoo1 = new CFoo;&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;CleanupStack::PushL(pFoo1);&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;pFoo1-&amp;gt;iName.Copy(_L(&amp;quot;Test Ob1&amp;quot;));&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;pFoo1-&amp;gt;iSomeData = 1;&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;User::LeaveIfError(rObs.Append(pFoo1));&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;CleanupStack::Pop(pFoo1);&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;CFoo* pFoo2 = new CFoo;&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;CleanupStack::PushL(pFoo2);&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;pFoo2-&amp;gt;iName.Copy(_L(&amp;quot;Test Ob2&amp;quot;));&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;pFoo2-&amp;gt;iSomeData = 2;&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;User::LeaveIfError(rObs.Append(pFoo2));&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;CleanupStack::Pop(pFoo2);&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;RArray &amp;lt; TStreamId &amp;gt; rIndexArray;&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;CleanupClosePushL(rIndexArray);&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;//&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;// Store each object from rObs into the store.&amp;nbsp; Each object will create it&amp;#039;s own stream&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;// in the store, and it&amp;#039;s id will be returned from -&amp;gt;StoreL.&amp;nbsp; We then store the ids in a&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;// index which we store in the root stream of the store.&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;for(TInt n = 0; n &amp;lt; rObs.Count(); ++n)&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;{&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;TStreamId id = rObs[n]-&amp;gt;StoreL(*aStore);&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;User::LeaveIfError(rIndexArray.Append(id));&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;//&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;// Write index&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;RStoreWriteStream rs;&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;rs.ReplaceLC(*aStore, aStore-&amp;gt;Root());&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;rs.WriteInt16L(rIndexArray.Count());&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;for(TInt nn = 0; nn &amp;lt; rIndexArray.Count(); ++nn)&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;{&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;//&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;// Write name&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;rs &amp;lt;&amp;lt; rObs[nn]-&amp;gt;iName;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;//&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;// And index&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;rs &amp;lt;&amp;lt; rIndexArray[nn];&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;rs.CommitL();&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;CleanupStack::PopAndDestroy(&amp;amp;rs);&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;//&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;// Commit the store&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;aStore-&amp;gt;CommitL();&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;//&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;// Done with the index array&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;CleanupStack::PopAndDestroy(&amp;amp;rIndexArray);&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;//&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;// And the objects&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;CleanupStack::PopAndDestroy(&amp;amp;rObs);&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;}&lt;br /&gt;&lt;br /&gt;LOCAL_C void doExampleL()&lt;br /&gt;{&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;//&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;// Open a RFs&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;RFs aFs;&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;User::LeaveIfError(aFs.Connect());&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;CleanupClosePushL(aFs);&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;_LIT(KStoreName, &amp;quot;C:\\TestStore.dat&amp;quot;);&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;//&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;// Create a perminate file store&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;CPermanentFileStore* pStore = CPermanentFileStore::ReplaceLC(aFs, KStoreName, EFileWrite);&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;pStore-&amp;gt;SetTypeL(KPermanentFileStoreLayoutUid);&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;//&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;// Write a fake root stream containg 0 for the entry count&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;RStoreWriteStream rs;&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;TStreamId id = rs.CreateLC(*pStore);&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;rs.WriteInt16L(0);&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;rs.CommitL();&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;pStore-&amp;gt;SetRootL(id);&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;pStore-&amp;gt;CommitL();&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;CleanupStack::PopAndDestroy(&amp;amp;rs);&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;//&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;// Generate some objects and save them to the store&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;TRAPD(err, DoSaveToStoreL(pStore));&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;if(err != KErrNone)&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;{&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;pStore-&amp;gt;Revert();&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;User::Leave(err);&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;//&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;// The store now contains a series of streams, and each stream contains it&amp;#039;s own CFoo, which&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;// we can load independatly of each other&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;//&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;// Close the store&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;CleanupStack::PopAndDestroy(pStore);&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;//&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;// Open up the store for reading&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;CPermanentFileStore* pReadStore = CPermanentFileStore::OpenLC(aFs,&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;KStoreName, EFileRead);&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;//&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;// Go through the ids, and look for the one called Test Ob2 to demonstrate&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;// we don&amp;#039;t need to load Test Ob1 to get at Test Ob2 as we would if we were&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;// using a normal stream&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;TInt nRecordCount = 0;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;RStoreReadStream streamIn;&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;streamIn.OpenLC(*pReadStore, pReadStore-&amp;gt;Root());&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;nRecordCount = streamIn.ReadInt16L();&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;TStreamId nTheId;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;for(TInt n = 0; n &amp;lt; nRecordCount; ++n)&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;{&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;//&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;// Read name&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;TBuf&amp;lt;20&amp;gt; iName;&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;streamIn &amp;gt;&amp;gt; iName;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;TStreamId id;&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;streamIn &amp;gt;&amp;gt; id;&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;if(iName.Compare(_L(&amp;quot;Test Ob2&amp;quot;)) == 0)&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;{&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;//&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;// Found it!&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;nTheId = id;&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;break;&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;}&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;CleanupStack::PopAndDestroy(&amp;amp;streamIn);&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;if(nTheId != KNullStreamId)&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;{&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;//&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;// Load er back in&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;CFoo* pOb2 = new CFoo;&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;CleanupStack::PushL(pOb2);&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;//&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;// Restore it&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;pOb2-&amp;gt;RestoreL(*pReadStore, nTheId);&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;//&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;// Do something with it&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;// .&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;// ,&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;//&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;// Destory it&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;CleanupStack::PopAndDestroy(pOb2);&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;//&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;// Close the store&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;CleanupStack::PopAndDestroy(pReadStore);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;//&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;// Close the RFs&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;CleanupStack::PopAndDestroy(&amp;amp;aFs);&lt;br /&gt;}&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;</description>
 <pubDate>Fri, 24 Jun 2005 14:47:48 +0200</pubDate>
 <dc:creator>didster</dc:creator>
 <guid isPermaLink="false">comment 4570 at http://www.newlc.com</guid>
</item>
<item>
 <title>Re: RFile or file stream</title>
 <link>http://www.newlc.com/topic-567#comment-4569</link>
 <description>&lt;div class=&quot;smf-content&quot;&gt;Here you go for streams:&lt;br /&gt;&lt;br /&gt;&lt;div class=&quot;codeheader&quot;&gt;Code:&lt;/div&gt;&lt;div class=&quot;code&quot;&gt;//&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;// Open a RFs&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;RFs aFs;&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;User::LeaveIfError(aFs.Connect());&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;CleanupClosePushL(aFs);&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;_LIT(KStreamName, &amp;quot;C:\\TestStream.dat&amp;quot;);&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;//&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;// Delete old file&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;aFs.Delete(KStreamName);&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;//&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;// Open a file write stream&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;RFileWriteStream fWrite;&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;User::LeaveIfError(fWrite.Create(aFs, KStreamName, EFileWrite));&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;CleanupClosePushL(fWrite);&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;//&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;// Write to the stream and commit it&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;_LIT(KTextToCopy, &amp;quot;This is a test stream&amp;quot;);&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;fWrite &amp;lt;&amp;lt; KTextToCopy();&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;// Warning, this _CAN_ leave&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;fWrite.CommitL();&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;//&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;// Close the stream&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;CleanupStack::PopAndDestroy(&amp;amp;fWrite);&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;//&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;// Open a read stream&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;RFileReadStream fRead;&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;User::LeaveIfError(fRead.Open(aFs, KStreamName, EFileRead));&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;CleanupClosePushL(fRead);&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;//&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;// Read data back from the stream.&amp;nbsp; Using the HBufC::NewL which takes a RReadStream&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;// so we get a buffer exactly the right size for whats in the stream&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;HBufC* pBuf = HBufC::NewL(fRead, 1000);&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;//&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;// Close the read stream&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;CleanupStack::PopAndDestroy(&amp;amp;fRead);&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;//&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;// Close the RFs&lt;br /&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;CleanupStack::PopAndDestroy(&amp;amp;aFs);&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;I will do one for stores this avo if I get a spare minute, since it&amp;#039;s a bit more involved.&lt;/div&gt;</description>
 <pubDate>Fri, 24 Jun 2005 13:00:20 +0200</pubDate>
 <dc:creator>didster</dc:creator>
 <guid isPermaLink="false">comment 4569 at http://www.newlc.com</guid>
</item>
<item>
 <title>Re: RFile or file stream</title>
 <link>http://www.newlc.com/topic-567#comment-4568</link>
 <description>&lt;div class=&quot;smf-content&quot;&gt;Great... I will add all this in the sticky topic with the definitions.&lt;br /&gt;(Nikolas, don&amp;#039;t forget to put your file on the CleanupStack just after opening it - CleanupClosePushL(file) - since the HBufC allocation may leave, and same for sree where the iFileServer should be on the cleanupstack - but it looks like this is just a data member of a class just copied in the example so this is probably ok anyway ).&lt;br /&gt;&lt;br /&gt;Who can do this for the stream and store interfaces &lt;img src=&quot;/sites/all/modules/smf_filter/smf_smileys/huh.gif&quot; alt=&quot;Huh&quot; border=&quot;0&quot; /&gt;&amp;nbsp; &lt;img src=&quot;/sites/all/modules/smf_filter/smf_smileys/rolleyes.gif&quot; alt=&quot;Roll Eyes&quot; border=&quot;0&quot; /&gt;&lt;/div&gt;</description>
 <pubDate>Fri, 24 Jun 2005 12:25:47 +0200</pubDate>
 <dc:creator>eric</dc:creator>
 <guid isPermaLink="false">comment 4568 at http://www.newlc.com</guid>
</item>
<item>
 <title>Re: RFile or file stream</title>
 <link>http://www.newlc.com/topic-567#comment-4567</link>
 <description>&lt;div class=&quot;smf-content&quot;&gt;Cheers to all who answered this threadÂ  &lt;img src=&quot;/sites/all/modules/smf_filter/smf_smileys/grin.gif&quot; alt=&quot;Grin&quot; border=&quot;0&quot; /&gt;!&lt;br /&gt;&lt;br /&gt;To complement the code already here, here is some very simple code to read the contents of a file into a heap-based descriptor.&lt;br /&gt;I&amp;#039;ve put that code in the OpenFileL method of my document class (which explains where the parameters in the Open method come from).&lt;br /&gt;&lt;br /&gt;Â  Â /* Txt file to be opened. */&lt;br /&gt;Â  Â RFile file ;&lt;br /&gt;Â  Â file.Open(aFs, aFilename,EFileRead) ;&lt;br /&gt;&lt;br /&gt;Â  Â /* Size of file. */&lt;br /&gt;Â  Â TInt iSize ;Â  Â &lt;br /&gt;Â  Â file.Size(iSize) ;&lt;br /&gt;Â  Â &lt;br /&gt;Â  Â /* Allocate enough memory to read in the whole file. */&lt;br /&gt;Â  Â HBufC8* buf = HBufC8::NewLC(iSize) ;&lt;br /&gt;&lt;br /&gt;Â  Â /* Get a pointer to modify contents of buffer. */&lt;br /&gt;Â  Â TPtr8Â  pBuf = buf-&amp;gt;Des() ;&lt;br /&gt;&lt;br /&gt;Â  Â /* Read data into buf. */&lt;br /&gt;Â  Â file.Read(pBuf) ;&lt;br /&gt;&lt;br /&gt;Â  Â file.Close() ;&lt;br /&gt;&lt;br /&gt;Â  Â /*Â  When buf is not needed anymore... */&lt;br /&gt;Â  Â CleanupStack::PopAndDestroy() ;&lt;br /&gt;&lt;/div&gt;</description>
 <pubDate>Fri, 24 Jun 2005 12:10:52 +0200</pubDate>
 <dc:creator>nikolas</dc:creator>
 <guid isPermaLink="false">comment 4567 at http://www.newlc.com</guid>
</item>
<item>
 <title>Re: RFile or file stream</title>
 <link>http://www.newlc.com/topic-567#comment-4566</link>
 <description>&lt;div class=&quot;smf-content&quot;&gt;&lt;br /&gt;&lt;br /&gt; In order to have access to files first you connect to fileserver with which can have access to file operations:&lt;br /&gt;&lt;br /&gt;Example code for read:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;RFs iFileServer;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;User::LeaveIfError(iFileServer.Connect());&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;RFile fp;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;TInt err = fp.Open(iFileServer,_L(&amp;quot;temp.txt&amp;quot;),EFileRead);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if(err !=KErrNone)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;break;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;TBuf8&amp;lt;10&amp;gt;&amp;nbsp; buf;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;TBuf16&amp;lt;200&amp;gt; buf16;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;TBuf16&amp;lt;10&amp;gt; tmp16;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;TInt Err;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Err = fp.Read(buf);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;while(!Err &amp;amp;&amp;amp; buf.Length()&amp;gt;0)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;tmp16.Copy(buf);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; buf16.Append(tmp16);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Err = fp.Read(buf);&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;iAppContainer-&amp;gt;PrintData(buf16);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;fp.Close();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;iFileServer.Close(); &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Example code for File write:&lt;br /&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; RFs iFileServer;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;User::LeaveIfError(iFileServer.Connect());&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;RFile fp;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;TInt err = fp.Open(iFileServer,_L(&amp;quot;temp.txt&amp;quot;),EFileWrite);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if(err !=KErrNone)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;fp.Create(iFileServer,_L(&amp;quot;temp.txt&amp;quot;),EFileWrite);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;TInt pos=0 ;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;fp.Seek(ESeekEnd,pos);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;_LIT8(KData,&amp;quot;Hi&amp;quot;);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;fp.Write(KData);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;fp.Close();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;iFileServer.Close(); &lt;br /&gt;&lt;br /&gt;============================&lt;br /&gt;&lt;br /&gt;Hope this would help u&lt;/div&gt;</description>
 <pubDate>Fri, 24 Jun 2005 10:05:54 +0200</pubDate>
 <dc:creator>sree.iitm</dc:creator>
 <guid isPermaLink="false">comment 4566 at http://www.newlc.com</guid>
</item>
<item>
 <title>Re: RFile or file stream</title>
 <link>http://www.newlc.com/topic-567#comment-4565</link>
 <description>&lt;div class=&quot;smf-content&quot;&gt;Ok,&lt;br /&gt;&lt;br /&gt;A few definations. &lt;br /&gt;&lt;br /&gt;Files:&amp;nbsp; Just plain old binary files, where you the developer are responsable for writting everything to that file in the correct format that you need to get data back out.&amp;nbsp; For instance, if you write a descriptor to the file, you would need to write a flag indicating its type (8 or 16 bit), it&amp;#039;s length, its maxlength if its non-constant, and its data to reconstruct it from the file.&lt;br /&gt;&lt;br /&gt;Streams:&amp;nbsp; Provide a simple API for you to write data in external format and to allow you to abstract the underlying storage away from your code.&amp;nbsp; For instance, you can attach a stream to a file, or to a block of memory, but reading and writting to it remain the same.&amp;nbsp; Also, the bit above about writting lengths etc is done for you - when you send a descriptor to a stream, everything needed to reconstruct it is written for you.&amp;nbsp; This is because the descriptor classes serialise themselfs - they provide an Externalise and Internalise method which the framework calls when one of them is added to a stream - in these method they write and read all their own data members.&amp;nbsp; This process is known as serialisation, ever done MFC?&amp;nbsp; Then think CArchive - basically its about making it a classes own responsabilty to save and load thier state.&lt;br /&gt;&lt;br /&gt;Stores:&amp;nbsp; Streams are great, but they have one problem.&amp;nbsp; They are sequentially accessed.&amp;nbsp; In that you must know the exact order thinks went in to get them out.&amp;nbsp; So say if you have two classes in your stream, A and B.&amp;nbsp; When you load from that stream, if you want B, you must first load A even if you don&amp;#039;t want it.&amp;nbsp; Stores get round this.&amp;nbsp; Essentially, they are a network of streams - mutiple streams which are individually accessable from there &amp;quot;stream id&amp;quot;.&amp;nbsp; The stream id&amp;#039;s are maintained by a dictonary at the start of the store.&amp;nbsp; &lt;br /&gt;&lt;br /&gt;Finally, on top of stores, you have DBMS.&amp;nbsp; Which uses the store principle to implment a complete relational database system.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;</description>
 <pubDate>Fri, 24 Jun 2005 09:30:07 +0200</pubDate>
 <dc:creator>didster</dc:creator>
 <guid isPermaLink="false">comment 4565 at http://www.newlc.com</guid>
</item>
<item>
 <title>Re: RFile or file stream</title>
 <link>http://www.newlc.com/topic-567#comment-4564</link>
 <description>&lt;div class=&quot;smf-content&quot;&gt;Nikolas is right.&lt;br /&gt;&lt;br /&gt;FileStores (and the whole file stream interface) is a layer that is built upon RFile and that adds a specific format to the saved data (ex: a dictionnary to handle multiple streams in the same store). Based on that, it is clear that you can not open with the stream interface a file that you have generated using RFile primitives (unless you have created the exact same format that the one expected by the stream primitives). &lt;br /&gt;&lt;br /&gt;I don&amp;#039;t really understand why you have to open your file with those primitive if you create it with RFile. My advice would be:&lt;br /&gt;- change your code and create your file using the stream primitive and everything would be fine.&lt;br /&gt;- or check that you really have to use the stream interface.....&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;</description>
 <pubDate>Fri, 24 Jun 2005 09:06:30 +0200</pubDate>
 <dc:creator>eric</dc:creator>
 <guid isPermaLink="false">comment 4564 at http://www.newlc.com</guid>
</item>
<item>
 <title>Re: RFile or file stream</title>
 <link>http://www.newlc.com/topic-567#comment-4563</link>
 <description>&lt;div class=&quot;smf-content&quot;&gt;hello my friend,&lt;br /&gt;&lt;br /&gt;well the wheel has gone full turn and i&amp;#039;m having exactly the same dilema...&lt;br /&gt;&lt;br /&gt;I talked to some guys on irc (#symbian.dev on EFnet) and we haven&amp;#039;t figured yet what exactly is the problem. &lt;br /&gt;&lt;br /&gt;However they were a few conjectures:&lt;br /&gt;&lt;br /&gt;&amp;nbsp; Using a readstream to read from a file that does not contain a filestore is random.&lt;br /&gt;&lt;br /&gt;&amp;nbsp; Using a readstream to read from a file that has not been written to with a writestream is random.&lt;br /&gt;&lt;br /&gt;Will let you know when I understand this better...&lt;br /&gt;&lt;br /&gt;Take care,&lt;br /&gt;&lt;br /&gt;Nikolas.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;</description>
 <pubDate>Fri, 24 Jun 2005 00:06:49 +0200</pubDate>
 <dc:creator>nikolas</dc:creator>
 <guid isPermaLink="false">comment 4563 at http://www.newlc.com</guid>
</item>
<item>
 <title>RFile or file stream</title>
 <link>http://www.newlc.com/topic-567#comment-4562</link>
 <description>&lt;div class=&quot;smf-content&quot;&gt;Eric,Thanks for ur reply. &lt;img src=&quot;/sites/all/modules/smf_filter/smf_smileys/smiley.gif&quot; alt=&quot;Smiley&quot; border=&quot;0&quot; /&gt; &lt;br /&gt;&lt;br /&gt;I am trying to create a application that will be used by other program to save high score. I am using the RFile to write and read file now....but i am asked to do it using file stream now.....is it file stream must used together with File store or RFile.&lt;br /&gt;&lt;br /&gt;The code below is used by me to write&lt;br /&gt; to a file (C:\\System\\apps\\testdata\\testdata.dat).&lt;br /&gt;&lt;br /&gt;---------------------------------------------------------------------------&lt;br /&gt;void CTestdataAppUi::Write()&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;TBuf8&amp;lt;KTestLength&amp;gt; buf;&lt;br /&gt;RFs TheFs;&lt;br /&gt;RFile file;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;&lt;br /&gt;User::LeaveIfError(TheFs.Connect()); &lt;br /&gt;User::LeaveIfError(file.Open(TheFs,KTestFile,EFileWrite));&lt;br /&gt;&lt;br /&gt;RFile f=file; &lt;br /&gt;RFileWriteStream out(f); &lt;br /&gt;TInt iFileSize;&lt;br /&gt;&lt;br /&gt;file.Size(iFileSize); &lt;br /&gt;out.Attach(file, iFileSize); &lt;br /&gt;out.WriteL(KTestDes); &lt;br /&gt;out.CommitL(); &lt;br /&gt;out.Close(); &amp;nbsp;&lt;br /&gt;TheFs.Close(); &lt;br /&gt;}&lt;br /&gt;--------------------------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;it write data to the file, but when I want to read it using RFileReadStream.It show me system error so I try to use RFile::Read();(file interface) instead of RFileReadStream ...and it&#039;s work....anyone know why?&lt;br /&gt;&lt;br /&gt;Thanks in advance.&lt;/div&gt;</description>
 <pubDate>Fri, 17 Oct 2003 10:13:33 +0200</pubDate>
 <dc:creator>joanntsc</dc:creator>
 <guid isPermaLink="false">comment 4562 at http://www.newlc.com</guid>
</item>
<item>
 <title>RFile or file stream</title>
 <link>http://www.newlc.com/topic-567#comment-4561</link>
 <description>&lt;div class=&quot;smf-content&quot;&gt;The question is maybe a little bit too open to have a clear answer. Try to be more specific &amp;nbsp;&lt;img src=&quot;/sites/all/modules/smf_filter/smf_smileys/wink.gif&quot; alt=&quot;Wink&quot; border=&quot;0&quot; /&gt; &lt;br /&gt;&lt;br /&gt;RFiles and CFileStores have their pros and cons.... it really depends on what you need. &lt;br /&gt;&lt;br /&gt;Eric&lt;/div&gt;</description>
 <pubDate>Fri, 17 Oct 2003 09:25:16 +0200</pubDate>
 <dc:creator>eric</dc:creator>
 <guid isPermaLink="false">comment 4561 at http://www.newlc.com</guid>
</item>
<item>
 <title>RFile or file stream</title>
 <link>http://www.newlc.com/topic-567#comment-4560</link>
 <description>&lt;div class=&quot;smf-content&quot;&gt;Anyone help? Thanks again.&lt;/div&gt;</description>
 <pubDate>Fri, 17 Oct 2003 08:24:28 +0200</pubDate>
 <dc:creator>joanntsc</dc:creator>
 <guid isPermaLink="false">comment 4560 at http://www.newlc.com</guid>
</item>
<item>
 <title>RFile or file stream</title>
 <link>http://www.newlc.com/topic-567</link>
 <description>&lt;div class=&quot;smf-content&quot;&gt;&lt;/div&gt;&lt;p&gt;&lt;a href=&quot;http://www.newlc.com/topic-567&quot;&gt;read more&lt;/a&gt;&lt;/p&gt;</description>
 <comments>http://www.newlc.com/topic-567#comments</comments>
 <category domain="http://www.newlc.com/forums/symbian-c">Symbian C++</category>
 <pubDate>Wed, 15 Oct 2003 08:57:46 +0200</pubDate>
 <dc:creator>joanntsc</dc:creator>
 <guid isPermaLink="false">1644 at http://www.newlc.com</guid>
</item>
</channel>
</rss>
