Week 23 contribution of PDK documentation content. See release notes for details. Fixes bugs Bug 2714, Bug 462.
<?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-F86CFD79-88B1-55E0-AF81-4666D97B7AF5" xml:lang="en"><title>Automatic
file deletion on closure</title><shortdesc>This topic describes how a temporary file can be destroyed automatically
when the owning thread closes it or if the owning thread crashes. </shortdesc><prolog><metadata><keywords/></metadata></prolog><conbody>
<p>Set <codeph>EDeleteOnClose</codeph> when opening a temporary file to enable
the automatic deletion on closure. <codeph>EDeleteOnClose</codeph> can be
used with <xref href="GUID-BE0804F6-4375-3C8A-8C83-968F510466E0.dita#GUID-BE0804F6-4375-3C8A-8C83-968F510466E0/GUID-87D0C77C-CC63-3D70-BACE-3C5EE702BD37"><apiname>RFile::Temp()</apiname></xref> and <xref href="GUID-BE0804F6-4375-3C8A-8C83-968F510466E0.dita#GUID-BE0804F6-4375-3C8A-8C83-968F510466E0/GUID-1EB4AA8F-9363-3EC5-8AE2-1F70F15FCF15"><apiname>RFile::Create()</apiname></xref>.
For example: </p>
<codeblock id="GUID-F74D3314-7C59-5350-913F-D38AED696799" xml:space="preserve">r = file.Create(TheFs, filename, EFileShareAny | EFileRead | EFileWrite | EDeleteOnClose);</codeblock>
<p>The purpose of this flag is to prevent memory leaks when components that
create temporary files crash. </p>
<section id="GUID-BB928F1C-75DD-409D-8C0A-B753D3B19FE3"><note><ul>
<li id="GUID-BFA882BB-D312-5FBB-906F-5B27A6B4507D"><p>Existing files cannot
be opened with <codeph>EDeleteOnClose</codeph> set. Any attempts to do this
will return the error message <codeph>KErrArgument</codeph>. </p> </li>
<li id="GUID-CA76B615-62CE-59E5-B1D8-B0628728D7C6"><p>Automatic file deletion
is not default behavior. </p> </li>
</ul></note> </section>
</conbody></concept>