ObjFW  Check-in [5c08717941]

Overview
Comment:Add -[writeToURL:]
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 5c08717941fccbf99a0e8f0fb3bbe966c0c718f160bca30057f2536f926f2444
User & Date: js on 2018-01-15 00:34:58
Other Links: manifest | tags
Context
2018-01-18
23:28
OFHTTPServer: Fix missing cast check-in: cb0ac3f868 user: js tags: trunk
2018-01-15
00:34
Add -[writeToURL:] check-in: 5c08717941 user: js tags: trunk
2018-01-14
18:25
OFData: Add -[rangeOfData:options:range:] check-in: c85b63d2af user: js tags: trunk
Changes

Modified src/OFConstantString.m from [1d7e2ea2cd] to [37198b5a4e].

660
661
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
{
	[self finishInitialization];

	return [self decomposedStringWithCompatibilityMapping];
}
#endif


- (void)writeToFile: (OFString *)path
{
	[self finishInitialization];

	[self writeToFile: path];
}

- (void)writeToFile: (OFString *)path
	   encoding: (of_string_encoding_t)encoding
{
	[self finishInitialization];

	[self writeToFile: path
		 encoding: encoding];
}


















#ifdef OF_HAVE_BLOCKS
- (void)enumerateLinesUsingBlock: (of_string_line_enumeration_block_t)block
{
	[self finishInitialization];

	[self enumerateLinesUsingBlock: block];
}
#endif
@end







>















>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>










660
661
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
698
699
700
701
702
703
704
705
706
707
708
709
{
	[self finishInitialization];

	return [self decomposedStringWithCompatibilityMapping];
}
#endif

#ifdef OF_HAVE_FILES
- (void)writeToFile: (OFString *)path
{
	[self finishInitialization];

	[self writeToFile: path];
}

- (void)writeToFile: (OFString *)path
	   encoding: (of_string_encoding_t)encoding
{
	[self finishInitialization];

	[self writeToFile: path
		 encoding: encoding];
}
#endif

- (void)writeToURL: (OFURL *)URL
{
	[self finishInitialization];

	[self writeToURL: URL];
}

- (void)writeToURL: (OFURL *)URL
	  encoding: (of_string_encoding_t)encoding
{
	[self finishInitialization];

	[self writeToURL: URL
		encoding: encoding];
}

#ifdef OF_HAVE_BLOCKS
- (void)enumerateLinesUsingBlock: (of_string_line_enumeration_block_t)block
{
	[self finishInitialization];

	[self enumerateLinesUsingBlock: block];
}
#endif
@end

Modified src/OFData.h from [72db843d4f] to [40d5270f3b].

304
305
306
307
308
309
310







311
312
313
314
315
316
317
/*!
 * @brief Writes the OFData into the specified file.
 *
 * @param path The path of the file to write to
 */
- (void)writeToFile: (OFString *)path;
#endif







@end

OF_ASSUME_NONNULL_END

#import "OFMutableData.h"
#import "OFData+CryptoHashing.h"
#import "OFData+MessagePackValue.h"







>
>
>
>
>
>
>







304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
/*!
 * @brief Writes the OFData into the specified file.
 *
 * @param path The path of the file to write to
 */
- (void)writeToFile: (OFString *)path;
#endif

/*!
 * @brief Writes the OFData to the specified URL.
 *
 * @param URL The URL to write to
 */
- (void)writeToURL: (OFURL *)URL;
@end

OF_ASSUME_NONNULL_END

#import "OFMutableData.h"
#import "OFData+CryptoHashing.h"
#import "OFData+MessagePackValue.h"

Modified src/OFData.m from [7c051801e0] to [28b1c3f1d0].

596
597
598
599
600
601
602
















603
604
605
606
607
608
609
		[file writeBuffer: _items
			   length: _count * _itemSize];
	} @finally {
		[file release];
	}
}
#endif

















- (OFXMLElement *)XMLElementBySerializing
{
	void *pool;
	OFXMLElement *element;

	if (_itemSize != 1)







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
		[file writeBuffer: _items
			   length: _count * _itemSize];
	} @finally {
		[file release];
	}
}
#endif

- (void)writeToURL: (OFURL *)URL
{
	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 writeData: self];

	objc_autoreleasePoolPop(pool);
}

- (OFXMLElement *)XMLElementBySerializing
{
	void *pool;
	OFXMLElement *element;

	if (_itemSize != 1)

Modified src/OFString.h from [53d3dfe512] to [73a909cfb2].

1214
1215
1216
1217
1218
1219
1220
















1221
1222
1223
1224
1225
1226
1227
 * @param path The path of the file to write to
 * @param encoding The encoding to use to write the string into the file
 */
- (void)writeToFile: (OFString *)path
	   encoding: (of_string_encoding_t)encoding;
#endif

















#ifdef OF_HAVE_BLOCKS
/*!
 * Enumerates all lines in the receiver using the specified block.
 *
 * @brief block The block to call for each line
 */
- (void)enumerateLinesUsingBlock: (of_string_line_enumeration_block_t)block;







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
 * @param path The path of the file to write to
 * @param encoding The encoding to use to write the string into the file
 */
- (void)writeToFile: (OFString *)path
	   encoding: (of_string_encoding_t)encoding;
#endif

/*!
 * @brief Writes the string to the specified URL using UTF-8 encoding.
 *
 * @param URL The URL to write to
 */
- (void)writeToURL: (OFURL *)URL;

/*!
 * @brief Writes the string to the specified URL using the specified encoding.
 *
 * @param URL The URL to write to
 * @param encoding The encoding to use to write the string to the URL
 */
- (void)writeToURL: (OFURL *)URL
	  encoding: (of_string_encoding_t)encoding;

#ifdef OF_HAVE_BLOCKS
/*!
 * Enumerates all lines in the receiver using the specified block.
 *
 * @brief block The block to call for each line
 */
- (void)enumerateLinesUsingBlock: (of_string_line_enumeration_block_t)block;

Modified src/OFString.m from [665adcd6a8] to [03d1103065].

39
40
41
42
43
44
45

46
47
48
49
50
51
52
#import "OFDictionary.h"
#import "OFLocalization.h"
#ifdef OF_HAVE_FILES
# import "OFFile.h"
# import "OFFileManager.h"
#endif
#import "OFURL.h"

#import "OFXMLElement.h"

#import "OFInitializationFailedException.h"
#import "OFInvalidArgumentException.h"
#import "OFInvalidEncodingException.h"
#import "OFInvalidFormatException.h"
#import "OFNotImplementedException.h"







>







39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#import "OFDictionary.h"
#import "OFLocalization.h"
#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"
#import "OFInvalidFormatException.h"
#import "OFNotImplementedException.h"
2896
2897
2898
2899
2900
2901
2902
























2903
2904
2905
2906
2907
2908
2909
			       mode: @"w"];
	[file writeString: self
		 encoding: encoding];

	objc_autoreleasePoolPop(pool);
}
#endif

























#ifdef OF_HAVE_BLOCKS
- (void)enumerateLinesUsingBlock: (of_string_line_enumeration_block_t)block
{
	void *pool = objc_autoreleasePoolPush();
	const of_unichar_t *characters = [self characters];
	size_t i, last = 0, length = [self length];







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
			       mode: @"w"];
	[file writeString: self
		 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();
	const of_unichar_t *characters = [self characters];
	size_t i, last = 0, length = [self length];