-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch '3.1.1' of github.com:ChatSecure/ChatSecure-iOS into 3.1.1
- Loading branch information
Showing
8 changed files
with
129 additions
and
58 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// | ||
// NSFileManager+ChatSecure.h | ||
// ChatSecure | ||
// | ||
// Created by David Chiles on 5/19/15. | ||
// Copyright (c) 2015 Chris Ballinger. All rights reserved. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
@interface NSFileManager (ChatSecure) | ||
|
||
|
||
- (void)otr_enumerateFilesInDirectory:(NSString *)directory block:(void (^)(NSString *fullPath,BOOL *stop))enumerateBlock; | ||
- (BOOL)otr_setFileProtection:(NSString *)fileProtection forFilesInDirectory:(NSString *)directory; | ||
- (BOOL)otr_excudeFromBackUpFilesInDirectory:(NSString *)directory; | ||
|
||
@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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// | ||
// NSFileManager+ChatSecure.m | ||
// ChatSecure | ||
// | ||
// Created by David Chiles on 5/19/15. | ||
// Copyright (c) 2015 Chris Ballinger. All rights reserved. | ||
// | ||
|
||
#import "NSFileManager+ChatSecure.h" | ||
|
||
@implementation NSFileManager (ChatSecure) | ||
|
||
- (void)otr_enumerateFilesInDirectory:(NSString *)directory block:(void (^)(NSString *fullPath,BOOL *stop))enumerateBlock | ||
{ | ||
BOOL isDirecotry = NO; | ||
BOOL exists = [self fileExistsAtPath:directory isDirectory:&isDirecotry]; | ||
if (enumerateBlock && isDirecotry && exists) { | ||
NSDirectoryEnumerator *directoryEnumerator = [self enumeratorAtPath:directory]; | ||
NSString *file = nil; | ||
BOOL stop = NO; | ||
while ((file = [directoryEnumerator nextObject]) && !stop) { | ||
NSString *path = [NSString pathWithComponents:@[directory,file]]; | ||
enumerateBlock(path,&stop); | ||
} | ||
} | ||
} | ||
|
||
- (BOOL)otr_setFileProtection:(NSString *)fileProtection forFilesInDirectory:(NSString *)directory | ||
{ | ||
__block BOOL success = YES; | ||
[self otr_enumerateFilesInDirectory:directory block:^(NSString *fullPath, BOOL *stop) { | ||
success = [self setAttributes:@{NSFileProtectionKey:fileProtection} | ||
ofItemAtPath:fullPath error:nil]; | ||
*stop = !success; | ||
}]; | ||
return success; | ||
} | ||
|
||
- (BOOL)otr_excudeFromBackUpFilesInDirectory:(NSString *)directory | ||
{ | ||
__block BOOL success = YES; | ||
[self otr_enumerateFilesInDirectory:directory block:^(NSString *fullPath, BOOL *stop) { | ||
success = [self setAttributes:@{NSURLIsExcludedFromBackupKey:@(YES)} ofItemAtPath:fullPath error:nil]; | ||
*stop = !success; | ||
}]; | ||
return success; | ||
} | ||
|
||
@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
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
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
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
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