开发者

FSFindFolder finds strange directory

I have the following code:

FSRef FileRef;
OSStatus Error = ::FSFindFolder(kUserDomain, kApplicationSupportFolderType, kCreateFolder, &FileRef);
if (Error != noErr)
{
    //error
}

CFURLRef UrlRef = ::CFURLCreateFromFSRef(kCFAllocatorDefault, &FileRef);
if (!UrlRef)
{
    //error
}
CFStringRef PathRef = ::CFURLCopyFileSystemPath(UrlRef, kCFURLPOSIXPathStyle);
/Qt class for string store
QString strResult;
if (PathRef)
{
    CFIndex Size = ::CFStringGetMaximumSizeForEncoding(::CFStringGetLength(PathRef), kCFStringEncodingUTF8);
    //Qt smart pointer for arrays
    QScopedArrayPointer<char> spBuffer(new char[Size + 1]);
    if (::CFStringGetCString(PathRef, spBuffer.data(), Size, kCFStringEncodingUTF8))
    {
        strResult = QString::fromUtf8(spBuffer.data());
    }
    else
    {
        //error
    }
    ::CFRelease(PathRef);
}
else
{
    //error
}
::CFRelease(UrlRef);

So after code execution I expect to have "/User/myname/Library/Application Sup开发者_StackOverflow社区port" but I have "/private/var/root/Library/Application Support" instead. Does anybody know what the problem I've stumbled on?


/private/var/root is the home directory for the root user. Is this code running in a process with setuid or elevated privileges?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜