261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
|
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
|
-
-
-
-
-
+
-
-
-
+
-
-
-
-
+
-
-
-
+
-
-
-
-
-
+
-
-
-
-
-
-
+
+
|
{
OF_INVALID_INIT_METHOD
}
#ifdef OF_HAVE_FILES
- (instancetype)initWithContentsOfFile: (OFString *)path
{
char *buffer = NULL;
OFStreamOffset fileSize;
@try {
void *pool = objc_autoreleasePoolPush();
void *pool = objc_autoreleasePoolPush();
OFFile *file = [OFFile fileWithPath: path mode: @"r"];
fileSize = [file seekToOffset: 0 whence: OFSeekEnd];
OFIRI *IRI;
if (fileSize < 0 || (unsigned long long)fileSize > SIZE_MAX)
@throw [OFOutOfRangeException exception];
[file seekToOffset: 0 whence: OFSeekSet];
@try {
buffer = OFAllocMemory((size_t)fileSize, 1);
[file readIntoBuffer: buffer exactLength: (size_t)fileSize];
IRI = [OFIRI fileIRIWithPath: path];
objc_autoreleasePoolPop(pool);
} @catch (id e) {
OFFreeMemory(buffer);
[self release];
@throw e;
}
@try {
self = [self initWithItemsNoCopy: buffer
self = [self initWithContentsOfIRI: IRI];
count: (size_t)fileSize
freeWhenDone: true];
} @catch (id e) {
OFFreeMemory(buffer);
@throw e;
}
objc_autoreleasePoolPop(pool);
return self;
}
#endif
- (instancetype)initWithContentsOfIRI: (OFIRI *)IRI
{
|