MCPcopy Create free account
hub / github.com/Tencent/MMKV / tryResetFileProtection

Function tryResetFileProtection

Core/MemoryFile_OSX.cpp:30–46  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

28namespace mmkv {
29
30void tryResetFileProtection(const string &path) {
31 @autoreleasepool {
32 NSString *nsPath = [NSString stringWithUTF8String:path.c_str()];
33 NSDictionary *attr = [[NSFileManager defaultManager] attributesOfItemAtPath:nsPath error:nullptr];
34 NSString *protection = [attr valueForKey:NSFileProtectionKey];
35 MMKVInfo("protection on [%@] is %@", nsPath, protection);
36 if ([protection isEqualToString:NSFileProtectionCompleteUntilFirstUserAuthentication] == NO) {
37 NSMutableDictionary *newAttr = [NSMutableDictionary dictionaryWithDictionary:attr];
38 [newAttr setObject:NSFileProtectionCompleteUntilFirstUserAuthentication forKey:NSFileProtectionKey];
39 NSError *err = nil;
40 [[NSFileManager defaultManager] setAttributes:newAttr ofItemAtPath:nsPath error:&err];
41 if (err != nil) {
42 MMKVError("fail to set attribute %@ on [%@]: %@", NSFileProtectionCompleteUntilFirstUserAuthentication,
43 nsPath, err);
44 }
45 }
46 }
47}
48
49} // namespace mmkv

Callers 1

reloadFromFileMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected