1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
|
length: (size_t)fileSize];
[self freeMemory: tmp];
return self;
}
#endif
#if defined(OF_HAVE_FILES) || defined(OF_HAVE_SOCKETS)
- (instancetype)initWithContentsOfURL: (OFURL *)URL
{
return [self initWithContentsOfURL: URL
encoding: OF_STRING_ENCODING_AUTODETECT];
}
- (instancetype)initWithContentsOfURL: (OFURL *)URL
encoding: (of_string_encoding_t)encoding
{
void *pool = objc_autoreleasePoolPush();
OFString *scheme = [URL scheme];
# ifdef OF_HAVE_FILES
if ([scheme isEqual: @"file"]) {
if (encoding == OF_STRING_ENCODING_AUTODETECT)
encoding = OF_STRING_ENCODING_UTF_8;
self = [self
initWithContentsOfFile: [URL fileSystemRepresentation]
encoding: encoding];
} else
# endif
@throw [OFUnsupportedProtocolException exceptionWithURL: URL];
objc_autoreleasePoolPop(pool);
return self;
}
#endif
- (instancetype)initWithSerialization: (OFXMLElement *)element
{
@try {
void *pool = objc_autoreleasePoolPush();
if (![[element namespace] isEqual: OF_SERIALIZATION_NS])
|
<
>
|
<
|
<
<
<
<
|
<
|
<
|
<
|
>
>
>
|
>
<
|
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
|
length: (size_t)fileSize];
[self freeMemory: tmp];
return self;
}
#endif
- (instancetype)initWithContentsOfURL: (OFURL *)URL
{
return [self initWithContentsOfURL: URL
encoding: OF_STRING_ENCODING_AUTODETECT];
}
- (instancetype)initWithContentsOfURL: (OFURL *)URL
encoding: (of_string_encoding_t)encoding
{
@try {
void *pool = objc_autoreleasePoolPush();
OFData *data = [OFData dataWithContentsOfURL: URL];
self = [self initWithCString: [data items]
encoding: encoding
length: [data count]];
objc_autoreleasePoolPop(pool);
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- (instancetype)initWithSerialization: (OFXMLElement *)element
{
@try {
void *pool = objc_autoreleasePoolPush();
if (![[element namespace] isEqual: OF_SERIALIZATION_NS])
|