Last active
April 3, 2016 17:10
-
-
Save hansemannn/676a9c7ca35c2f29212d19bddd4a135a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-(NSNumber*)remoteBackup | |
{ | |
NSURL *URL= [NSURL fileURLWithPath: [self path]]; | |
NSError *error; | |
NSNumber *result = nil; | |
BOOL success = [URL getResourceValue:&result | |
forKey:NSURLIsExcludedFromBackupKey error:&error]; | |
if (!success) { | |
// Doesn't matter what error is set to; this means that we're backing up. | |
return NUMBOOL(YES); | |
} | |
// A value of 0 means backup, so: | |
return NUMBOOL([result isEqualToNumber:@YES] ? NO : YES); | |
} | |
-(void)setRemoteBackup:(id)remoteBackup | |
{ | |
ENSURE_TYPE(remoteBackup, NSNumber); | |
BOOL isExcluced = ![TiUtils boolValue:remoteBackup def:YES]; | |
NSURL *URL= [NSURL fileURLWithPath: [self path]]; | |
NSError *error; | |
BOOL success = [URL setResourceValue: NUMBOOL(isExcluced) | |
forKey: NSURLIsExcludedFromBackupKey error: &error]; | |
if (!success) { | |
[self throwException:@"Error setting remote backup flag:" | |
subreason:[error localizedDescription] | |
location:CODELOCATION]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment