615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
|
- initWithContentsOfFile: (OFString*)path
encoding: (enum of_string_encoding)encoding
{
self = [super init];
@try {
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
OFFile *file;
char *tmp;
struct stat s;
if (stat([path cString], &s) == -1)
@throw [OFInitializationFailedException
newWithClass: isa];
tmp = [self allocMemoryWithSize: s.st_size];
file = [OFFile fileWithPath: path
mode: @"rb"];
[file readExactlyNBytes: s.st_size
intoBuffer: tmp];
self = [self initWithCString: tmp
encoding: encoding
length: s.st_size];
[self freeMemory: tmp];
[pool release];
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
|
<
<
|
|
>
>
>
>
|
|
|
|
|
|
>
>
|
<
|
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
|
- initWithContentsOfFile: (OFString*)path
encoding: (enum of_string_encoding)encoding
{
self = [super init];
@try {
OFFile *file;
char *tmp;
struct stat s;
if (stat([path cString], &s) == -1)
@throw [OFInitializationFailedException
newWithClass: isa];
file = [[OFFile alloc] initWithPath: path
mode: @"rb"];
@try {
tmp = [self allocMemoryWithSize: s.st_size];
[file readExactlyNBytes: s.st_size
intoBuffer: tmp];
self = [self initWithCString: tmp
encoding: encoding
length: s.st_size];
[self freeMemory: tmp];
} @finally {
[file release];
}
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
|