ObjFW  Diff

Differences From Artifact [03372dc363]:

To Artifact [5e63b2cd8e]:


35
36
37
38
39
40
41


42
43
44
45
46
47
48
49
50
51
52
53
35
36
37
38
39
40
41
42
43
44
45
46


47
48
49
50
51
52
53







+
+



-
-







#import "OFCharacterSet.h"
#import "OFData.h"
#import "OFDictionary.h"
#ifdef OF_HAVE_FILES
# import "OFFile.h"
# import "OFFileManager.h"
#endif
#import "OFIRI.h"
#import "OFIRIHandler.h"
#import "OFLocale.h"
#import "OFStream.h"
#import "OFSystemInfo.h"
#import "OFURI.h"
#import "OFURIHandler.h"
#import "OFUTF8String.h"
#import "OFUTF8String+Private.h"
#import "OFXMLElement.h"

#import "OFGetItemAttributesFailedException.h"
#import "OFInitializationFailedException.h"
#import "OFInvalidArgumentException.h"
578
579
580
581
582
583
584
585

586
587

588
589
590

591
592
593

594
595
596
597
598
599
600
578
579
580
581
582
583
584

585
586

587
588
589

590
591
592

593
594
595
596
597
598
599
600







-
+

-
+


-
+


-
+







			      encoding: (OFStringEncoding)encoding
{
	return (id)[[OFUTF8String alloc] initWithContentsOfFile: path
						       encoding: encoding];
}
#endif

- (instancetype)initWithContentsOfURI: (OFURI *)URI
- (instancetype)initWithContentsOfIRI: (OFIRI *)IRI
{
	return (id)[[OFUTF8String alloc] initWithContentsOfURI: URI];
	return (id)[[OFUTF8String alloc] initWithContentsOfIRI: IRI];
}

- (instancetype)initWithContentsOfURI: (OFURI *)URI
- (instancetype)initWithContentsOfIRI: (OFIRI *)IRI
			     encoding: (OFStringEncoding)encoding
{
	return (id)[[OFUTF8String alloc] initWithContentsOfURI: URI
	return (id)[[OFUTF8String alloc] initWithContentsOfIRI: IRI
						      encoding: encoding];
}

- (instancetype)initWithSerialization: (OFXMLElement *)element
{
	return (id)[[OFUTF8String alloc] initWithSerialization: element];
}
792
793
794
795
796
797
798
799

800
801

802
803
804

805
806
807

808
809
810
811
812
813
814
792
793
794
795
796
797
798

799
800

801
802
803

804
805
806

807
808
809
810
811
812
813
814







-
+

-
+


-
+


-
+







				encoding: (OFStringEncoding)encoding
{
	return [[[self alloc] initWithContentsOfFile: path
					    encoding: encoding] autorelease];
}
#endif

+ (instancetype)stringWithContentsOfURI: (OFURI *)URI
+ (instancetype)stringWithContentsOfIRI: (OFIRI *)IRI
{
	return [[[self alloc] initWithContentsOfURI: URI] autorelease];
	return [[[self alloc] initWithContentsOfIRI: IRI] autorelease];
}

+ (instancetype)stringWithContentsOfURI: (OFURI *)URI
+ (instancetype)stringWithContentsOfIRI: (OFIRI *)IRI
			       encoding: (OFStringEncoding)encoding
{
	return [[[self alloc] initWithContentsOfURI: URI
	return [[[self alloc] initWithContentsOfIRI: IRI
					   encoding: encoding] autorelease];
}

- (instancetype)init
{
	if ([self isMemberOfClass: [OFString class]]) {
		@try {
1045
1046
1047
1048
1049
1050
1051
1052

1053
1054

1055
1056
1057
1058

1059
1060
1061
1062
1063
1064
1065

1066
1067
1068
1069
1070
1071
1072
1045
1046
1047
1048
1049
1050
1051

1052
1053

1054
1055
1056
1057

1058
1059
1060
1061
1062
1063
1064

1065
1066
1067
1068
1069
1070
1071
1072







-
+

-
+



-
+






-
+







		}
	}

	return self;
}
#endif

- (instancetype)initWithContentsOfURI: (OFURI *)URI
- (instancetype)initWithContentsOfIRI: (OFIRI *)IRI
{
	return [self initWithContentsOfURI: URI
	return [self initWithContentsOfIRI: IRI
				  encoding: OFStringEncodingAutodetect];
}

- (instancetype)initWithContentsOfURI: (OFURI *)URI
- (instancetype)initWithContentsOfIRI: (OFIRI *)IRI
			     encoding: (OFStringEncoding)encoding
{
	void *pool = objc_autoreleasePoolPush();
	OFData *data;

	@try {
		data = [OFData dataWithContentsOfURI: URI];
		data = [OFData dataWithContentsOfIRI: IRI];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	/* FIXME: Detect encoding where we can. */
	if (encoding == OFStringEncodingAutodetect)
2720
2721
2722
2723
2724
2725
2726
2727

2728
2729

2730
2731
2732

2733
2734
2735
2736
2737

2738
2739
2740
2741
2742
2743
2744
2720
2721
2722
2723
2724
2725
2726

2727
2728

2729
2730
2731

2732
2733
2734
2735
2736

2737
2738
2739
2740
2741
2742
2743
2744







-
+

-
+


-
+




-
+







	void *pool = objc_autoreleasePoolPush();
	OFFile *file = [OFFile fileWithPath: path mode: @"w"];
	[file writeString: self encoding: encoding];
	objc_autoreleasePoolPop(pool);
}
#endif

- (void)writeToURI: (OFURI *)URI
- (void)writeToIRI: (OFIRI *)IRI
{
	[self writeToURI: URI encoding: OFStringEncodingUTF8];
	[self writeToIRI: IRI encoding: OFStringEncodingUTF8];
}

- (void)writeToURI: (OFURI *)URI encoding: (OFStringEncoding)encoding
- (void)writeToIRI: (OFIRI *)IRI encoding: (OFStringEncoding)encoding
{
	void *pool = objc_autoreleasePoolPush();
	OFStream *stream;

	stream = [OFURIHandler openItemAtURI: URI mode: @"w"];
	stream = [OFIRIHandler openItemAtIRI: IRI mode: @"w"];
	[stream writeString: self encoding: encoding];

	objc_autoreleasePoolPop(pool);
}

#ifdef OF_HAVE_BLOCKS
- (void)enumerateLinesUsingBlock: (OFStringLineEnumerationBlock)block