@@ -41,10 +41,11 @@ #ifdef OF_HAVE_FILES # import "OFFile.h" # import "OFFileManager.h" #endif #import "OFURL.h" +#import "OFURLHandler.h" #import "OFXMLElement.h" #import "OFInitializationFailedException.h" #import "OFInvalidArgumentException.h" #import "OFInvalidEncodingException.h" @@ -2898,10 +2899,34 @@ encoding: encoding]; objc_autoreleasePoolPop(pool); } #endif + +- (void)writeToURL: (OFURL *)URL +{ + [self writeToURL: URL + encoding: OF_STRING_ENCODING_UTF_8]; +} + +- (void)writeToURL: (OFURL *)URL + encoding: (of_string_encoding_t)encoding +{ + void *pool = objc_autoreleasePoolPush(); + OFURLHandler *URLHandler; + OFStream *stream; + + if ((URLHandler = [OFURLHandler handlerForURL: URL]) == nil) + @throw [OFUnsupportedProtocolException exceptionWithURL: URL]; + + stream = [URLHandler openItemAtURL: URL + mode: @"w"]; + [stream writeString: self + encoding: encoding]; + + objc_autoreleasePoolPop(pool); +} #ifdef OF_HAVE_BLOCKS - (void)enumerateLinesUsingBlock: (of_string_line_enumeration_block_t)block { void *pool = objc_autoreleasePoolPush();