zoukankan      html  css  js  c++  java
  • Sandbox 文件存放规则

    文档1, document2,  document3

    一、文件路径介绍

    <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 = 1;
            int result = setxattr(filePath, attrName, &attrValue, sizeof(attrValue), 0, 0);
            return (result == 0);
        }
        
        return YES;
    }

    三、统计文件夹的大小 

  • 相关阅读:
    实时27实战机器学习:图片验证码识别(Java实现)
    大屏26深度学习模型来从文档图片中自动化地提取出关键信息成为一项亟待解决的挑战
    f-string想必作为Python3.6版本开始引入的特性,通过它我们可以更加方便地向字符串中嵌入自定义内容
    大屏25JAVA+selenium+tess4j识别登陆验证码截图与识别
    前端12 highcharts和echarts选择
    大屏20基于 Selenium 的 Web 自动化测试框架完美版自动化解决方案 [开源项目]
    大屏24字典python+selenium的行为
    大屏23Tesseract字库训练Tesseract 3
    大屏21解决数据问题python-tesseract-ocr的安装及使用
    大屏22解决数据问题java浏览器源.docx
  • 原文地址:https://www.cnblogs.com/eileenleung/p/3504282.html
Copyright © 2011-2022 走看看