Skip to content

Commit

Permalink
Jb/issue 1613 (#1668)
Browse files Browse the repository at this point in the history
fixed issue that  CPathMapper() receives null as path when trying to get data from NSUserDefaults
#1613
changed manual convertion of mutable string to charactes into using of  native representation of url's path
  • Loading branch information
jboich authored and bbowman committed Jan 18, 2017
1 parent e3df20d commit 7c86e9a
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions Frameworks/CoreFoundation/Preferences.subproj/CFPreferences.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,19 +182,24 @@ static CFURLRef _preferencesDirectoryForUserHostSafetyLevel(CFStringRef userName
#if DEPLOYMENT_TARGET_WINDOWS

CFURLRef url = NULL;
Boolean success = false;

CFMutableStringRef completePath = _CFCreateApplicationRepositoryPath(alloc, CSIDL_APPDATA);
if (completePath) {
// append "Preferences\" and make the CFURL
CFStringAppend(completePath, CFSTR("Preferences\\"));
url = CFURLCreateWithFileSystemPath(alloc, completePath, kCFURLWindowsPathStyle, true);
_CFCreateDirectory(CFStringGetCStringPtr(completePath, kCFStringEncodingUTF8)); // WINOBJC: ensure directory exists

char cPath[CFMaxPathSize];
if (CFURLGetFileSystemRepresentation(url, true, (unsigned char *)cPath, CFMaxPathSize)) {
success = _CFCreateDirectory(cPath);
}

CFRelease(completePath);
}


// Can't find a better place? Home directory then?
if (url == NULL)
if (!success)
url = CFCopyHomeDirectoryURLForUser((userName == kCFPreferencesCurrentUser) ? NULL : userName);

return url;
Expand Down

0 comments on commit 7c86e9a

Please sign in to comment.