ObjFW  Diff

Differences From Artifact [df1cd50578]:

To Artifact [016d812c99]:


30
31
32
33
34
35
36
37

38
39
40

41
42
43

44
45
46

47
48
49
50
51
52
53
30
31
32
33
34
35
36

37
38
39

40
41
42

43
44
45

46
47
48
49
50
51
52
53







-
+


-
+


-
+


-
+







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

#import "OFNotImplementedException.h"

#if defined(__APPLE__) && !defined(OF_IOS)
#if defined(OF_MAC_OS_X)
# include <NSSystemDirectories.h>
#endif
#ifdef _WIN32
#ifdef OF_WINDOWS
# include <windows.h>
#endif
#ifdef __HAIKU__
#ifdef OF_HAIKU
# include <FindDirectory.h>
#endif
#ifdef __QNX__
#ifdef OF_QNX
# include <sys/syspage.h>
#endif

#if defined(OF_X86_64_ASM) || defined(OF_X86_ASM)
struct x86_regs {
	uint32_t eax, ebx, ecx, edx;
};
97
98
99
100
101
102
103
104

105
106
107
108
109

110
111
112
113
114
115
116
97
98
99
100
101
102
103

104
105
106
107
108

109
110
111
112
113
114
115
116







-
+




-
+








@implementation OFSystemInfo
+ (void)initialize
{
	if (self != [OFSystemInfo class])
		return;

#if defined(_WIN32)
#if defined(OF_WINDOWS)
	SYSTEM_INFO si;
	GetSystemInfo(&si);
	pageSize = si.dwPageSize;
	numberOfCPUs = si.dwNumberOfProcessors;
#elif defined(__QNX__)
#elif defined(OF_QNX)
	if ((pageSize = sysconf(_SC_PAGESIZE)) < 1)
		pageSize = 4096;
	numberOfCPUs = _syspage_ptr->num_cpu;
#else
# if defined(HAVE_SYSCONF) && defined(_SC_PAGESIZE)
	if ((pageSize = sysconf(_SC_PAGESIZE)) < 1)
# endif
142
143
144
145
146
147
148
149

150
151
152
153
154
155
156
142
143
144
145
146
147
148

149
150
151
152
153
154
155
156







-
+







	/* FIXME */
	return OF_STRING_ENCODING_UTF_8;
}

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

	state = NSStartSearchPathEnumeration(NSApplicationSupportDirectory,
173
174
175
176
177
178
179
180

181
182
183
184
185
186
187
188
189
190
191
192

193
194
195
196
197
198
199
173
174
175
176
177
178
179

180
181
182
183
184
185
186
187
188
189
190
191

192
193
194
195
196
197
198
199







-
+











-
+







	}

	[path makeImmutable];

	[path retain];
	objc_autoreleasePoolPop(pool);
	return [path autorelease];
#elif defined(_WIN32)
#elif defined(OF_WINDOWS)
	void *pool = objc_autoreleasePoolPush();
	OFDictionary *env = [OFApplication environment];
	OFString *appData;

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

	[appData retain];
	objc_autoreleasePoolPop(pool);
	return [appData autorelease];
#elif defined(__HAIKU__)
#elif defined(OF_HAIKU)
	char pathC[PATH_MAX];

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

222
223
224
225
226
227
228
229

230
231
232
233
234
235
236
222
223
224
225
226
227
228

229
230
231
232
233
234
235
236







-
+







	return [var autorelease];
#endif
}

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

	state = NSStartSearchPathEnumeration(NSLibraryDirectory,
255
256
257
258
259
260
261
262

263
264
265
266
267
268
269
270
271
272
273
274

275
276
277
278
279
280
281
255
256
257
258
259
260
261

262
263
264
265
266
267
268
269
270
271
272
273

274
275
276
277
278
279
280
281







-
+











-
+







	[path appendString: @"/Preferences"];

	[path makeImmutable];

	[path retain];
	objc_autoreleasePoolPop(pool);
	return [path autorelease];
#elif defined(_WIN32)
#elif defined(OF_WINDOWS)
	void *pool = objc_autoreleasePoolPush();
	OFDictionary *env = [OFApplication environment];
	OFString *appData;

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

	[appData retain];
	objc_autoreleasePoolPop(pool);
	return [appData autorelease];
#elif defined(__HAIKU__)
#elif defined(OF_HAIKU)
	char pathC[PATH_MAX];

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