|
1 <?xml version="1.0" encoding="utf-8"?> |
|
2 <!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. --> |
|
3 <!-- This component and the accompanying materials are made available under the terms of the License |
|
4 "Eclipse Public License v1.0" which accompanies this distribution, |
|
5 and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". --> |
|
6 <!-- Initial Contributors: |
|
7 Nokia Corporation - initial contribution. |
|
8 Contributors: |
|
9 --> |
|
10 <!DOCTYPE concept |
|
11 PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd"> |
|
12 <concept id="GUID-F86CFD79-88B1-55E0-AF81-4666D97B7AF5" xml:lang="en"><title>Automatic |
|
13 file deletion on closure</title><shortdesc>This topic describes how a temporary file can be destroyed automatically |
|
14 when the owning thread closes it or if the owning thread crashes. </shortdesc><prolog><metadata><keywords/></metadata></prolog><conbody> |
|
15 <p>Set <codeph>EDeleteOnClose</codeph> when opening a temporary file to enable |
|
16 the automatic deletion on closure. <codeph>EDeleteOnClose</codeph> can be |
|
17 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>. |
|
18 For example: </p> |
|
19 <codeblock id="GUID-F74D3314-7C59-5350-913F-D38AED696799" xml:space="preserve">r = file.Create(TheFs, filename, EFileShareAny | EFileRead | EFileWrite | EDeleteOnClose);</codeblock> |
|
20 <p>The purpose of this flag is to prevent memory leaks when components that |
|
21 create temporary files crash. </p> |
|
22 <section id="GUID-BB928F1C-75DD-409D-8C0A-B753D3B19FE3"><note><ul> |
|
23 <li id="GUID-BFA882BB-D312-5FBB-906F-5B27A6B4507D"><p>Existing files cannot |
|
24 be opened with <codeph>EDeleteOnClose</codeph> set. Any attempts to do this |
|
25 will return the error message <codeph>KErrArgument</codeph>. </p> </li> |
|
26 <li id="GUID-CA76B615-62CE-59E5-B1D8-B0628728D7C6"><p>Automatic file deletion |
|
27 is not default behavior. </p> </li> |
|
28 </ul></note> </section> |
|
29 </conbody></concept> |