mirror of https://github.com/oxen-io/session-ios
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
882 B
Matlab
34 lines
882 B
Matlab
8 years ago
|
//
|
||
|
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
|
||
|
//
|
||
|
|
||
|
#import "OWSFileSystem.h"
|
||
|
|
||
|
NS_ASSUME_NONNULL_BEGIN
|
||
|
|
||
|
@implementation OWSFileSystem
|
||
|
|
||
|
+ (void)protectFolderAtPath:(NSString *)path
|
||
|
{
|
||
|
if (![NSFileManager.defaultManager fileExistsAtPath:path]) {
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
NSError *error;
|
||
|
NSDictionary *fileProtection = @{ NSFileProtectionKey : NSFileProtectionCompleteUntilFirstUserAuthentication };
|
||
|
[[NSFileManager defaultManager] setAttributes:fileProtection ofItemAtPath:path error:&error];
|
||
|
|
||
|
NSDictionary *resourcesAttrs = @{ NSURLIsExcludedFromBackupKey : @YES };
|
||
|
|
||
|
NSURL *ressourceURL = [NSURL fileURLWithPath:path];
|
||
|
BOOL success = [ressourceURL setResourceValues:resourcesAttrs error:&error];
|
||
|
|
||
|
if (error || !success) {
|
||
|
OWSProdCritical([OWSAnalyticsEvents storageErrorFileProtection]);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@end
|
||
|
|
||
|
NS_ASSUME_NONNULL_END
|