This topic describes how to use file server sessions.
The Rfs class represents a session with the file server. The following code demonstrates the use of the session path and shows how to connect and disconnect to and from the file server.
Use Connect() to connect to the file server.
Use SessionPath() to get the session path.
Use SetSessionPath() to set the session path.
Use Close() to close the file server session when its use is complete.
_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->Printf(KSession,&path); ... ... fsSession.Close(); CleanupStack::PopAndDestroy();
Use CleanupClosePushL() and CleanupStack::PopAndDestroy() so that fsSession is still closed if any of the User::LeaveIfError() functions leave.
See also How to use CleanupClosePushL() .
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 RFs::SetSessionPath() .
Unlike some other systems, there is a single path, rather than a path for each drive: the path consists of a drive and a path specification.
You can make several connections to the file server from the same program, and each can have a different session path.
If a file server session is not closed using the Close() 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.
Copyright ©2010 Nokia Corporation and/or its subsidiary(-ies).
All rights
reserved. Unless otherwise stated, these materials are provided under the terms of the Eclipse Public License
v1.0.