//--------------------------------------------------------------------------␊ |
-(bool) savePreferences: (NSDictionary*) dict␊ |
{␊ |
␉std::string sPath = [kPreferencesFilePath UTF8String];␊ |
␉␊ |
␉if(dict==nil || sPath.length()==0) return false;␊ |
␉if(dict==nil) return false;␊ |
␉␊ |
␉AuthorizationRef auth = [self isUnlocked] ? [[authView authorization] authorizationRef] : NULL;␊ |
␉if (!auth) return false;␊ |
␉␊ |
␉PropertyList::chmodFile(sPath.c_str(), "0777", auth);␊ |
␉[dict writeToFile:kPreferencesFilePath atomically:YES];␊ |
␉PropertyList::chmodFile(sPath.c_str(), "0644", auth);␊ |
␉return true;␊ |
␉NSString* tmpPropName = @"/tmp/chamPrefPane.plist";␊ |
␉BOOL ret = [dict writeToFile:tmpPropName atomically:YES];␊ |
␉if (!ret) return false;␊ |
␉NSString* args = [NSString stringWithFormat:@"%@ %@", tmpPropName, kPreferencesFilePath];␊ |
␉const char * cArgs = [args UTF8String];␊ |
␉ret = executePrivilegedCmd(auth, "/bin/cp", cArgs , NULL);␊ |
␉return ret;␊ |
}␊ |
␊ |
//--------------------------------------------------------------------------␊ |