662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
|
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
|
+
+
+
-
+
-
+
-
+
|
OFFile *file;
if (stat([path cString], &s) == -1)
@throw [OFOpenFileFailedException newWithClass: isa
path: path
mode: @"rb"];
if (s.st_size > SIZE_MAX)
@throw [OFOutOfRangeException newWithClass: isa];
file = [[OFFile alloc] initWithPath: path
mode: @"rb"];
@try {
tmp = [self allocMemoryWithSize: s.st_size];
tmp = [self allocMemoryWithSize: (size_t)s.st_size];
[file readExactlyNBytes: s.st_size
[file readExactlyNBytes: (size_t)s.st_size
intoBuffer: tmp];
} @finally {
[file release];
}
} @catch (id e) {
[self release];
@throw e;
}
self = [self initWithCString: tmp
encoding: encoding
length: s.st_size];
length: (size_t)s.st_size];
[self freeMemory: tmp];
return self;
}
- initWithContentsOfURL: (OFURL*)url
{
|