9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
* the packaging of this file.
*/
#import "config.h"
#import <stdio.h>
#import <unistd.h>
#import <sys/types.h>
#import <sys/stat.h>
#import "OFFile.h"
#import "OFExceptions.h"
|
>
>
|
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
* the packaging of this file.
*/
#import "config.h"
#import <stdio.h>
#import <unistd.h>
#import <string.h>
#import <wchar.h>
#import <sys/types.h>
#import <sys/stat.h>
#import "OFFile.h"
#import "OFExceptions.h"
|
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
|
{
return [self readNItems: size
ofSize: 1];
}
- (size_t)writeNItems: (size_t)nitems
ofSize: (size_t)size
fromBuffer: (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];
return ret;
}
- (size_t)writeNBytes: (size_t)size
fromBuffer: (uint8_t*)buf
{
return [self writeNItems: size
ofSize: 1
fromBuffer: buf];
}
@end
|
|
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
|
{
return [self readNItems: size
ofSize: 1];
}
- (size_t)writeNItems: (size_t)nitems
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];
return ret;
}
- (size_t)writeNBytes: (size_t)size
fromBuffer: (const uint8_t*)buf
{
return [self writeNItems: size
ofSize: 1
fromBuffer: buf];
}
- (size_t)writeCString: (const char*)str
{
return [self writeNItems: strlen(str)
ofSize: 1
fromBuffer: (const uint8_t*)str];
}
- (size_t)writeWideCString: (const wchar_t*)str
{
return [self writeNItems: wcslen(str)
ofSize: sizeof(wchar_t)
fromBuffer: (const uint8_t*)str];
}
@end
|