ObjFW  Check-in [b16fc262c0]

Overview
Comment:Use more native AmigaOS APIs on AmigaOS 3
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: b16fc262c08fb554f7446e77f623295aa1351e004972ba3bb7039ac7041a0a97
User & Date: js on 2018-04-23 22:19:10
Other Links: manifest | tags
Context
2018-04-24
00:06
Fix compilation for PSP check-in: ae0899ef7c user: js tags: trunk
2018-04-23
22:19
Use more native AmigaOS APIs on AmigaOS 3 check-in: b16fc262c0 user: js tags: trunk
2018-04-22
23:42
Make all tests pass on AmigaOS 3 check-in: 49cb6ada5f user: js tags: trunk
Changes

Modified src/OFFile.h from [1301722443] to [0217984244].

14
15
16
17
18
19
20
21

22
23
24
25
26
27
28
29
30
31
32
33
14
15
16
17
18
19
20

21
22
23
24
25

26
27
28
29
30
31
32







-
+




-







 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#import "OFSeekableStream.h"
#import "OFKernelEventObserver.h"

#ifndef OF_MORPHOS
#ifndef OF_AMIGAOS
# define OF_FILE_HANDLE_IS_FD
# define OF_INVALID_FILE_HANDLE (-1)
typedef int of_file_handle_t;
#else
# include <proto/dos.h>
# define OF_INVALID_FILE_HANDLE NULL
typedef struct of_file_handle *of_file_handle_t;
#endif

OF_ASSUME_NONNULL_BEGIN

@class OFURL;

Modified src/OFFile.m from [77e3c3a21e] to [8331bd9e6b].

52
53
54
55
56
57
58







59
60
61
62
63
64
65
66
67
68
69
70
71
72
73

74
75
76
77
78
79
80
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79

80
81
82
83
84
85
86
87







+
+
+
+
+
+
+














-
+







# include <fat.h>
#endif

#ifdef OF_NINTENDO_DS
# include <stdbool.h>
# include <filesystem.h>
#endif

#ifdef OF_AMIGAOS
# ifdef OF_AMIGAOS3
#  define INTUITION_CLASSES_H
# endif
# include <proto/dos.h>
#endif

#ifndef O_BINARY
# define O_BINARY 0
#endif
#ifndef O_CLOEXEC
# define O_CLOEXEC 0
#endif
#ifndef O_EXCL
# define O_EXCL 0
#endif
#ifndef O_EXLOCK
# define O_EXLOCK 0
#endif

#ifndef OF_MORPHOS
#ifndef OF_AMIGAOS
# define closeHandle(h) close(h)
#else
struct of_file_handle {
	of_file_handle_t previous, next;
	BPTR handle;
	bool append;
} *firstHandle = NULL;
99
100
101
102
103
104
105
106

107
108
109
110
111
112
113
106
107
108
109
110
111
112

113
114
115
116
117
118
119
120







-
+







{
	for (of_file_handle_t iter = firstHandle; iter != NULL;
	    iter = iter->next)
		Close(iter->handle);
}
#endif

#ifndef OF_MORPHOS
#ifndef OF_AMIGAOS
static int
parseMode(const char *mode)
{
	if (strcmp(mode, "r") == 0)
		return O_RDONLY;
	if (strcmp(mode, "r+") == 0)
		return O_RDWR;
205
206
207
208
209
210
211
212

213
214
215
216
217
218
219
212
213
214
215
216
217
218

219
220
221
222
223
224
225
226







-
+







{
	of_file_handle_t handle;

	@try {
		void *pool = objc_autoreleasePoolPush();
		int flags;

#ifndef OF_MORPHOS
#ifndef OF_AMIGAOS
		if ((flags = parseMode([mode UTF8String])) == -1)
			@throw [OFInvalidArgumentException exception];

		flags |= O_BINARY | O_CLOEXEC;

# if defined(OF_WINDOWS)
		if ((handle = _wopen([path UTF16String], flags,
266
267
268
269
270
271
272

273
274



275
276
277
278
279
280
281
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292







+


+
+
+







				@throw [OFOpenItemFailedException
				    exceptionWithPath: path
						 mode: mode
						errNo: errNo];
			}

			if (handle->append) {
# ifdef OF_MORPHOS
				if (Seek64(handle->handle, 0,
				    OFFSET_END) == -1) {
# else
				if (Seek(handle->handle, 0, OFFSET_END) == -1) {
# endif
					Close(handle->handle);
					@throw [OFOpenItemFailedException
					    exceptionWithPath: path
							 mode: mode
							errNo: EIO];
				}
			}
359
360
361
362
363
364
365
366

367
368
369
370
371
372
373
370
371
372
373
374
375
376

377
378
379
380
381
382
383
384







-
+







	if (length > UINT_MAX)
		@throw [OFOutOfRangeException exception];

	if ((ret = read(_handle, buffer, (unsigned int)length)) < 0)
		@throw [OFReadFailedException exceptionWithObject: self
						  requestedLength: length
							    errNo: errno];
#elif defined(OF_MORPHOS)
#elif defined(OF_AMIGAOS)
	if (length > LONG_MAX)
		@throw [OFOutOfRangeException exception];

	if ((ret = Read(_handle->handle, buffer, length)) < 0)
		@throw [OFReadFailedException exceptionWithObject: self
						  requestedLength: length
							    errNo: EIO];
397
398
399
400
401
402
403
404

405
406
407
408
409
410

411



412
413
414
415
416
417
418
408
409
410
411
412
413
414

415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433







-
+






+

+
+
+







		@throw [OFOutOfRangeException exception];

	if ((bytesWritten = write(_handle, buffer, (int)length)) < 0)
		@throw [OFWriteFailedException exceptionWithObject: self
						   requestedLength: length
						      bytesWritten: 0
							     errNo: errno];
#elif defined(OF_MORPHOS)
#elif defined(OF_AMIGAOS)
	LONG bytesWritten;

	if (length > LONG_MAX)
		@throw [OFOutOfRangeException exception];

	if (_handle->append) {
# ifdef OF_MORPHOS
		if (Seek64(_handle->handle, 0, OFFSET_END) == -1)
# else
		if (Seek(_handle->handle, 0, OFFSET_END) == -1)
# endif
			@throw [OFWriteFailedException
			    exceptionWithObject: self
				requestedLength: length
				   bytesWritten: 0
					  errNo: EIO];
	}

441
442
443
444
445
446
447
448

449
450
451
452
453
454
455
456
457
458
459
460
461
462


463
464
465

466
467
468

469
470
471

472
473

474
475



476
477




478

479
480
481
482
483
484
485
456
457
458
459
460
461
462

463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481

482
483
484

485
486
487

488
489
490
491


492
493
494
495
496
497
498
499
500

501
502
503
504
505
506
507
508







-
+














+
+


-
+


-
+


-
+


+
-
-
+
+
+


+
+
+
+
-
+







			     whence: (int)whence
{
	of_offset_t ret;

	if (_handle == OF_INVALID_FILE_HANDLE)
		@throw [OFNotOpenException exceptionWithObject: self];

#ifndef OF_MORPHOS
#ifndef OF_AMIGAOS
# if defined(OF_WINDOWS)
	ret = _lseeki64(_handle, offset, whence);
# elif defined(OF_HAVE_OFF64_T)
	ret = lseek64(_handle, offset, whence);
# else
	ret = lseek(_handle, offset, whence);
# endif

	if (ret == -1)
		@throw [OFSeekFailedException exceptionWithStream: self
							   offset: offset
							   whence: whence
							    errNo: errno];
#else
	LONG translatedWhence;

	switch (whence) {
	case SEEK_SET:
		ret = Seek64(_handle->handle, offset, OFFSET_BEGINNING);
		translatedWhence = OFFSET_BEGINNING;
		break;
	case SEEK_CUR:
		ret = Seek64(_handle->handle, offset, OFFSET_CURRENT);
		translatedWhence = OFFSET_CURRENT;
		break;
	case SEEK_END:
		ret = Seek64(_handle->handle, offset, OFFSET_END);
		translatedWhence = OFFSET_END;
		break;
	default:
		@throw [OFSeekFailedException exceptionWithStream: self
		ret = -1;
		break;
							   offset: offset
							   whence: whence
							    errNo: EINVAL];
	}

# ifdef OF_MORPHOS
	if ((ret = Seek64(_handle->handle, offset, translatedWhence)) == 1)
# else
	if ((ret = Seek(_handle->handle, offset, translatedWhence)) == 1)
	if (ret == -1)
# endif
		@throw [OFSeekFailedException exceptionWithStream: self
							   offset: offset
							   whence: whence
							    errNo: EINVAL];
#endif

	_atEndOfStream = false;

Modified src/OFFileManager.h from [723dd40210] to [e4831219a2].

19
20
21
22
23
24
25
26

27
28
29

30
31
32

33
34
35

36
37
38
39
40
41
42
19
20
21
22
23
24
25

26
27
28

29
30
31

32
33
34

35
36
37
38
39
40
41
42







-
+


-
+


-
+


-
+







#import "OFDictionary.h"
#import "OFSeekableStream.h"

OF_ASSUME_NONNULL_BEGIN

/*! @file */

#if defined(OF_HAVE_CHMOD) && !defined(OF_MORPHOS)
#if defined(OF_HAVE_CHMOD) && !defined(OF_AMIGAOS)
# define OF_FILE_MANAGER_SUPPORTS_PERMISSIONS
#endif
#if defined(OF_HAVE_CHOWN) && !defined(OF_MORPHOS)
#if defined(OF_HAVE_CHOWN) && !defined(OF_AMIGAOS)
# define OF_FILE_MANAGER_SUPPORTS_OWNER
#endif
#if (defined(OF_HAVE_LINK) && !defined(OF_MORPHOS)) || defined(OF_WINDOWS)
#if (defined(OF_HAVE_LINK) && !defined(OF_AMIGAOS)) || defined(OF_WINDOWS)
# define OF_FILE_MANAGER_SUPPORTS_LINKS
#endif
#if (defined(OF_HAVE_SYMLINK) && !defined(OF_MORPHOS)) || defined(OF_WINDOWS)
#if (defined(OF_HAVE_SYMLINK) && !defined(OF_AMIGAOS)) || defined(OF_WINDOWS)
# define OF_FILE_MANAGER_SUPPORTS_SYMLINKS
#endif

@class OFArray OF_GENERIC(ObjectType);
@class OFDate;
@class OFURL;

Modified src/OFFileManager.m from [96795739ab] to [6bf29cf1ec].

52
53
54
55
56
57
58
59





60
61
62
63
64
65
66
52
53
54
55
56
57
58

59
60
61
62
63
64
65
66
67
68
69
70







-
+
+
+
+
+








#ifdef OF_WINDOWS
# include <windows.h>
# include <direct.h>
# include <ntdef.h>
#endif

#ifdef OF_MORPHOS
#ifdef OF_AMIGAOS
# ifdef OF_AMIGAOS3
#  define INTUITION_CLASSES_H
# endif
# include <proto/exec.h>
# include <proto/dos.h>
# include <proto/locale.h>
#endif

@interface OFFileManager_default: OFFileManager
@end

94
95
96
97
98
99
100
101

102
103
104
105
106
107
108
98
99
100
101
102
103
104

105
106
107
108
109
110
111
112







-
+







const of_file_type_t of_file_type_symbolic_link = @"of_file_type_symbolic_link";
const of_file_type_t of_file_type_fifo = @"of_file_type_fifo";
const of_file_type_t of_file_type_character_special =
    @"of_file_type_character_special";
const of_file_type_t of_file_type_block_special = @"of_file_type_block_special";
const of_file_type_t of_file_type_socket = @"of_file_type_socket";

#ifdef OF_MORPHOS
#ifdef OF_AMIGAOS
static bool dirChanged = false;
static BPTR originalDirLock = 0;

OF_DESTRUCTOR()
{
	if (dirChanged)
		UnLock(CurrentDir(originalDirLock));
145
146
147
148
149
150
151
152

153
154
155
156
157
158
159
149
150
151
152
153
154
155

156
157
158
159
160
161
162
163







-
+







	@try {
		ret = [OFString stringWithUTF16String: buffer];
	} @finally {
		free(buffer);
	}

	return ret;
#elif defined(OF_MORPHOS)
#elif defined(OF_AMIGAOS)
	char buffer[512];

	if (!NameFromLock(((struct Process *)FindTask(NULL))->pr_CurrentDir,
	    buffer, 512)) {
		if (IoErr() == ERROR_LINE_TOO_LONG)
			@throw [OFOutOfRangeException exception];

400
401
402
403
404
405
406
407

408
409
410
411
412
413
414
404
405
406
407
408
409
410

411
412
413
414
415
416
417
418







-
+







		@throw [OFInvalidArgumentException exception];

#if defined(OF_WINDOWS)
	if (_wchdir([path UTF16String]) != 0)
		@throw [OFChangeCurrentDirectoryPathFailedException
		    exceptionWithPath: path
				errNo: errno];
#elif defined(OF_MORPHOS)
#elif defined(OF_AMIGAOS)
	BPTR lock, oldLock;

	if ((lock = Lock([path cStringWithEncoding: [OFLocalization encoding]],
	    SHARED_LOCK)) == 0) {
		int errNo;

		switch (IoErr()) {

Modified src/OFLocalization.m from [72ae978ca9] to [16040a43d0].

222
223
224
225
226
227
228
229

230
231

232


233
234
235
236
237
238
239
222
223
224
225
226
227
228

229
230

231
232
233
234
235
236
237
238
239
240
241







-
+

-
+

+
+








		/*
		 * Returns an empty string on MorphOS + libnix, but still
		 * applies it so that printf etc. work as expected.
		 */
		setlocale(LC_ALL, "");

# ifdef OF_MORPHOS
# if defined(OF_MORPHOS)
		if (GetVar("CODEPAGE", buffer, sizeof(buffer), 0) > 0) {
# else
# elif defined(OF_AMIGAOS4)
		if (GetVar("Charset", buffer, sizeof(buffer), 0) > 0) {
# else
		if (0) {
# endif
			of_string_encoding_t ASCII = OF_STRING_ENCODING_ASCII;

			@try {
				_encoding = of_string_parse_encoding(
				    [OFString stringWithCString: buffer
						       encoding: ASCII]);

Modified src/OFStdIOStream+Private.h from [636bb040e5] to [048a7a1142].

16
17
18
19
20
21
22
23

24
25
26
27
28
29
30
31
16
17
18
19
20
21
22

23
24
25
26
27
28
29
30
31







-
+








 */

#import "OFStdIOStream.h"

OF_ASSUME_NONNULL_BEGIN

@interface OFStdIOStream ()
#ifndef OF_MORPHOS
#ifndef OF_AMIGAOS
- (instancetype)of_initWithFileDescriptor: (int)fd OF_METHOD_FAMILY(init);
#else
- (instancetype)of_initWithHandle: (BPTR)handle
			 closable: (bool)closable OF_METHOD_FAMILY(init);
#endif
@end

OF_ASSUME_NONNULL_END

Modified src/OFStdIOStream.h from [230fa44006] to [25b6014eaa].

14
15
16
17
18
19
20
21




22



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39

40
41
42
43

44
45
46
47
48
49
50
14
15
16
17
18
19
20

21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44

45
46
47
48

49
50
51
52
53
54
55
56







-
+
+
+
+

+
+
+
















-
+



-
+







 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#import "OFStream.h"
#import "OFKernelEventObserver.h"

#ifdef OF_MORPHOS
#ifdef OF_AMIGAOS
# ifdef OF_AMIGAOS3
#  define INTUITION_CLASSES_H
# endif
# include <proto/dos.h>
# ifdef OF_AMIGAOS3
#  undef INTUITION_CLASSES_H
# endif
#endif

OF_ASSUME_NONNULL_BEGIN

/*!
 * @class OFStdIOStream OFStdIOStream.h ObjFW/OFStdIOStream.h
 *
 * @brief A class for providing standard input, output and error as OFStream.
 *
 * The global variables @ref of_stdin, @ref of_stdout and @ref of_stderr are
 * instances of this class and need no initialization.
 */
#ifdef OF_STDIO_STREAM_WIN32_CONSOLE_H
OF_SUBCLASSING_RESTRICTED
#endif
@interface OFStdIOStream: OFStream
#if !defined(OF_WINDOWS) && !defined(OF_MORPHOS)
#if !defined(OF_WINDOWS) && !defined(OF_AMIGAOS)
    <OFReadyForReadingObserving, OFReadyForWritingObserving>
#endif
{
#ifndef OF_MORPHOS
#ifndef OF_AMIGAOS
	int _fd;
#else
	BPTR _handle;
	bool _closable;
#endif
	bool _atEndOfStream;
}

Modified src/OFStdIOStream.m from [7f1468fef3] to [6647a44cbe].

37
38
39
40
41
42
43
44




45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61

62
63
64
65
66
67
68
37
38
39
40
41
42
43

44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63

64
65
66
67
68
69
70
71







-
+
+
+
+
















-
+







#endif

#import "OFNotOpenException.h"
#import "OFOutOfRangeException.h"
#import "OFReadFailedException.h"
#import "OFWriteFailedException.h"

#ifdef OF_MORPHOS
#ifdef OF_AMIGAOS
# ifdef OF_AMIGAOS3
#  define INTUITION_CLASSES_H
# endif
# include <proto/exec.h>
#endif

/* References for static linking */
#ifdef OF_WINDOWS
void
_reference_to_OFStdIOStream_Win32Console(void)
{
	[OFStdIOStream_Win32Console class];
}
#endif

OFStdIOStream *of_stdin = nil;
OFStdIOStream *of_stdout = nil;
OFStdIOStream *of_stderr = nil;

#ifdef OF_MORPHOS
#ifdef OF_AMIGAOS
OF_DESTRUCTOR()
{
	[of_stdin dealloc];
	[of_stdout dealloc];
	[of_stderr dealloc];
}
#endif
94
95
96
97
98
99
100
101

102
103
104
105
106
107
108
97
98
99
100
101
102
103

104
105
106
107
108
109
110
111







-
+







	objc_autoreleasePoolPop(pool);
}

@implementation OFStdIOStream
#ifndef OF_WINDOWS
+ (void)load
{
# ifndef OF_MORPHOS
# ifndef OF_AMIGAOS
	of_stdin = [[OFStdIOStream alloc] of_initWithFileDescriptor: 0];
	of_stdout = [[OFStdIOStream alloc] of_initWithFileDescriptor: 1];
	of_stderr = [[OFStdIOStream alloc] of_initWithFileDescriptor: 2];
# else
	BPTR input = Input(), output = Output();
	BPTR error = ((struct Process *)FindTask(NULL))->pr_CES;
	bool inputClosable = false, outputClosable = false,
134
135
136
137
138
139
140
141

142
143
144
145
146
147
148
137
138
139
140
141
142
143

144
145
146
147
148
149
150
151







-
+







#endif

- (instancetype)init
{
	OF_INVALID_INIT_METHOD
}

#ifndef OF_MORPHOS
#ifndef OF_AMIGAOS
- (instancetype)of_initWithFileDescriptor: (int)fd
{
	self = [super init];

	_fd = fd;

	return self;
165
166
167
168
169
170
171
172

173
174
175
176
177
178
179
180
181
182
183
184
185
186
187

188
189
190
191
192
193
194
168
169
170
171
172
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







-
+














-
+







	[self close];

	[super dealloc];
}

- (bool)lowlevelIsAtEndOfStream
{
#ifndef OF_MORPHOS
#ifndef OF_AMIGAOS
	if (_fd == -1)
#else
	if (_handle == 0)
#endif
		@throw [OFNotOpenException exceptionWithObject: self];

	return _atEndOfStream;
}

- (size_t)lowlevelReadIntoBuffer: (void *)buffer
			  length: (size_t)length
{
	ssize_t ret;

#ifndef OF_MORPHOS
#ifndef OF_AMIGAOS
	if (_fd == -1)
		@throw [OFNotOpenException exceptionWithObject: self];

# ifndef OF_WINDOWS
	if ((ret = read(_fd, buffer, length)) < 0)
		@throw [OFReadFailedException exceptionWithObject: self
						  requestedLength: length
220
221
222
223
224
225
226
227

228
229
230
231
232
233
234
223
224
225
226
227
228
229

230
231
232
233
234
235
236
237







-
+








	return ret;
}

- (size_t)lowlevelWriteBuffer: (const void *)buffer
		       length: (size_t)length
{
#ifndef OF_MORPHOS
#ifndef OF_AMIGAOS
	if (_fd == -1)
		@throw [OFNotOpenException exceptionWithObject: self];

# ifndef OF_WINDOWS
	ssize_t bytesWritten;

	if (length > SSIZE_MAX)
266
267
268
269
270
271
272
273

274
275
276
277
278
279
280
281
282
283
284
285
286
287

288
289
290
291
292
293
294
269
270
271
272
273
274
275

276
277
278
279
280
281
282
283
284
285
286
287
288
289

290
291
292
293
294
295
296
297







-
+













-
+







						      bytesWritten: 0
							     errNo: EIO];
#endif

	return (size_t)bytesWritten;
}

#if !defined(OF_WINDOWS) && !defined(OF_MORPHOS)
#if !defined(OF_WINDOWS) && !defined(OF_AMIGAOS)
- (int)fileDescriptorForReading
{
	return _fd;
}

- (int)fileDescriptorForWriting
{
	return _fd;
}
#endif

- (void)close
{
#ifndef OF_MORPHOS
#ifndef OF_AMIGAOS
	if (_fd != -1)
		close(_fd);

	_fd = -1;
#else
	if (_closable && _handle != 0)
		Close(_handle);
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
343
344
345
346
347
348
319
320
321
322
323
324
325

326
327
328
329
330
331
332
333
334
335
336
337
338
339

340
341
342
343
344
345
346
347
348
349
350
351







-
+













-
+











- (unsigned int)retainCount
{
	return OF_RETAIN_COUNT_MAX;
}

- (int)columns
{
#if defined(HAVE_SYS_IOCTL_H) && defined(TIOCGWINSZ) && !defined(OF_MORPHOS)
#if defined(HAVE_SYS_IOCTL_H) && defined(TIOCGWINSZ) && !defined(OF_AMIGAOS)
	struct winsize ws;

	if (ioctl(_fd, TIOCGWINSZ, &ws) != 0)
		return -1;

	return ws.ws_col;
#else
	return -1;
#endif
}

- (int)rows
{
#if defined(HAVE_SYS_IOCTL_H) && defined(TIOCGWINSZ) && !defined(OF_MORPHOS)
#if defined(HAVE_SYS_IOCTL_H) && defined(TIOCGWINSZ) && !defined(OF_AMIGAOS)
	struct winsize ws;

	if (ioctl(_fd, TIOCGWINSZ, &ws) != 0)
		return -1;

	return ws.ws_row;
#else
	return -1;
#endif
}
@end

Modified src/OFSystemInfo.m from [a6ae61b1e9] to [dad22dd462].

212
213
214
215
216
217
218


219
220
221
222
223
224
225
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227







+
+







	}
# endif
#elif defined(OF_ANDROID)
	/* TODO */
#elif defined(OF_MORPHOS)
	/* TODO */
#elif defined(OF_AMIGAOS4)
	/* TODO */
#elif defined(OF_AMIGAOS3)
	/* TODO */
#elif defined(OF_WII) || defined(NINTENDO_3DS) || defined(OF_NINTENDO_DS) || \
    defined(OF_PSP) || defined(OF_MSDOS)
	/* Intentionally nothing */
#elif defined(HAVE_SYS_UTSNAME_H) && defined(HAVE_UNAME)
	struct utsname utsname;

Modified src/OFThread.m from [6fbe74a9ed] to [19b90357c1].

28
29
30
31
32
33
34
35




36
37
38
39
40
41
42
28
29
30
31
32
33
34

35
36
37
38
39
40
41
42
43
44
45







-
+
+
+
+







#ifdef OF_HAVE_SCHED_YIELD
# include <sched.h>
#endif
#include "unistd_wrapper.h"

#include "platform.h"

#ifdef OF_MORPHOS
#ifdef OF_AMIGAOS
# ifdef OF_AMIGAOS3
#  define INTUITION_CLASSES_H
# endif
# include <proto/dos.h>
#endif

#ifdef OF_WII
# define nanosleep ogc_nanosleep
# include <ogcsys.h>
# undef nanosleep
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
83
84
85
86
87
88
89



90
91
92
93
94
95
96







-
-
-







#ifdef OF_HAVE_ATOMIC_OPS
# import "atomic.h"
#endif

#ifdef OF_DJGPP
# define lrint(x) rint(x)
#endif
#ifdef OF_AMIGAOS3
# define lrint(x) ((long)x)
#endif

#ifdef OF_HAVE_THREADS
# import "threading.h"

static of_tlskey_t threadSelfKey;
static OFThread *mainThread;

204
205
206
207
208
209
210
211

212
213
214
215
216
217
218
204
205
206
207
208
209
210

211
212
213
214
215
216
217
218







-
+







	rqtp.tv_sec = (time_t)timeInterval;
	rqtp.tv_nsec = lrint((timeInterval - rqtp.tv_sec) * 1000000000);

	if (rqtp.tv_sec != floor(timeInterval))
		@throw [OFOutOfRangeException exception];

	nanosleep(&rqtp, NULL);
#elif defined(OF_MORPHOS)
#elif defined(OF_AMIGAOS)
	if (timeInterval * 50 > ULONG_MAX)
		@throw [OFOutOfRangeException exception];

	Delay(timeInterval * 50);
#elif defined(OF_NINTENDO_DS)
	uint64_t counter;

Modified src/OFURLHandler_file.m from [398809665b] to [08b70171c7].

62
63
64
65
66
67
68
69




70
71
72
73
74
75
76

77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92

93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108

109
110
111
112
113
114
115
62
63
64
65
66
67
68

69
70
71
72
73
74
75
76
77
78

79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94

95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110

111
112
113
114
115
116
117
118







-
+
+
+
+






-
+















-
+















-
+








#ifdef OF_WINDOWS
# include <windows.h>
# include <direct.h>
# include <ntdef.h>
#endif

#ifdef OF_MORPHOS
#ifdef OF_AMIGAOS
# ifdef OF_AMIGAOS3
#  define INTUITION_CLASSES_H
# endif
# include <proto/dos.h>
# include <proto/locale.h>
#endif

#if defined(OF_WINDOWS)
typedef struct __stat64 of_stat_t;
#elif defined(OF_MORPHOS)
#elif defined(OF_AMIGAOS)
typedef struct {
	of_offset_t st_size;
	mode_t st_mode;
	of_time_interval_t st_atime, st_mtime, st_ctime;
} of_stat_t;
#elif defined(OF_HAVE_OFF64_T)
typedef struct stat64 of_stat_t;
#else
typedef struct stat of_stat_t;
#endif

#ifndef S_ISLNK
# define S_ISLNK(s) 0
#endif

#if defined(OF_HAVE_CHOWN) && defined(OF_HAVE_THREADS) && !defined(OF_MORPHOS)
#if defined(OF_HAVE_CHOWN) && defined(OF_HAVE_THREADS) && !defined(OF_AMIGAOS)
static OFMutex *passwdMutex;
#endif
#if !defined(HAVE_READDIR_R) && defined(OF_HAVE_THREADS) && !defined(OF_WINDOWS)
static OFMutex *readdirMutex;
#endif

#ifdef OF_WINDOWS
static WINAPI BOOLEAN (*func_CreateSymbolicLinkW)(LPCWSTR, LPCWSTR, DWORD);
#endif

static int
of_stat(OFString *path, of_stat_t *buffer)
{
#if defined(OF_WINDOWS)
	return _wstat64([path UTF16String], buffer);
#elif defined(OF_MORPHOS)
#elif defined(OF_AMIGAOS)
	BPTR lock;
	struct FileInfoBlock fib;
	of_time_interval_t timeInterval;
	struct Locale *locale;

	if ((lock = Lock([path cStringWithEncoding: [OFLocalization encoding]],
	    SHARED_LOCK)) == 0) {
125
126
127
128
129
130
131

132



133
134
135
136
137
138
139
140

141



142
143
144
145
146
147
148
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159







+

+
+
+








+

+
+
+







			errno = 0;
			break;
		}

		return -1;
	}

# ifdef OF_MORPHOS
	if (!Examine64(lock, &fib, TAG_DONE)) {
# else
	if (!Examine(lock, &fib)) {
# endif
		UnLock(lock);

		errno = 0;
		return -1;
	}

	UnLock(lock);

# ifdef OF_MORPHOS
	buffer->st_size = fib.fib_Size64;
# else
	buffer->st_size = fib.fib_Size;
# endif
	buffer->st_mode = (fib.fib_DirEntryType > 0 ? S_IFDIR : S_IFREG);

	timeInterval = 252460800;	/* 1978-01-01 */

	locale = OpenLocale(NULL);
	/*
	 * FIXME: This does not take DST into account. But unfortunately, there
168
169
170
171
172
173
174
175

176
177
178
179
180
181
182
179
180
181
182
183
184
185

186
187
188
189
190
191
192
193







-
+







	    buffer);
#endif
}

static int
of_lstat(OFString *path, of_stat_t *buffer)
{
#if defined(HAVE_LSTAT) && !defined(OF_WINDOWS) && !defined(OF_MORPHOS)
#if defined(HAVE_LSTAT) && !defined(OF_WINDOWS) && !defined(OF_AMIGAOS)
# ifdef OF_HAVE_OFF64_T
	return lstat64([path cStringWithEncoding: [OFLocalization encoding]],
	    buffer);
# else
	return lstat([path cStringWithEncoding: [OFLocalization encoding]],
	    buffer);
# endif
656
657
658
659
660
661
662
663

664
665
666
667
668
669
670
667
668
669
670
671
672
673

674
675
676
677
678
679
680
681







-
+







	path = [URL fileSystemRepresentation];

#if defined(OF_WINDOWS)
	if (_wmkdir([path UTF16String]) != 0)
		@throw [OFCreateDirectoryFailedException
		    exceptionWithURL: URL
			       errNo: errno];
#elif defined(OF_MORPHOS)
#elif defined(OF_AMIGAOS)
	BPTR lock;

	if ((lock = CreateDir(
	    [path cStringWithEncoding: [OFLocalization encoding]])) == 0) {
		int errNo;

		switch (IoErr()) {
758
759
760
761
762
763
764
765

766
767
768
769
770
771
772
769
770
771
772
773
774
775

776
777
778
779
780
781
782
783







-
+







		if (GetLastError() != ERROR_NO_MORE_FILES)
			@throw [OFReadFailedException exceptionWithObject: self
							  requestedLength: 0
								    errNo: EIO];
	} @finally {
		FindClose(handle);
	}
#elif defined(OF_MORPHOS)
#elif defined(OF_AMIGAOS)
	of_string_encoding_t encoding = [OFLocalization encoding];
	BPTR lock;
	struct FileInfoBlock fib;

	if ((lock = Lock([path cStringWithEncoding: encoding],
	    SHARED_LOCK)) == 0) {
		int errNo;
936
937
938
939
940
941
942
943

944
945
946
947
948
949
950
947
948
949
950
951
952
953

954
955
956
957
958
959
960
961







-
+








			[self removeItemAtURL: [OFURL fileURLWithPath:
			    [path stringByAppendingPathComponent: item]]];

			objc_autoreleasePoolPop(pool2);
		}

#ifndef OF_MORPHOS
#ifndef OF_AMIGAOS
# ifndef OF_WINDOWS
		if (rmdir([path cStringWithEncoding:
		    [OFLocalization encoding]]) != 0)
# else
		if (_wrmdir([path UTF16String]) != 0)
# endif
			@throw [OFRemoveItemFailedException
959
960
961
962
963
964
965
966

967
968
969
970
971
972
973
970
971
972
973
974
975
976

977
978
979
980
981
982
983
984







-
+







# endif
			@throw [OFRemoveItemFailedException
			    exceptionWithURL: URL
				       errNo: errno];
#endif
	}

#ifdef OF_MORPHOS
#ifdef OF_AMIGAOS
	if (!DeleteFile(
	    [path cStringWithEncoding: [OFLocalization encoding]])) {
		int errNo;

		switch (IoErr()) {
		case ERROR_OBJECT_IN_USE:
		case ERROR_DISK_NOT_VALIDATED:
1095
1096
1097
1098
1099
1100
1101
1102

1103
1104
1105
1106
1107
1108
1109
1106
1107
1108
1109
1110
1111
1112

1113
1114
1115
1116
1117
1118
1119
1120







-
+







#if defined(OF_WINDOWS)
	if (_wrename([[source fileSystemRepresentation] UTF16String],
	    [[destination fileSystemRepresentation] UTF16String]) != 0)
		@throw [OFMoveItemFailedException
		    exceptionWithSourceURL: source
			    destinationURL: destination
				     errNo: errno];
#elif defined(OF_MORPHOS)
#elif defined(OF_AMIGAOS)
	of_string_encoding_t encoding = [OFLocalization encoding];

	if (!Rename([[source fileSystemRepresentation]
	    cStringWithEncoding: encoding],
	    [[destination fileSystemRepresentation]
	    cStringWithEncoding: encoding]) != 0) {
		int errNo;

Modified utils/ofhash/OFHash.m from [f021cb30da] to [58c7926b8d].

88
89
90
91
92
93
94
95

96
97
98
99
100
101
102
88
89
90
91
92
93
94

95
96
97
98
99
100
101
102







-
+








		[OFApplication activateSandbox: sandbox];
	} @finally {
		[sandbox release];
	}
#endif

#ifndef OF_MORPHOS
#ifndef OF_AMIGAOS
	[OFLocalization addLanguageDirectory: @LANGUAGE_DIR];
#else
	[OFLocalization addLanguageDirectory: @"PROGDIR:/share/ofhash/lang"];
#endif

	if ([arguments count] < 2)
		help();

Modified utils/ofhttp/OFHTTP.m from [de7a31ac42] to [e2bb21d82f].

392
393
394
395
396
397
398
399

400
401
402
403
404
405
406
392
393
394
395
396
397
398

399
400
401
402
403
404
405
406







-
+








		[OFApplication activateSandbox: sandbox];
	} @finally {
		[sandbox release];
	}
#endif

#ifndef OF_MORPHOS
#ifndef OF_AMIGAOS
	[OFLocalization addLanguageDirectory: @LANGUAGE_DIR];
#else
	[OFLocalization addLanguageDirectory: @"PROGDIR:/share/ofhttp/lang"];
#endif

	optionsParser = [OFOptionsParser parserWithOptions: options];
	while ((option = [optionsParser nextOption]) != '\0') {

Modified utils/ofzip/OFZIP.m from [8e70d5c643] to [288d6fb85f].

179
180
181
182
183
184
185
186

187
188
189
190
191
192
193
179
180
181
182
183
184
185

186
187
188
189
190
191
192
193







-
+








		[OFApplication activateSandbox: sandbox];
	} @finally {
		[sandbox release];
	}
#endif

#ifndef OF_MORPHOS
#ifndef OF_AMIGAOS
	[OFLocalization addLanguageDirectory: @LANGUAGE_DIR];
#else
	[OFLocalization addLanguageDirectory: @"PROGDIR:/share/ofzip/lang"];
#endif

	optionsParser = [OFOptionsParser parserWithOptions: options];
	while ((option = [optionsParser nextOption]) != '\0') {