ObjFW  Check-in [4a5eb1c281]

Overview
Comment:OFSystemInfo: Implement finding dirs for iOS 10
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 4a5eb1c28124b4f16fde95560b668c4966a18c06a8318c2ea1149976a2bb78c8
User & Date: js on 2016-10-09 02:17:10
Other Links: manifest | tags
Context
2016-10-09
16:04
Add three missing #include <inttypes.h> check-in: 1b90782e78 user: js tags: trunk
02:17
OFSystemInfo: Implement finding dirs for iOS 10 check-in: 4a5eb1c281 user: js tags: trunk
01:34
Remove textual headers from ObjFW_Bridge check-in: f6ac3febf3 user: js tags: trunk
Changes

Modified src/OFSystemInfo.m from [35e9a4decf] to [7a2395920f].

36
37
38
39
40
41
42
43

44
45
46
47
48
49
50
36
37
38
39
40
41
42

43
44
45
46
47
48
49
50







-
+







#import "OFString.h"
#import "OFArray.h"
#import "OFDictionary.h"
#import "OFApplication.h"

#import "OFNotImplementedException.h"

#if defined(OF_MAC_OS_X)
#if defined(OF_MAC_OS_X) || defined(OF_IOS)
# ifdef HAVE_SYSDIR_H
#  include <sysdir.h>
# else
#  include <NSSystemDirectories.h>
# endif
#endif
#ifdef OF_WINDOWS
147
148
149
150
151
152
153
154
155

156
157
158
159
160
161
162
147
148
149
150
151
152
153


154
155
156
157
158
159
160
161







-
-
+







{
	/* FIXME */
	return OF_STRING_ENCODING_UTF_8;
}

+ (OFString*)userDataPath
{
	/* TODO: Return something more sensible for iOS */
#if defined(OF_MAC_OS_X)
#if defined(OF_MAC_OS_X) || defined(OF_IOS)
	void *pool = objc_autoreleasePoolPush();
	char pathC[PATH_MAX];
	OFMutableString *path;
	OFString *home;

# ifdef HAVE_SYSDIR_START_SEARCH_PATH_ENUMERATION
	sysdir_search_path_enumeration_state state;
211
212
213
214
215
216
217
218

219
220
221
222
223
224
225
210
211
212
213
214
215
216

217
218
219
220
221
222
223
224







-
+








	if (find_directory(B_USER_SETTINGS_DIRECTORY, 0, false,
	    pathC, PATH_MAX) != B_OK)
		@throw [OFNotImplementedException exceptionWithSelector: _cmd
								 object: self];

	return [OFString stringWithUTF8String: pathC];
#else
#elif !defined(OF_IOS)
	void *pool = objc_autoreleasePoolPush();
	OFDictionary *env = [OFApplication environment];
	OFString *var;

	if ((var = [env objectForKey: @"XDG_DATA_HOME"]) != nil &&
	    [var length] > 0) {
		[var retain];
233
234
235
236
237
238
239



240
241
242
243
244
245
246

247
248
249
250
251
252
253
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246


247
248
249
250
251
252
253
254







+
+
+





-
-
+








	var = [OFString pathWithComponents: [OFArray arrayWithObjects:
	    var, @".local", @"share", nil]];

	[var retain];
	objc_autoreleasePoolPop(pool);
	return [var autorelease];
#else
	@throw [OFNotImplementedException exceptionWithSelector: _cmd
							 object: self];
#endif
}

+ (OFString*)userConfigPath
{
	/* TODO: Return something more sensible for iOS */
#if defined(OF_MAC_OS_X)
#if defined(OF_MAC_OS_X) || defined(OF_IOS)
	void *pool = objc_autoreleasePoolPush();
	char pathC[PATH_MAX];
	OFMutableString *path;
	OFString *home;

# ifdef HAVE_SYSDIR_START_SEARCH_PATH_ENUMERATION
	sysdir_search_path_enumeration_state state;
304
305
306
307
308
309
310
311

312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331



332
333
334
335
336
337
338
305
306
307
308
309
310
311

312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342







-
+




















+
+
+








	if (find_directory(B_USER_SETTINGS_DIRECTORY, 0, false,
	    pathC, PATH_MAX) != B_OK)
		@throw [OFNotImplementedException exceptionWithSelector: _cmd
								 object: self];

	return [OFString stringWithUTF8String: pathC];
#else
#elif !defined(OF_IOS)
	void *pool = objc_autoreleasePoolPush();
	OFDictionary *env = [OFApplication environment];
	OFString *var;

	if ((var = [env objectForKey: @"XDG_CONFIG_HOME"]) != nil &&
	    [var length] > 0) {
		[var retain];
		objc_autoreleasePoolPop(pool);
		return [var autorelease];
	}

	if ((var = [env objectForKey: @"HOME"]) == nil)
		@throw [OFNotImplementedException exceptionWithSelector: _cmd
								 object: self];

	var = [var stringByAppendingPathComponent: @".config"];

	[var retain];
	objc_autoreleasePoolPop(pool);
	return [var autorelease];
#else
	@throw [OFNotImplementedException OFNotImplementedException: _cmd
							     object: self];
#endif
}

+ (OFString*)CPUVendor
{
#if defined(OF_X86_64_ASM) || defined(OF_X86_ASM)
	struct x86_regs regs = x86_cpuid(0, 0);