ObjFW  Diff

Differences From Artifact [d2aa51b6f7]:

To Artifact [1e28d0f42f]:


76
77
78
79
80
81
82


83
84


85
86
87

88
89
90
91
92
93
94
	symlink(src, dest);
#endif
}

- initWithPath: (const char*)path
       andMode: (const char*)mode
{


	if ((self = [super init])) {
		if ((fp = fopen(path, mode)) == NULL)


			@throw [OFOpenFileFailedException newWithObject: self
								andPath: path
								andMode: mode];

	}
	return self;
}

- free
{
	fclose(fp);







>
>

|
>
>
|
|
|
>







76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
	symlink(src, dest);
#endif
}

- initWithPath: (const char*)path
       andMode: (const char*)mode
{
	Class c;

	if ((self = [super init])) {
		if ((fp = fopen(path, mode)) == NULL) {
			c = [self class];
			[super free];
			@throw [OFOpenFileFailedException newWithClass: c 
							       andPath: path
							       andMode: mode];
		}
	}
	return self;
}

- free
{
	fclose(fp);
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
- (size_t)readNItems: (size_t)nitems
	      ofSize: (size_t)size
	  intoBuffer: (uint8_t*)buf
{
	size_t ret;

	if ((ret = fread(buf, size, nitems, fp)) == 0 && !feof(fp))
		@throw [OFReadFailedException newWithObject: self
						    andSize: size
						  andNItems: nitems];

	return ret;
}

- (size_t)readNBytes: (size_t)size
	  intoBuffer: (uint8_t*)buf
{







|
|
|







109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
- (size_t)readNItems: (size_t)nitems
	      ofSize: (size_t)size
	  intoBuffer: (uint8_t*)buf
{
	size_t ret;

	if ((ret = fread(buf, size, nitems, fp)) == 0 && !feof(fp))
		@throw [OFReadFailedException newWithClass: [self class]
						   andSize: size
						 andNItems: nitems];

	return ret;
}

- (size_t)readNBytes: (size_t)size
	  intoBuffer: (uint8_t*)buf
{
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
	       ofSize: (size_t)size
	   fromBuffer: (const uint8_t*)buf
{
	size_t ret;

	if ((ret = fwrite(buf, size, nitems, fp)) == 0 &&
	    size != 0 && nitems != 0)
		@throw [OFWriteFailedException newWithObject: self
						     andSize: size
						   andNItems: nitems];

	return ret;
}

- (size_t)writeNBytes: (size_t)size
	   fromBuffer: (const uint8_t*)buf
{







|
|
|







158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
	       ofSize: (size_t)size
	   fromBuffer: (const uint8_t*)buf
{
	size_t ret;

	if ((ret = fwrite(buf, size, nitems, fp)) == 0 &&
	    size != 0 && nitems != 0)
		@throw [OFWriteFailedException newWithClass: [self class]
						    andSize: size
						  andNItems: nitems];

	return ret;
}

- (size_t)writeNBytes: (size_t)size
	   fromBuffer: (const uint8_t*)buf
{