Skip to content
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
34 changes: 19 additions & 15 deletions CoreFoundation/Base.subproj/CFKnownLocations.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <CoreFoundation/CFString.h>
#include "CFPriv.h"
#include "CFInternal.h"
#include "CFUtilities.h"

#include <assert.h>

Expand Down Expand Up @@ -93,23 +94,26 @@ CFURLRef _Nullable _CFKnownLocationCreatePreferencesURLForUser(CFKnownLocationUs

#elif TARGET_OS_ANDROID

// Android doesn't support users, and apps cannot write outside their
// sandbox. All the preferences will be local to the application, mapping
// "any user" and other users by name to different directories inside the
// sandbox.
CFURLRef userdir = CFCopyHomeDirectoryURL();
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;
}
case _kCFKnownLocationUserAny:
location = CFURLCreateWithFileSystemPathRelativeToBase(kCFAllocatorSystemDefault, CFSTR("/Apple/Library/Preferences/AnyUser"), kCFURLPOSIXPathStyle, true, userdir);
break;
case _kCFKnownLocationUserByName: {
CFURLRef tmp = CFURLCreateWithFileSystemPathRelativeToBase(kCFAllocatorSystemDefault, CFSTR("/Apple/Library/Preferences/ByUser"), kCFURLPOSIXPathStyle, true, userdir);
location = CFURLCreateWithFileSystemPathRelativeToBase(kCFAllocatorSystemDefault, username, kCFURLPOSIXPathStyle, true, tmp);
CFRelease(tmp);
break;
}
case _kCFKnownLocationUserCurrent:
location = CFURLCreateWithFileSystemPathRelativeToBase(kCFAllocatorSystemDefault, CFSTR("/Apple/Library/Preferences"), kCFURLPOSIXPathStyle, true, userdir);
break;
}
CFRelease(userdir);

#else

Expand Down