ObjFW  Diff

Differences From Artifact [249d4d336a]:

To Artifact [88173cbff8]:


65
66
67
68
69
70
71
72
73
74



75
76
77
78
79
80
81
65
66
67
68
69
70
71



72
73
74
75
76
77
78
79
80
81







-
-
-
+
+
+







}

- initWithPath: (const char*)path
       andMode: (const char*)mode
{
	if ((self = [super init])) {
		if ((fp = fopen(path, mode)) == NULL)
			[[OFOpenFileFailedException newWithObject: self
							  andPath: path
							  andMode: mode] raise];
			@throw [OFOpenFileFailedException newWithObject: self
								andPath: path
								andMode: mode];
	}
	return self;
}

- free
{
	fclose(fp);
90
91
92
93
94
95
96
97
98
99



100
101
102
103
104
105
106
90
91
92
93
94
95
96



97
98
99
100
101
102
103
104
105
106







-
-
-
+
+
+







- (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))
		[[OFReadFailedException newWithObject: self
					      andSize: size
					    andNItems: nitems] raise];
		@throw [OFReadFailedException newWithObject: self
						    andSize: size
						  andNItems: nitems];

	return ret;
}

- (size_t)readNBytes: (size_t)size
	  intoBuffer: (uint8_t*)buf
{
139
140
141
142
143
144
145
146
147
148



149
150
151
152
153
154
155
139
140
141
142
143
144
145



146
147
148
149
150
151
152
153
154
155







-
-
-
+
+
+







	       ofSize: (size_t)size
	   fromBuffer: (const uint8_t*)buf
{
	size_t ret;

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

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