-
Notifications
You must be signed in to change notification settings - Fork 808
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Jb/issue 1613 #1668
Jb/issue 1613 #1668
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
what is this value and is it sufficient for all cases? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi, @bbowman .
I do not know why such value was chosen for Windows target. CFMaxPathSize definition used in many places of CoreFoundation. |
||
if (CFURLGetFileSystemRepresentation(url, true, (unsigned char *)cPath, CFMaxPathSize)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please make sure any and all changes to CoreFoundation are annotated with a // WINOBJC: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
will do, thank you There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
looking at the implementation for this, it appears that it can return false if the buffer is too small as well. Not a lot we can do here about that though. I think the MaxPath thing is fine for now but it does worry me a for very long names. |
||
success = _CFCreateDirectory(cPath); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Please make sure to run clang-format before submitting any code. In this case you have tabs that should be spaces. Coding conventions are a sticking point for a lot of people so we make it pretty easy to ensure the code is conformant (https://github.com/Microsoft/WinObjC/wiki/ClangFormat) for more info. EDIT: Just realized that core foundation turns off clang-format because we don't want to make unecessary churn from the ref platform. Can you just manually change your tabs to spaces? Thanks! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
sure, will do |
||
} | ||
|
||
CFRelease(completePath); | ||
} | ||
|
||
|
||
// Can't find a better place? Home directory then? | ||
if (url == NULL) | ||
if (!success) | ||
url = CFCopyHomeDirectoryURLForUser((userName == kCFPreferencesCurrentUser) ? NULL : userName); | ||
|
||
return url; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is this used for now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, @bbowman .
The changes I made are fix for the issue #1613 . In my last comment to the issue 1613 I mentioned that I found the solution, which I applied in "_preferencesDirectoryForUserHostSafetyLevel" in CFPreferences.c . But then I changed it to the implementation, which I submitted as PR, because I thought it was more relevant.