ObjFW  Diff

Differences From Artifact [58c24c0199]:

To Artifact [528afc5c1f]:


402
403
404
405
406
407
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
434
435
436
437
438
439
440
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
486
487
488
489
490
491
492

493
494
495
496
497
498


499
500
501
502
503
504
505
506
507
508
509
510
511

512
513
514
515
516
517


518
519
520
521
522
523
524
402
403
404
405
406
407
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
434
435
436
437
438
439
440
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







-
-
-
-
-
-
-
-
-













-




-
-

-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-

















-
-
-
-
-
-
-
-
-
-








-
-
+
-
-
-
-
-
-
+
+











-
-
+
-
-
-
-
-
-
+
+







	return mode;
}
@end

@implementation OFReadOrWriteFailedException
+ newWithClass: (Class)class__
	  size: (size_t)size
	 items: (size_t)items
{
	return [[self alloc] initWithClass: class__
				      size: size
				     items: items];
}

+ newWithClass: (Class)class__
	  size: (size_t)size
{
	return [[self alloc] initWithClass: class__
				      size: size];
}

- initWithClass: (Class)class__
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
}

- initWithClass: (Class)class__
	   size: (size_t)size
	  items: (size_t)items
{
	self = [super initWithClass: class__];

	req_size = size;
	req_items = items;
	has_items = YES;

	if (class__ == [OFTCPSocket class])
		err = GET_SOCK_ERR;
	else
		err = GET_ERR;

	/* FIXME: We need something that works for subclasses as well */
	return self;
}

- initWithClass: (Class)class__
	   size: (size_t)size
{
	self = [super initWithClass: class__];

	req_size = size;
	req_items = 0;
	has_items = NO;

	if (class__ == [OFTCPSocket class])
		err = GET_SOCK_ERR;
	else
		err = GET_ERR;

	return self;
}

- (int)errNo
{
	return err;
}

- (size_t)requestedSize
{
	return req_size;
}

- (size_t)requestedItems
{
	return req_items;
}

- (BOOL)hasNItems
{
	return has_items;
}
@end

@implementation OFReadFailedException
- (OFString*)string
{
	if (string != nil)
		return string;;

	if (has_items)
		string = [[OFString alloc] initWithFormat:
	string = [[OFString alloc] initWithFormat:
		    @"Failed to read %zu items of size %zu in class %s! "
		    ERRFMT, req_items, req_size, [class_ className], ERRPARAM];
	else
		string = [[OFString alloc] initWithFormat:
		    @"Failed to read %zu bytes in class %s! " ERRFMT, req_size,
		    [class_ className], ERRPARAM];
	    @"Failed to read %zu bytes in class %s! " ERRFMT, req_size,
	    [class_ className], ERRPARAM];

	return string;
}
@end

@implementation OFWriteFailedException
- (OFString*)string
{
	if (string != nil)
		return string;

	if (has_items)
		string = [[OFString alloc] initWithFormat:
	string = [[OFString alloc] initWithFormat:
		    @"Failed to write %zu items of size %zu in class %s! "
		    ERRFMT, req_items, req_size, [class_ className], ERRPARAM];
	else
		string = [[OFString alloc] initWithFormat:
		    @"Failed to write %zu bytes in class %s! " ERRFMT, req_size,
		    [class_ className], ERRPARAM];
	    @"Failed to write %zu bytes in class %s! " ERRFMT, req_size,
	    [class_ className], ERRPARAM];

	return string;
}
@end

@implementation OFChangeFileModeFailedException
+ newWithClass: (Class)class__