Mac Sandbox 可寫路徑

為了提高系統(tǒng)安全性,蘋果引入了Sandbox機(jī)制,要在app store發(fā)布的軟件需符合該機(jī)制。軟件的讀寫權(quán)限被嚴(yán)格的限制在一定范圍內(nèi),大部分路徑的讀寫權(quán)限需要向用戶請求。但是有些數(shù)據(jù)我們需要獲得較高的權(quán)限,而且沒必要每次都向用戶申請。

如何解決呢?還好apple給我們留了一個(gè)路徑讓我們自由讀寫。下面是apple文檔介紹如何操作相應(yīng)目錄

Container Directories and File System Access

When you adopt App Sandbox, your application has access to the following locations:

The app container directory. Upon first launch, the operating system creates a special directory for use by your app—and only by your app—called a container. Each user on a system gets an individual container for your app, within their home directory; your app has unfettered read/write access to the container for the user who ran it.

App group container directories. A sandboxed app can specify an entitlement that gives it access to one or more app group container directories, each of which is shared among all apps with that entitlement.

User-specified files. A sandboxed app (with an appropriate entitlement) automatically obtains access to files in arbitrary locations when those files are explicitly opened by the user or are dragged and dropped onto the application by the user.

Related items. With the appropriate entitlement, your app can access a file with the same name as a user-specified file, but a different extension. This can be used for accessing files that are functionally related (such as a subtitle file associated with a movie) or for saving modified files in a different format (such as re-saving an RTF flat file as an RTFD container after the user added a picture).

Temporary directories, command-line tool directories, and specific world-readable locations. A sandboxed app has varying degrees of access to files in certain other well-defined locations.

These policies are detailed further in the sections that follow.

The app container directory.就是我們獲取的完全權(quán)限。

The app container directory. Upon first launch, the operating system

creates a special directory for use by your app—and only by your

app—called a container. Each user on a system gets an individual

container for your app, within their home directory; your app has

unfettered read/write access to the container for the user who ran it.


下面是kindle的containers路徑

~/Library/Containers/com.amazon.Kindle/Data/Library/Application Support/Kindle

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容