mirror of
https://github.com/oxen-io/session-ios.git
synced 2023-12-13 21:30:14 +01:00
34 lines
882 B
Mathematica
34 lines
882 B
Mathematica
|
//
|
||
|
// 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
|