Sandbox 文件存放规则
一、文件路径介绍
<Application_Home>/AppName.app :
1) This is the bundle directory containing the app itself.
2) Do not whrite anything to this directory.
3) iCloud and iTunes do not back up.
<Application_Home>/Documents :
1) Store critical data that not be recreated by your app.
2) Will be copied to the new app directory while app update
3) The contents of this directory are backed up by iTunes.
<Application_Home>/Decuments/Inbox :
1) Use this directory to access files that your app was asked to open by oputside entities. Specifically, the Mail program places email attachments whit your app in this directory.
2) Your app can read and delete files in this directory but cannot create new files or write to existng files. If the user tries to edit a file in this directory, your app must silently move it out of the directory before making any changes.
3) The contents of this directory are backed up by iTunes.
<Application_Home>/tmp :
1) Temporary data comprises any data that you do not need to presist for an extended period of time.
2) Remember to delete those files when you are done with them so that do not continue to consume space on the user's device.
3) iCloud and iTunes do not back up.
<Application_Home>/Library/ :
1) Store not user data files. You typically put files in one of serveral standard subdirectories but you can also create custom subdirectory files you want to backed up but not exposed to the user.
2) Will be copied to the new app directory while app update.
3) The contents of this directories (with the exception of the caches subdirectory) are backed up by iTunes.
<Application_Home>/Library/Caches :
1) Database cache files and downloadable content.
2) Your app should be able to handle situations where cached data is deleted by the system to free up disk space.
3) iCloud and iTunes do not back up.
注意:获取文件路径最好使用 NSSearchPathForDirectoriesInDomains, 不要使用 [NSHomeDirectory() stringByAppendingString: @“xxxxx"]。(if Apple ever chooses to rename or move the Documents directory, your app will break.)
二、Prevent backup
1) ios 5.1 and later,
Add the NSURLIsExcludedFromBackupKey attribute to the corresponding NSURL object using the serResourceValue:forKey:error: method.
2) ios 5.0.1 use
3) iOS 5.0 and earlier, It is not possible to exclude data from backups on iOS 5.0. If your app must support iOS 5.0, then you will need to store your app data in Caches to avoid that data being backed up.
-(BOOL) addSkipBackupAttributeToItemAtURL: (NSURL *)URL {
assert([fileManager fileExistsAtPath: [URL path]]);
if ([BROKER.context.device ifSystemMeetRequireVersion: @"5.1"]) {
NSError* error = nil;
BOOL success = [URL setResourceValue: [NSNumber numberWithBool: YES]
forKey:NSURLIsExcludedFromBackupKey error:&error];
return success;
} else if ([BROKER.context.device ifSystemMeetRequireVersion: @"5.0.1"]) {
const char* filePath = [[URL path] fileSystemRepresentation];
const char* attrName = "com.apple.MobileBackup";
u_int8_t attrValue = ;
int result = setxattr(filePath, attrName, &attrValue, sizeof(attrValue), , );
return (result == );
}
return YES;
}
三、统计文件夹的大小
Sandbox 文件存放规则的更多相关文章
- Destoon 模板存放规则 及 语法参考
模板存放规则及语法参考 一.模板存放及调用规则 模板存放于系统 template 目录,template 目录下的一个目录例如 template/default/ 即为一套模板 模板文件以 .htm ...
- hadoop 集群及hbase集群的pid文件存放位置
一.当hbase集群和hadoop集群停了做一些配置调整,结果执行stop-all.sh的时候无法停止集群, 提示no datanode,no namenode等等之类的信息, 查看stop-all. ...
- c++中头文件include规则浅析[译]
英文原文地址 在开发大型的软件项目时,头文件需要得到恰当的管理,甚至在c中也会面临这种问题,当我们用c++开发时,头文件的管理会变得更复杂,更加耗费我们的时间去管理,下面我将讲一些包含规则来简化这个苦 ...
- SqlServer修改数据库文件及日志文件存放位置
--查看当前的存放位置 select database_id,name,physical_name AS CurrentLocation,state_desc,size from sys.master ...
- I.MX6 Android USB Touch eGTouchA.ini文件存放
/******************************************************************** * I.MX6 Android USB Touch eGTo ...
- Matlab 文件命名规则
Matlab 文件命名规则 1.文件名命名要用英文字符,第一个字符不能是数字和下划线. 2.文件名不要取为matlab的一个固有函数,m文件名的命名尽量不要是简单的英文单词,最好是由大小写英文.数字. ...
- 怎样查看MySql数据库物理文件存放位置
想导出mysql中的数据库文件,死活找不到,网上说在配置文件中有路径,可是我打开我的配置文件,里边的代码全都是注释掉的,没有一句有用的.后来在某一论坛上找到解决方法了,记录下来. 使用如下命令: my ...
- 更改Oracle数据文件名及数据文件存放路径
更改Oracle数据文件名及数据文件存放路径 SQL> select * from v$dbfile; FILE# NAME ---------- ---------------- ...
- ThinkPHP第七天(F函数使用,项目分组配置,项目分组模板文件放置规则配置)
1.F(文件名称,写入数据,写入地址),用于将数据写入至磁盘文件中,如F('Data',$arr,'./Data/'),作用是将$arr写入至网站根目录的Data文件夹中的Data.php中. 2.读 ...
随机推荐
- CodeForces 222B Cosmic Tables
Cosmic Tables Time Limit:3000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u Subm ...
- ZooKeeper使用原理
ZooKeeper的基本原理 ZNode的基本概念 ZooKeeper数据模型的结构与Unix文件系统很类似,整体上可以看作是一棵树,每个节点称做一个ZNode.每个ZNode都可以通过其路径唯一标识 ...
- SU suspike命令学习
用默认参数生成的数据如下: 用别的软件打开数据查看, 依次查看4个脉冲的位置(第几道.出现的时间), 接下来我们做一些小练习,比如说在同一道上放两个脉冲 还可以增加道数,让脉冲位于不同地方,
- LightOJ1316 A Wedding Party(状压DP)
这题事实上只需要关心15个商店和一个起点一个终点,预处理出这几个点之间的最短距离.Floyd会超时,用Dijkstra即可. 然后就是dp[u][S]表示已经经过商店集合S且当前在第u个商店所花的最少 ...
- 【python游戏编程之旅】第三篇---pygame事件与设备轮询
本系列博客介绍以python+pygame库进行小游戏的开发.有写的不对之处还望各位海涵. 在上一篇博客中,我们学习了pygame中的IO.数据http://www.cnblogs.com/msxh/ ...
- BZOJ3103 : Palindromic Equivalence
用Manacher可以推出O(n)对相等和不等关系. 将相等的用并查集维护,不等的连边. 然后从1到n,如果该等价类还没被考虑过,则ans*=26-与它不等的考虑过的等价类个数. #include&l ...
- BZOJ3476 : [Usaco2014 Mar]The Lazy Cow
旋转坐标系后转化为正方形,$x'=x+y$,$y'=x-y+1000001$,$k'=2k-1$ 两根扫描线从左往右扫 f[i]表示y坐标下边界为i时的价值和 每次加入/删除一个点等价于一段区间加减 ...
- 【壁纸自动换】自动下载、更换壁纸(Bing壁纸)--XinBSBingWallPaper[2.7更新]
XinBSBingWallPaper主要功能: 1.支持自动下载Bing壁纸.Netbian壁纸.美国国家地理杂志图片. 2.自动搜索.下载多国Bing首页壁纸. 3.支持定时自动更换桌面壁纸. 4. ...
- 【POJ】2299 Ultra-QuickSort(逆序对)
http://poj.org/problem?id=2299 在两个元素相同的数列里,其中一个数列要移动到另一个数列相同元素相同的位置,那么要移动的次数就是这个数列关于另一个数列的逆序对数(hash后 ...
- BZOJ3238: [Ahoi2013]差异 (后缀自动机)
Description Input 一行,一个字符串S Output 一行,一个整数,表示所求值 Sample Input cacao Sample Output 54 HINT 2<=N< ...