Skip to content

Instantly share code, notes, and snippets.

@heiberg
Created November 17, 2012 21:05
Show Gist options
  • Save heiberg/4100330 to your computer and use it in GitHub Desktop.
Save heiberg/4100330 to your computer and use it in GitHub Desktop.
iOS "Do not backup"
//
// 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
//
// 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