ObjFW  Diff

Differences From Artifact [b2e536c6d0]:

To Artifact [35e9a4decf]:


37
38
39
40
41
42
43



44

45
46
47
48
49
50
51
#import "OFArray.h"
#import "OFDictionary.h"
#import "OFApplication.h"

#import "OFNotImplementedException.h"

#if defined(OF_MAC_OS_X)



# include <NSSystemDirectories.h>

#endif
#ifdef OF_WINDOWS
# include <windows.h>
#endif
#ifdef OF_HAIKU
# include <FindDirectory.h>
#endif







>
>
>
|
>







37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#import "OFArray.h"
#import "OFDictionary.h"
#import "OFApplication.h"

#import "OFNotImplementedException.h"

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











157
158
159
160
161
162

163
164
165
166
167
168
169

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












	state = NSStartSearchPathEnumeration(NSApplicationSupportDirectory,
	    NSUserDomainMask);
	if (NSGetNextSearchPathEnumeration(state, pathC) == 0)
		@throw [OFNotImplementedException exceptionWithSelector: _cmd
								 object: self];


	path = [OFMutableString stringWithUTF8String: pathC];
	if ([path hasPrefix: @"~"]) {
		OFDictionary *env = [OFApplication environment];

		if ((home = [env objectForKey: @"HOME"]) == nil)
			@throw [OFNotImplementedException







<


>
>
>
>
>
>
>
>
>
>
>






>







151
152
153
154
155
156
157

158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184

+ (OFString*)userDataPath
{
	/* TODO: Return something more sensible for iOS */
#if defined(OF_MAC_OS_X)
	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;

	state = sysdir_start_search_path_enumeration(
	    SYSDIR_DIRECTORY_APPLICATION_SUPPORT, SYSDIR_DOMAIN_MASK_USER);
	if (sysdir_get_next_search_path_enumeration(state, pathC) == 0)
		@throw [OFNotImplementedException exceptionWithSelector: _cmd
								 object: self];
# else
	NSSearchPathEnumerationState state;

	state = NSStartSearchPathEnumeration(NSApplicationSupportDirectory,
	    NSUserDomainMask);
	if (NSGetNextSearchPathEnumeration(state, pathC) == 0)
		@throw [OFNotImplementedException exceptionWithSelector: _cmd
								 object: self];
# endif

	path = [OFMutableString stringWithUTF8String: pathC];
	if ([path hasPrefix: @"~"]) {
		OFDictionary *env = [OFApplication environment];

		if ((home = [env objectForKey: @"HOME"]) == nil)
			@throw [OFNotImplementedException
227
228
229
230
231
232
233
234
235
236











237
238
239
240
241
242

243
244
245
246
247
248
249

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












	state = NSStartSearchPathEnumeration(NSLibraryDirectory,
	    NSUserDomainMask);
	if (NSGetNextSearchPathEnumeration(state, pathC) == 0)
		@throw [OFNotImplementedException exceptionWithSelector: _cmd
								 object: self];


	path = [OFMutableString stringWithUTF8String: pathC];
	if ([path hasPrefix: @"~"]) {
		OFDictionary *env = [OFApplication environment];

		if ((home = [env objectForKey: @"HOME"]) == nil)
			@throw [OFNotImplementedException







<


>
>
>
>
>
>
>
>
>
>
>






>







242
243
244
245
246
247
248

249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275

+ (OFString*)userConfigPath
{
	/* TODO: Return something more sensible for iOS */
#if defined(OF_MAC_OS_X)
	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;

	state = sysdir_start_search_path_enumeration(
	    SYSDIR_DIRECTORY_LIBRARY, SYSDIR_DOMAIN_MASK_USER);
	if (sysdir_get_next_search_path_enumeration(state, pathC) == 0)
		@throw [OFNotImplementedException exceptionWithSelector: _cmd
								 object: self];
# else
	NSSearchPathEnumerationState state;

	state = NSStartSearchPathEnumeration(NSLibraryDirectory,
	    NSUserDomainMask);
	if (NSGetNextSearchPathEnumeration(state, pathC) == 0)
		@throw [OFNotImplementedException exceptionWithSelector: _cmd
								 object: self];
# endif

	path = [OFMutableString stringWithUTF8String: pathC];
	if ([path hasPrefix: @"~"]) {
		OFDictionary *env = [OFApplication environment];

		if ((home = [env objectForKey: @"HOME"]) == nil)
			@throw [OFNotImplementedException