ObjFW  Diff

Differences From Artifact [6c6cb9f3db]:

To Artifact [1933c9d596]:


178
179
180
181
182
183
184
185

186
187
188

189
190
191
192

193
194
195

196
197
198
199
200
201
202
203
204
205
206
207
208
209

210
211
212
213
214
215
216
217
178
179
180
181
182
183
184

185

186

187

188
189

190

191

192

193
194
195
196
197
198
199
200
201
202
203
204

205

206
207
208
209
210
211
212







-
+
-

-
+
-


-
+
-

-
+
-












-
+
-







#ifdef OF_NINTENDO_DS
	if (!nitroFSInit(NULL))
		@throw [OFInitializationFailedException
		    exceptionWithClass: self];
#endif
}

+ (instancetype)fileWithPath: (OFString *)path
+ (instancetype)fileWithPath: (OFString *)path mode: (OFString *)mode
			mode: (OFString *)mode
{
	return [[[self alloc] initWithPath: path
	return [[[self alloc] initWithPath: path mode: mode] autorelease];
				      mode: mode] autorelease];
}

+ (instancetype)fileWithURL: (OFURL *)URL
+ (instancetype)fileWithURL: (OFURL *)URL mode: (OFString *)mode
		       mode: (OFString *)mode
{
	return [[[self alloc] initWithURL: URL
	return [[[self alloc] initWithURL: URL mode: mode] autorelease];
				     mode: mode] autorelease];
}

+ (instancetype)fileWithHandle: (of_file_handle_t)handle
{
	return [[[self alloc] initWithHandle: handle] autorelease];
}

- (instancetype)init
{
	OF_INVALID_INIT_METHOD
}

- (instancetype)initWithPath: (OFString *)path
- (instancetype)initWithPath: (OFString *)path mode: (OFString *)mode
			mode: (OFString *)mode
{
	of_file_handle_t handle;

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

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
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







-
+
-











-
+
-







		closeHandle(handle);
		@throw e;
	}

	return self;
}

- (instancetype)initWithURL: (OFURL *)URL
- (instancetype)initWithURL: (OFURL *)URL mode: (OFString *)mode
		       mode: (OFString *)mode
{
	void *pool = objc_autoreleasePoolPush();
	OFString *fileSystemRepresentation;

	@try {
		fileSystemRepresentation = URL.fileSystemRepresentation;
	} @catch (id e) {
		[self release];
		@throw e;
	}

	self = [self initWithPath: fileSystemRepresentation
	self = [self initWithPath: fileSystemRepresentation mode: mode];
			     mode: mode];

	objc_autoreleasePoolPop(pool);

	return self;
}

- (instancetype)initWithHandle: (of_file_handle_t)handle
360
361
362
363
364
365
366
367

368
369
370
371
372
373
374
375
353
354
355
356
357
358
359

360

361
362
363
364
365
366
367







-
+
-







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

	return _atEndOfStream;
}

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

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

#if defined(OF_WINDOWS)
397
398
399
400
401
402
403
404

405
406
407
408
409
410
411
412
389
390
391
392
393
394
395

396

397
398
399
400
401
402
403







-
+
-








	if (ret == 0)
		_atEndOfStream = true;

	return ret;
}

- (size_t)lowlevelWriteBuffer: (const void *)buffer
- (size_t)lowlevelWriteBuffer: (const void *)buffer length: (size_t)length
		       length: (size_t)length
{
	if (_handle == OF_INVALID_FILE_HANDLE)
		@throw [OFNotOpenException exceptionWithObject: self];

#if defined(OF_WINDOWS)
	int bytesWritten;

456
457
458
459
460
461
462
463

464
465
466
467
468
469
470
471
447
448
449
450
451
452
453

454

455
456
457
458
459
460
461







-
+
-







						      bytesWritten: 0
							     errNo: errno];
#endif

	return (size_t)bytesWritten;
}

- (of_offset_t)lowlevelSeekToOffset: (of_offset_t)offset
- (of_offset_t)lowlevelSeekToOffset: (of_offset_t)offset whence: (int)whence
			     whence: (int)whence
{
	of_offset_t ret;

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

#ifndef OF_AMIGAOS