Symbian3/SDK/Source/GUID-FA6E3270-C20A-5B05-9FFC-F3D4D8B35999.dita
changeset 7 51a74ef9ed63
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Symbian3/SDK/Source/GUID-FA6E3270-C20A-5B05-9FFC-F3D4D8B35999.dita	Wed Mar 31 11:11:55 2010 +0100
@@ -0,0 +1,41 @@
+<?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-FA6E3270-C20A-5B05-9FFC-F3D4D8B35999" xml:lang="en"><title>How
+to create and open a file</title><shortdesc>This topic describes the interface used to create, open, read from
+and write to a single file.</shortdesc><prolog><metadata><keywords/></metadata></prolog><conbody>
+<p>The <xref href="GUID-BE0804F6-4375-3C8A-8C83-968F510466E0.dita"><apiname>RFile</apiname></xref> interface is used to create, open, read from
+and write to a single file. </p>
+<section id="GUID-4E0574F0-91EF-4F5A-ABAB-18A5A37FF3E1"><title>Creating and opening a file</title> <p>A common pattern is
+to attempt to open an existing file, without replacing its existing data,
+and create it if it does not exist. </p> <ol id="GUID-42702312-C0C9-5788-8819-4BB5730320B5">
+<li id="GUID-31FFB1C8-AB53-581B-835E-0C33839CEEA5"><p>Use <codeph>Open()</codeph> to
+open an existing file for reading or writing - an error is returned if it
+does not already exist. </p> </li>
+<li id="GUID-9CC8F1EA-196E-5A77-AA80-9BBA198C3B62"><p>Use <codeph>Create()</codeph> to
+create and open a new file for writing. </p> </li>
+</ol> <codeblock id="GUID-70C09A68-4C30-5766-99C5-D9BF23ADC85F" xml:space="preserve">TInt err=file.Open(fsSession,fileName,shareMode);
+if (err==KErrNotFound) // file does not exist - create it
+    err=file.Create(fsSession,fileName,shareMode);</codeblock> </section>
+<section id="GUID-618128B4-085E-453B-BD16-9DDFD2212B2C"><title>Specifying a share and access mode</title> <p>Use various
+flags to specify how a file is opened. </p> <codeblock id="GUID-44FB8760-7C13-503D-A53A-3DF794768D26" xml:space="preserve">
+// Open a file as text, writable, and shared with other clients
+RFile file;
+_LIT(KFileName, "FILENAME.CPP");
+file.Open(fsSession,KFileName,EFileStreamText|EFileWrite|EFileShareAny);</codeblock> <note><ul>
+<li id="GUID-6124BD90-9267-523E-BC8E-590BED022083"><p>If another <codeph>RFile</codeph> object
+tries to open this file in <codeph>EFileShareExclusive</codeph> or <codeph>EFileShareReadersOnly</codeph> mode,
+access is denied. It can only be accessed in <codeph>EFileShareAny</codeph> mode. </p> </li>
+<li id="GUID-45948CEF-7780-51E4-B862-F7A8A5983EE5"><p>If a file is not closed
+explicitly (using <codeph>RFile::Close()</codeph>), it will be closed when
+the server session associated with it is closed. </p> </li>
+</ul></note> </section>
+</conbody></concept>
\ No newline at end of file