src/macosx/native/java/util/MacOSXPreferencesFile.m

Print this page

        

*** 639,649 **** if (name) CFRelease(name); } // child must end with '/' ! JNIEXPORT void JNICALL Java_java_util_prefs_MacOSXPreferencesFile_addChildToNode (JNIEnv *env, jobject klass, jobject jpath, jobject jchild, jobject jname, jlong juser, jlong jhost) { // like addNode, but can put a three-level-deep dict into the root file --- 639,649 ---- if (name) CFRelease(name); } // child must end with '/' ! JNIEXPORT Boolean JNICALL Java_java_util_prefs_MacOSXPreferencesFile_addChildToNode (JNIEnv *env, jobject klass, jobject jpath, jobject jchild, jobject jname, jlong juser, jlong jhost) { // like addNode, but can put a three-level-deep dict into the root file
*** 654,675 **** CFStringRef host = (CFStringRef)jlong_to_ptr(jhost); CFMutableDictionaryRef parent; CFDictionaryRef node; CFStringRef topKey; CFMutableDictionaryRef topValue; if (!path || !child || !name) goto badparams; node = createEmptyNode(); throwIfNull(node, "createEmptyNode failed"); // copyMutableNode creates the node if necessary parent = copyMutableNode(path, name, user, host, &topKey, &topValue); throwIfNull(parent, "copyMutableNode failed"); ! CFDictionaryAddValue(parent, child, node); ! CFPreferencesSetValue(topKey, topValue, name, user, host); CFRelease(parent); if (topKey) CFRelease(topKey); if (topValue) CFRelease(topValue); --- 654,679 ---- CFStringRef host = (CFStringRef)jlong_to_ptr(jhost); CFMutableDictionaryRef parent; CFDictionaryRef node; CFStringRef topKey; CFMutableDictionaryRef topValue; + Boolean beforeAdd = false; if (!path || !child || !name) goto badparams; node = createEmptyNode(); throwIfNull(node, "createEmptyNode failed"); // copyMutableNode creates the node if necessary parent = copyMutableNode(path, name, user, host, &topKey, &topValue); throwIfNull(parent, "copyMutableNode failed"); ! beforeAdd = CFDictionaryContainsKey(parent, child); CFDictionaryAddValue(parent, child, node); ! if (!beforeAdd) ! beforeAdd = CFDictionaryContainsKey(parent, child); ! else ! beforeAdd = false; CFPreferencesSetValue(topKey, topValue, name, user, host); CFRelease(parent); if (topKey) CFRelease(topKey); if (topValue) CFRelease(topValue);
*** 678,687 **** --- 682,692 ---- badnode: badparams: if (path) CFRelease(path); if (child) CFRelease(child); if (name) CFRelease(name); + return beforeAdd; } JNIEXPORT void JNICALL Java_java_util_prefs_MacOSXPreferencesFile_removeChildFromNode