如何使用 App 沙盒应用程序在 MAC 卷中查找文件和文件夹 [英] How to find files and folders in MAC volume using App sandboxed application

查看:72
本文介绍了如何使用 App 沙盒应用程序在 MAC 卷中查找文件和文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在 MAC(10.9) 上创建一个沙盒应用程序.当应用程序沙盒化关闭时,我可以从任何路径获取文件和文件夹.但是当我启用 App Sand-boxed 时,它不会从任何路径访问任何文件和文件夹.使用 Qt 5.0 关闭 App Sand-boxed 时,从路径(/Volumes/DriveName"或/"等)获取文件和文件夹

I am creating a sand-boxed application on MAC(10.9).When App Sand-boxed is off then i am able to get files and folders from any path. But when I does App Sand-boxed enabled it's not accessing any files and folders from any path. Getting file and folder from path ("/Volumes/DriveName" or "/" etc.) when App Sand-boxed is off using Qt 5.0

// for folders

    QStringList folderlist;
       QDir curDir = QDir(path);   
       curDir.setFilter(QDir::Dirs);
       QFileInfoList list = curDir.entryInfoList();
       for(;<list.size;)
        {
             QfileInfo fileInfo = list.at(i);
             folderList << fileInfo.filePath();
        }
    // for files
    QStringList filelist;
        QDirIterator dirIn(path,filterfiles,QDir::AllEnteries);
        while(dirIn.hasnext())
    {
     dirIn.next();
    QfileInfo fileInfo = dirIn.fileInfo();
             filelist<< fileInfo.filePath();
    }

    What i do same when App sand-boxed is enabled?  

推荐答案

这就是沙箱的意义所在,您只能访问沙箱内的资源.用户可以向沙箱添加文件,但这需要您的应用程序启动文件打开对话框,以便他们可以选择要使用的文件.

That's the point of a sandbox, you can only access resources within the sandbox. A user may add files to the sandbox, but that requires your application to launch a file open dialog box, so they can choose the file they want to work with.

我建议您首先阅读 Apple此处提供文档.

这篇关于如何使用 App 沙盒应用程序在 MAC 卷中查找文件和文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆