Determining the application path using Symbian C++
Article Metadata
Compatibility
S60 3rd Edition and later
Article
Contents |
Description
The end user can install applications either on the C: (phone memory) or E: (memory card, flash, or hard disk) drive. Applications may need to be aware of their installation location. The way the installation location is determined depends on the S60 platform version.
Solution
S60 3rd Edition (and later)
From S60 3rd Edition onwards, all application binaries (EXE and DLL files) are stored under \sys\bin. To access this directory, the application needs AllFiles capability. Resources and data cannot be stored in this directory. Instead, applications have their own restricted view on the file system consisting of the directory subtree \private\<SID>\, where SID is a security identifier, unique to each process. Applications use their private directory to hold .ini, .mbm, .rsc, and data files. Other processes cannot access the directory without the AllFiles capability.
CompleteWithAppPath() will always return \sys\bin as the application installation path on S60 3rd Edition. To access application data files located in the application's private directory, a different way to construct the path is needed:
TFileName appPath;
TBuf<2> appDrive;
// Returns private path of this application
// in following format: \Private\<SID of the application>\
// (does not contain drive specification).
iEikonEnv->FsSession().PrivatePath( appPath );
// Extract drive letter into appDrive
appDrive.Copy(iEikonEnv->EikAppUi()->Application()->AppFullName().Left(2));
// Insert drive letter into path
appPath.Insert(0, appDrive);
S60 2nd Edition
On S60 2nd Edition, use the CompleteWithAppPath( TDes& aFileName ) method from aknutils.h. All the components that are specified in the given descriptor (drive letter, path, and file name including the extension) are returned in the result; any missing components (path and drive letter) are taken from the application path (<drive>:\system\apps\<application_name> directory).
#include <aknutils.h>
// Insert the full application path into the file name (fileName)
TFileName fullPath(fileName);
CompleteWithAppPath(fullPath); // from aknutils.h


How do you do this in a S60 3rd Edition console exe?