Skip to content

Commit 939e2f6

Browse files
committed
[Windows, CoreFoundation] Construct Preferences Using Known Locations
The current Windows implementation doesn't properly handle kCFPreferencesAnyUsers, which causes it point to the same location as kCFPreferencesCurrentUser which causes preferences to be loaded incorrectly. Instead, we should defer to CFKnownLocations as the non Windows implementation already does
1 parent 05cb315 commit 939e2f6

File tree

1 file changed

+0
-26
lines changed

1 file changed

+0
-26
lines changed

CoreFoundation/Preferences.subproj/CFPreferences.c

-26
Original file line numberDiff line numberDiff line change
@@ -169,33 +169,8 @@ CF_PRIVATE CFStringRef _CFPreferencesGetByHostIdentifierString(void) {
169169

170170
static unsigned long __CFSafeLaunchLevel = 0;
171171

172-
#if TARGET_OS_WIN32
173-
#include <ShlObj.h>
174-
175-
#endif
176-
177172
static CFURLRef _preferencesDirectoryForUserHostSafetyLevel(CFStringRef userName, CFStringRef hostName, unsigned long safeLevel) {
178173
CFAllocatorRef alloc = __CFPreferencesAllocator();
179-
#if TARGET_OS_WIN32
180-
181-
CFURLRef url = NULL;
182-
183-
CFMutableStringRef completePath = _CFCreateApplicationRepositoryPath(alloc, CSIDL_APPDATA);
184-
if (completePath) {
185-
// append "Preferences\" and make the CFURL
186-
CFStringAppend(completePath, CFSTR("Preferences\\"));
187-
url = CFURLCreateWithFileSystemPath(alloc, completePath, kCFURLWindowsPathStyle, true);
188-
CFRelease(completePath);
189-
}
190-
191-
192-
// Can't find a better place? Home directory then?
193-
if (url == NULL)
194-
url = CFCopyHomeDirectoryURLForUser((userName == kCFPreferencesCurrentUser) ? NULL : userName);
195-
196-
return url;
197-
198-
#else
199174
CFURLRef location = NULL;
200175

201176
CFKnownLocationUser user;
@@ -219,7 +194,6 @@ static CFURLRef _preferencesDirectoryForUserHostSafetyLevel(CFStringRef userName
219194

220195
CFRelease(base);
221196
return location;
222-
#endif
223197
}
224198

225199
static CFURLRef _preferencesDirectoryForUserHost(CFStringRef userName, CFStringRef hostName) {

0 commit comments

Comments
 (0)