Symbian3/SDK/Source/GUID-52151070-626D-5F14-B53F-7B46BCBD633E.dita
changeset 0 89d6a7a84779
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Symbian3/SDK/Source/GUID-52151070-626D-5F14-B53F-7B46BCBD633E.dita	Thu Jan 21 18:18:20 2010 +0000
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. -->
+<!-- This component and the accompanying materials are made available under the terms of the License 
+"Eclipse Public License v1.0" which accompanies this distribution, 
+and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". -->
+<!-- Initial Contributors:
+    Nokia Corporation - initial contribution.
+Contributors: 
+-->
+<!DOCTYPE concept
+  PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
+<concept id="GUID-52151070-626D-5F14-B53F-7B46BCBD633E" xml:lang="en"><title>Using
+TAutoClose</title><shortdesc>Example code showing how <codeph>TAutoClose</codeph> can be used
+to clean up when an object goes out of scope.</shortdesc><prolog><metadata><keywords/></metadata></prolog><conbody>
+<p>A simple example shows how this class can be used.</p>
+<codeblock id="GUID-468EE01A-8EC1-5D8E-845A-710D5BE3BBBC" xml:space="preserve">TInt ReadFile(const TDesC&amp; aFile)
+//
+// Read a file
+//
+    {
+    TAutoClose&lt;RFile&gt; file;
+    TInt r=file.iObj.Open(aFile,KFileStreamText|EFileExclusive);
+    if (r!=KErrNone)
+        return(r);
+    TBuf&lt;100&gt; b;
+    if ((r=file.iObj.Read(b))!=KErrNone)
+        return(r);
+    ...
+    }</codeblock>
+<p>The object <codeph>file</codeph> goes out of scope when the function completes,
+and the compiler automatically destroys it, calling the <xref href="GUID-3377FA4B-FDC8-3B25-8C5F-34675F6BEA12.dita"><apiname>TAutoClose</apiname></xref> destructor
+in the process. The destructor calls <codeph>Close()</codeph> on the <codeph>RFile</codeph> member
+of <codeph>TAutoClose</codeph>.</p>
+</conbody></concept>
\ No newline at end of file