You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by he...@apache.org on 2012/06/27 20:33:51 UTC
[19/20] ios commit: Enhanced CB-471 - LocalFileSystem.PERSISTENT "do
not back up" file attribute iOS. Supports new iOS 5.1 iCloud Backup attribute
(the old way is deprecated, and only for iOS 5.0.1)
Enhanced CB-471 - LocalFileSystem.PERSISTENT "do not back up" file attribute iOS. Supports new iOS 5.1 iCloud Backup attribute (the old way is deprecated, and only for iOS 5.0.1)
Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/commit/3088a0c6
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/tree/3088a0c6
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/diff/3088a0c6
Branch: refs/heads/master
Commit: 3088a0c6b168ad8af21fe42cb939bce3cfc12eb7
Parents: 43f7892
Author: Shazron Abdullah <sh...@apache.org>
Authored: Wed Jun 20 11:25:23 2012 -0700
Committer: hermwong <he...@gmail.com>
Committed: Wed Jun 27 11:32:07 2012 -0700
----------------------------------------------------------------------
CordovaLib/Classes/CDVFile.m | 26 ++++++++++++++++++--------
1 files changed, 18 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/3088a0c6/CordovaLib/Classes/CDVFile.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVFile.m b/CordovaLib/Classes/CDVFile.m
index 76d3d8a..7730cfc 100644
--- a/CordovaLib/Classes/CDVFile.m
+++ b/CordovaLib/Classes/CDVFile.m
@@ -23,6 +23,7 @@
#import "JSONKit.h"
#import "NSData+Base64.h"
#import <MobileCoreServices/MobileCoreServices.h>
+#import "CDVAvailability.h"
#import "sys/xattr.h"
@implementation CDVFile
@@ -529,14 +530,23 @@
NSString* iCloudBackupExtendedAttributeKey = @"com.apple.MobileBackup";
id iCloudBackupExtendedAttributeValue = [options objectForKey:iCloudBackupExtendedAttributeKey];
- if (iCloudBackupExtendedAttributeValue != nil &&
- [iCloudBackupExtendedAttributeValue isKindOfClass:[NSNumber class]]) {
-
- u_int8_t value = [iCloudBackupExtendedAttributeValue intValue];
- if (value == 0) { // remove the attribute (allow backup, the default)
- ok = (removexattr([filePath fileSystemRepresentation], [iCloudBackupExtendedAttributeKey cStringUsingEncoding:NSUTF8StringEncoding], 0) == 0);
- } else { // set the attribute (skip backup)
- ok = (setxattr([filePath fileSystemRepresentation], [iCloudBackupExtendedAttributeKey cStringUsingEncoding:NSUTF8StringEncoding], &value, sizeof(value), 0, 0) == 0);
+ if (iCloudBackupExtendedAttributeValue != nil && [iCloudBackupExtendedAttributeValue isKindOfClass:[NSNumber class]])
+ {
+ if (IsAtLeastiOSVersion(@"5.1"))
+ {
+ NSURL* url = [NSURL fileURLWithPath:filePath];
+ NSError* error = nil;
+
+ ok = [url setResourceValue: [NSNumber numberWithBool: [iCloudBackupExtendedAttributeValue boolValue]] forKey: NSURLIsExcludedFromBackupKey error:&error];
+ }
+ else // below 5.1 (deprecated - only really supported in 5.01)
+ {
+ u_int8_t value = [iCloudBackupExtendedAttributeValue intValue];
+ if (value == 0) { // remove the attribute (allow backup, the default)
+ ok = (removexattr([filePath fileSystemRepresentation], [iCloudBackupExtendedAttributeKey cStringUsingEncoding:NSUTF8StringEncoding], 0) == 0);
+ } else { // set the attribute (skip backup)
+ ok = (setxattr([filePath fileSystemRepresentation], [iCloudBackupExtendedAttributeKey cStringUsingEncoding:NSUTF8StringEncoding], &value, sizeof(value), 0, 0) == 0);
+ }
}
}