ObjFW  Diff

Differences From Artifact [7ba6b6f15a]:

To Artifact [0b00f53cf5]:


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
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
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
119
120
121
#import "OFChangeFileOwnerFailedException.h"
#import "OFString.h"

#import "common.h"

#ifndef _WIN32
@implementation OFChangeFileOwnerFailedException
+ (instancetype)exceptionWithClass: (Class)class_
			      path: (OFString*)path
			     owner: (OFString*)owner
			     group: (OFString*)group
{
	return [[[self alloc] initWithClass: class_
				       path: path
				      owner: owner
				      group: group] autorelease];
}

- initWithClass: (Class)class_
{
	@try {
		[self doesNotRecognizeSelector: _cmd];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	abort();
}

- initWithClass: (Class)class_
	   path: (OFString*)path_
	  owner: (OFString*)owner_
	  group: (OFString*)group_
{
	self = [super initWithClass: class_];

	@try {
		path  = [path_ copy];
		owner = [owner_ copy];
		group = [group_ copy];
		errNo = GET_ERRNO;
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}

- (void)dealloc
{
	[path release];
	[owner release];
	[group release];

	[super dealloc];
}

- (OFString*)description
{
	if (description != nil)
		return description;

	if (group == nil)
		description = [[OFString alloc] initWithFormat:
		    @"Failed to change owner for file %@ to %@ in class %@! "
		    ERRFMT, path, owner, inClass, ERRPARAM];
	else if (owner == nil)
		description = [[OFString alloc] initWithFormat:
		    @"Failed to change group for file %@ to %@ in class %@! "
		    ERRFMT, path, group, inClass, ERRPARAM];
	else
		description = [[OFString alloc] initWithFormat:
		    @"Failed to change owner for file %@ to %@:%@ in class %@! "
		    ERRFMT, path, owner, group, inClass, ERRPARAM];

	return description;
}

- (int)errNo
{
	return errNo;
}

- (OFString*)path
{
	OF_GETTER(path, NO)
}

- (OFString*)owner
{
	OF_GETTER(owner, NO)
}

- (OFString*)group
{
	OF_GETTER(group, NO)
}
@end
#endif







|




|





|











|
|
|
|

|


|
|
|
|










|
|
|






|
|

|
|

|
|
|

|

|

|

|




|




|




|




|



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
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
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
119
120
121
#import "OFChangeFileOwnerFailedException.h"
#import "OFString.h"

#import "common.h"

#ifndef _WIN32
@implementation OFChangeFileOwnerFailedException
+ (instancetype)exceptionWithClass: (Class)class
			      path: (OFString*)path
			     owner: (OFString*)owner
			     group: (OFString*)group
{
	return [[[self alloc] initWithClass: class
				       path: path
				      owner: owner
				      group: group] autorelease];
}

- initWithClass: (Class)class
{
	@try {
		[self doesNotRecognizeSelector: _cmd];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	abort();
}

- initWithClass: (Class)class
	   path: (OFString*)path
	  owner: (OFString*)owner
	  group: (OFString*)group
{
	self = [super initWithClass: class];

	@try {
		_path  = [path copy];
		_owner = [owner copy];
		_group = [group copy];
		_errNo = GET_ERRNO;
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}

- (void)dealloc
{
	[_path release];
	[_owner release];
	[_group release];

	[super dealloc];
}

- (OFString*)description
{
	if (_description != nil)
		return _description;

	if (_group == nil)
		_description = [[OFString alloc] initWithFormat:
		    @"Failed to change owner for file %@ to %@ in class %@! "
		    ERRFMT, _path, _owner, _inClass, ERRPARAM];
	else if (_owner == nil)
		_description = [[OFString alloc] initWithFormat:
		    @"Failed to change group for file %@ to %@ in class %@! "
		    ERRFMT, _path, _group, _inClass, ERRPARAM];
	else
		_description = [[OFString alloc] initWithFormat:
		    @"Failed to change owner for file %@ to %@:%@ in class %@! "
		    ERRFMT, _path, _owner, _group, _inClass, ERRPARAM];

	return _description;
}

- (int)errNo
{
	return _errNo;
}

- (OFString*)path
{
	OF_GETTER(_path, NO)
}

- (OFString*)owner
{
	OF_GETTER(_owner, NO)
}

- (OFString*)group
{
	OF_GETTER(_group, NO)
}
@end
#endif