ObjFW  Diff

Differences From Artifact [08cbbc44cd]:

To Artifact [de67b84ef2]:


80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
- 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;







|







80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
- initWithPath: (const char*)path
       andMode: (const char*)mode
{
	Class c;

	if ((self = [super init])) {
		if ((fp = fopen(path, mode)) == NULL) {
			c = isa;
			[super free];
			@throw [OFOpenFileFailedException newWithClass: c 
							       andPath: path
							       andMode: mode];
		}
	}
	return self;
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
- (size_t)readNItems: (size_t)nitems
	      ofSize: (size_t)size
	  intoBuffer: (char*)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







|







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

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

	return ret;
}

- (size_t)readNBytes: (size_t)size
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
	       ofSize: (size_t)size
	   fromBuffer: (const char*)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







|







132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
	       ofSize: (size_t)size
	   fromBuffer: (const char*)buf
{
	size_t ret;

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

	return ret;
}

- (size_t)writeNBytes: (size_t)size