Symbian3/SDK/Source/GUID-C72CF928-F32E-55CF-A4B0-B51CD7D14F8A.dita
author Dominic Pinkman <Dominic.Pinkman@Nokia.com>
Thu, 21 Jan 2010 18:18:20 +0000
changeset 0 89d6a7a84779
permissions -rw-r--r--
Initial contribution of Documentation_content according to Feature bug 1266 bug 1268 bug 1269 bug 1270 bug 1372 bug 1374 bug 1375 bug 1379 bug 1380 bug 1381 bug 1382 bug 1383 bug 1385

<?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 xml:lang="en" id="GUID-C72CF928-F32E-55CF-A4B0-B51CD7D14F8A"><title>How to use file server sessions</title><prolog><metadata><keywords/></metadata></prolog><conbody><p>The <codeph>Rfs</codeph> class represents a session with the file server. The following code demonstrates the use of the <keyword>session
        path</keyword> and shows how to connect and disconnect to and from the file server. </p> <ul><li id="GUID-6D41700D-4355-5029-A767-4D26E830522D"><p>Use <codeph>Connect()</codeph> to connect to the file server. </p> </li> <li id="GUID-AD64EBC8-00EF-5AB9-9902-33CA63FBD41E"><p>Use <codeph>SessionPath()</codeph> to get the session path. </p> </li> <li id="GUID-E38A2DDB-0071-505F-9D6A-37A4BB22C4C5"><p>Use <codeph>SetSessionPath()</codeph> to set the session path. </p> </li> <li id="GUID-54C5D745-D2DE-5B3B-AA67-9A3B0505515B"><p>Use <codeph>Close()</codeph> to close the file server session when its use is complete. </p> </li> </ul> <codeblock id="GUID-AFD9152A-0439-5807-905D-1EA6FBC2BF8B" xml:space="preserve">_LIT(KSession,"Session path for fsSession is %S\n"); 
RFs fsSession;
CleanupClosePushL(fsSession);
User::LeaveIfError(fsSession.Connect()); 
TFileName path;
User::LeaveIfError(fsSession.SessionPath(path));
console-&gt;Printf(KSession,&amp;path); 
... 
... 
fsSession.Close();
CleanupStack::PopAndDestroy();</codeblock> <p>Use <xref href="GUID-16B0008A-0F85-3C1E-89E1-E7431E2C93B9.dita"><apiname>CleanupClosePushL()</apiname></xref> and <xref href="GUID-0DD554D7-B9B1-3FD3-898F-4D855144FCEA.dita#GUID-0DD554D7-B9B1-3FD3-898F-4D855144FCEA/GUID-C3BB6B4F-8096-3D74-9BEA-D77F309D900A"><apiname>CleanupStack::PopAndDestroy()</apiname></xref> so that <codeph>fsSession</codeph> is still closed if any of the <xref href="GUID-C197C9A7-EA05-3F24-9854-542E984C612D.dita#GUID-C197C9A7-EA05-3F24-9854-542E984C612D/GUID-96AFAC46-F3AD-392B-8A97-AFCBF2978CFB"><apiname>User::LeaveIfError()</apiname></xref> functions leave. </p> <p>See also <xref href="GUID-76D1438E-445E-5864-BA9D-27BC61D72C1B.dita">How to use CleanupClosePushL()</xref>. </p> <section><title>Notes</title> <ul><li id="GUID-FB2F41D7-445D-52B1-85DA-AF48CD4E7AA7"><p>The session path is the path in which, by default, all operations in the current file server session take place. The path can be changed by a call to <codeph>RFs::SetSessionPath()</codeph>. </p> </li> <li id="GUID-DEA3DC5E-3315-5091-B69A-396A93588791"><p>Unlike some other systems, there is a <i>single</i> path, rather than a path for each drive: the path consists of a drive and a path specification. </p> </li> <li id="GUID-9FE6A9C7-08C8-57D4-8E5F-FA3FE7894544"><p>You can make several connections to the file server from the same program, and each can have a different session path. </p> </li> <li id="GUID-349AE117-FB3F-5147-B62D-9A74AA0326EC"><p>If a file server session is not closed using the <codeph>Close()</codeph> function, it is closed automatically when the thread that opened it terminates. However, when operations using the file server session have finished, it is good practice to close all resources immediately. </p> </li> </ul> </section> </conbody></concept>