当用户选择文件夹时,Mac沙盒应用程序可以访问什么? [英] What does a Mac sandboxed app get access to when the user selects a folder?

查看:81
本文介绍了当用户选择文件夹时,Mac沙盒应用程序可以访问什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在阅读有关Mac应用程序沙箱的信息,并想知道当用户在NSOpenPanel或NSSavePanel中选择一个文件夹时到底会发生什么. "应用程序沙箱设计指南 "给出以下示例:

I'm reading about Mac app sandboxing and am wondering what exactly happens when a user selects a folder in an NSOpenPanel or NSSavePanel. The "App Sandbox Design Guide" gives the following example:

应用程序的用户指定他们要使用文件或文件夹时,系统会将关联的路径添加到应用程序的沙箱中.举例来说,用户将~/Documents文件夹拖到应用程序的Dock磁贴上(或拖到应用程序的Finder图标上,或拖到应用程序的打开窗口中),从而表明他们要使用该文件夹.作为响应,系统会将~/Documents文件夹,其内容及其子文件夹提供给您的应用.

When a user of your app specifies they want to use a file or a folder, the system adds the associated path to your app’s sandbox. Say, for example, a user drags the ~/Documents folder onto your app’s Dock tile (or onto your app’s Finder icon, or into an open window of your app), thereby indicating they want to use that folder. In response, the system makes the ~/Documents folder, its contents, and its subfolders available to your app.

我不清楚这里的内容"是什么意思.这是否仅限于查看文件夹中的文件而无法读取这些文件中的文件?还是这仅仅是意味着该应用程序将能够(递归)读取Documents文件夹内的任何文件(例如,它既可以读取~/Documents/Foo.txt也可以读取~/Documents/Bar/Baz.txt)?那么写操作(写一个现有文件,删除一个文件或创建一个新文件或文件夹)呢?

It's not clear to me what's meant by the "contents" here. Is this limited to seeing what files are in the folder without being able to read what's in those files? Or does this simply mean that the app will be able to read any file that's (recursively) inside the Documents folder (so it can, for example, read both ~/Documents/Foo.txt and ~/Documents/Bar/Baz.txt)? And what about write operations (writing to an existing file, deleting one or creating a new file or folder)?

推荐答案

该应用可以读取所选文件夹及其子文件夹中的所有文件.写入,写入新文件以及覆盖现有文件都同样如此.删除以及新建文件夹,在文件夹(或其他您具有所需权限的文件夹)范围内移动文件夹也是可能的.

The app can read all files in the selected folder as well as its subfolders. Same is true for writing, both for new files as well as overwriting existing ones. Deleting is also possible as well as new folder creation, folder movement within the bounds of the folder (or other folders you have the required rights for).

简单地说,您可以在此文件夹及其子文件夹中自由执行所需的任何操作.

Simply put, you have the freedom to do whatever you want within this folder and its subfolders.

注意事项:打开保存面板并显示Documents作为目标时,可能是~/Library/Containers/<app signature>/Data/Documents.您可以更改位置,但是在文件成功保存后却找不到~/Documents时,我第一次感到困惑.

Caveat: When the save panel opens up and it shows Documents as target, it might be ~/Library/Containers/<app signature>/Data/Documents. You may change the location, but the first time I was baffled after the file had successfully been saved but was not located at ~/Documents.

这篇关于当用户选择文件夹时,Mac沙盒应用程序可以访问什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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