Skip to content

Commit 1c1a633

Browse files
authored
Merge pull request #2353 from compnerd/so-it-is-known
Base: implement KnownLocations for android
2 parents f2c4df9 + f8fdf60 commit 1c1a633

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

CoreFoundation/Base.subproj/CFKnownLocations.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,26 @@ CFURLRef _Nullable _CFKnownLocationCreatePreferencesURLForUser(CFKnownLocationUs
9191
break;
9292
}
9393

94+
#elif TARGET_OS_ANDROID
95+
96+
switch (user) {
97+
case _kCFKnownLocationUserAny:
98+
case _kCFKnownLocationUserByName:
99+
abort();
100+
case _kCFKnownLocationUserCurrent: {
101+
const char *buffer = getenv("CFFIXED_USER_HOME");
102+
if (buffer == NULL || *buffer = '\0') {
103+
CFLog(__kCFLogAssertion, CFSTR("CFFIXED_USER_HOME is unset"));
104+
HALT;
105+
}
106+
107+
CFURLRef userdir = CFURLCreateFromFileSystemRepresentation(kCFAllocatorSystemDefault, (const unsigned char *)buffer, strlen(buffer), true);
108+
location = CFURLCreateWithFileSystemPathRelativeToBase(kCFAllocatorSystemDefault, CFSTR("/Apple/Library/Preferences"), kCFURLPOSIXPathStyle, true, userdir);
109+
CFRelease(userdir);
110+
break;
111+
}
112+
}
113+
94114
#else
95115

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

0 commit comments

Comments
 (0)