split Apple stuff in seperate file

This commit is contained in:
guoling
2019-12-27 17:08:00 +08:00
parent 791fdb8d47
commit 953b720e37
18 changed files with 587 additions and 340 deletions
-21
View File
@@ -299,27 +299,6 @@ int getPageSize() {
return getpagesize();
}
# ifdef MMKV_IOS
void tryResetFileProtection(const string &path) {
@autoreleasepool {
NSString *nsPath = [NSString stringWithUTF8String:path.c_str()];
NSDictionary *attr = [[NSFileManager defaultManager] attributesOfItemAtPath:nsPath error:nullptr];
NSString *protection = [attr valueForKey:NSFileProtectionKey];
MMKVInfo("protection on [%@] is %@", nsPath, protection);
if ([protection isEqualToString:NSFileProtectionCompleteUntilFirstUserAuthentication] == NO) {
NSMutableDictionary *newAttr = [NSMutableDictionary dictionaryWithDictionary:attr];
[newAttr setObject:NSFileProtectionCompleteUntilFirstUserAuthentication forKey:NSFileProtectionKey];
NSError *err = nil;
[[NSFileManager defaultManager] setAttributes:newAttr ofItemAtPath:nsPath error:&err];
if (err != nil) {
MMKVError("fail to set attribute %@ on [%@]: %@", NSFileProtectionCompleteUntilFirstUserAuthentication,
nsPath, err);
}
}
}
}
# endif
} // namespace mmkv
#endif // MMKV_WIN32