@@ -1062,40 +1062,35 @@ 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); + @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; } -#endif - (instancetype)initWithSerialization: (OFXMLElement *)element { @try { void *pool = objc_autoreleasePoolPush();