• How to get private directory(转)


    Platform Security introduces the data caging concept. There are some folders on Symbian OS v9 that can only be accessed with certain privileges. The private folder, \private\<sid>, is one of them. It is a folder where an application can store sensitive data. Other applications, except the one with AllFiles capability, cannot read/write to the folder.

    The <sid> is the Secure ID of the application. It is defined in the .mmp file. The following example shows how to get the path of the private folder of an application. For example, if an application has SID of 0x20001978, the private folder would be \private\20001978. The function that is used to get the private folder is RFs::PrivatePath().

    [edit]Example

    const TInt KPathNameLength = 100;
    TBuf< KPathNameLength > pathWithoutDrive;
    TBuf< KPathNameLength > driveAndPath;
    TBuf< 2 > appDrive;
     
    // Get application's private path
    // This is e.g. '\Private\20001978\'
    // Does not contain drive.
    iEikonEnv->FsSession().PrivatePath( pathWithoutDrive );
     
    // Extract drive letter into appDrive:
    appDrive.Copy(CEikonEnv::Static()->EikAppUi()->Application()->AppFullName().Left(2));
     
    // Combine drive letter and private path
    driveAndPath.Copy(appDrive);
    driveAndPath.Append(pathWithoutDrive);
     
    // Now driveAndPath contains e.g. 'E:\Private\20001978\'

    [edit]Example 2

    #include <f32file.h>
    TInt GetPrivatePath(TFileName& privatePath)
    {
    TFileName KPath;
    RFs fsSession;
    TInt result;
    result = fsSession.Connect();
    if (result != KErrNone)
    return result;
    fsSession.PrivatePath(KPath);
    TFindFile findFile(fsSession);
    privatePath = KPath;
    result = findFile.FindByDir(KPath, KNullDesC);
    if (result == KErrNone)
    privatePath = findFile.File();
    fsSession.Close();
    return result;
    }

    The code must be linked with efsrv.lib. The resulting path contains backslash at the end.

  • 相关阅读:
    POJ 2996 Help Me with the Game (模拟)
    PCL系列——怎样逐渐地配准一对点云
    sublime text3同时编辑多行
    博客搬家
    将博客搬至CSDN
    centos7用xshell可以连接, xftp连接失败!(墙裂推荐)
    重启ssh服务出现Redirecting to /bin/systemctl restart sshd.service
    重装wordpress
    ubuntu 16.04 启用root用户方法
    Ubuntu创建新用户并增加管理员权限(授权有问题)
  • 原文地址:https://www.cnblogs.com/yaoliang11/p/1902911.html
Copyright © 2020-2023  润新知