Skip to content

Base: implement KnownLocations for android #2353

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

Merged
merged 1 commit into from
Jun 19, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions CoreFoundation/Base.subproj/CFKnownLocations.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,26 @@ CFURLRef _Nullable _CFKnownLocationCreatePreferencesURLForUser(CFKnownLocationUs
break;
}

#elif TARGET_OS_ANDROID

switch (user) {
case _kCFKnownLocationUserAny:
case _kCFKnownLocationUserByName:
abort();
case _kCFKnownLocationUserCurrent: {
const char *buffer = getenv("CFFIXED_USER_HOME");
if (buffer == NULL || *buffer = '\0') {
CFLog(__kCFLogAssertion, CFSTR("CFFIXED_USER_HOME is unset"));
HALT;
}

CFURLRef userdir = CFURLCreateFromFileSystemRepresentation(kCFAllocatorSystemDefault, (const unsigned char *)buffer, strlen(buffer), true);
location = CFURLCreateWithFileSystemPathRelativeToBase(kCFAllocatorSystemDefault, CFSTR("/Apple/Library/Preferences"), kCFURLPOSIXPathStyle, true, userdir);
CFRelease(userdir);
break;
}
}

#else

#error For this platform, you need to define a preferences path for both 'any user' (i.e. installation-wide preferences) or the current user.
Expand Down