Created
November 17, 2012 21:05
-
-
Save heiberg/4100330 to your computer and use it in GitHub Desktop.
iOS "Do not backup"
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
// | |
// NSFileManager+DoNotBackUp.h | |
// | |
// Created by Morten Heiberg on 29/05/12. | |
// Copyright (c) 2012 Strange Loop. All rights reserved. | |
// | |
#import <Foundation/Foundation.h> | |
@interface NSFileManager (DoNotBackUp) | |
+ (void)addDoNotBackUpAttributeToPath:(NSString*)path; | |
+ (void)addDoNotBackUpAttributeToURL:(NSURL*)url; | |
@end |
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
// | |
// NSFileManager+DoNotBackUp.m | |
// | |
// Created by Morten Heiberg on 29/05/12. | |
// Copyright (c) 2012 Strange Loop. All rights reserved. | |
// | |
#import "NSFileManager+DoNotBackUp.h" | |
#include <sys/xattr.h> | |
@implementation NSFileManager (DoNotBackUp) | |
+ (void)addDoNotBackUpAttributeToPath:(NSString*)path | |
{ | |
u_int8_t b = 1; | |
setxattr([path fileSystemRepresentation], "com.apple.MobileBackup", &b, 1, 0, 0); | |
} | |
+ (void)addDoNotBackUpAttributeToURL:(NSURL*)url | |
{ | |
[NSFileManager addDoNotBackUpAttributeToPath:url.path]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment