ObjFW  Diff

Differences From Artifact [c9e9081959]:

To Artifact [a226263679]:


56
57
58
59
60
61
62







































































63
64
65
66
67
68
69
+ (OFCharacterSet *)URLPathAllowedCharacterSet;
@end

@interface OFCharacterSet_URLQueryOrFragmentAllowed:
    OFCharacterSet_URLAllowedBase
+ (OFCharacterSet *)URLQueryOrFragmentAllowedCharacterSet;
@end








































































@interface OFCharacterSet_invertedSetWithPercent: OFCharacterSet
{
	OFCharacterSet *_characterSet;
	bool (*_characterIsMember)(id, SEL, of_unichar_t);
}








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







56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
+ (OFCharacterSet *)URLPathAllowedCharacterSet;
@end

@interface OFCharacterSet_URLQueryOrFragmentAllowed:
    OFCharacterSet_URLAllowedBase
+ (OFCharacterSet *)URLQueryOrFragmentAllowedCharacterSet;
@end

#ifdef OF_HAVE_FILES
static OFString *
pathToURLPath(OFString *path)
{
# if defined(OF_WINDOWS) || defined(OF_MSDOS)
	path = [path stringByReplacingOccurrencesOfString: @"\\"
					       withString: @"/"];
	path = [path stringByPrependingString: @"/"];
# elif defined(OF_AMIGAOS)
	OFArray OF_GENERIC(OFString *) *components = [path pathComponents];
	OFMutableString *ret = [OFMutableString string];

	for (OFString *component in components) {
		if ([component length] == 0)
			continue;

		if ([component isEqual: @"/"])
			[ret appendString: @"/.."];
		else {
			[ret appendString: @"/"];
			[ret appendString: component];
		}
	}

	[ret makeImmutable];

	return ret;
# else
	return path;
# endif
}

static OFString *
URLPathToPath(OFString *path)
{
# if defined(OF_WINDOWS) || defined(OF_MSDOS)
	path = [path substringWithRange: of_range(1, [path length] - 1)];
	path = [path stringByReplacingOccurrencesOfString: @"/"
					       withString: @"\\"];
# elif defined(OF_AMIGAOS)
	OFMutableArray OF_GENERIC(OFString *) *components;
	size_t count;

	path = [path substringWithRange: of_range(1, [path length] - 1)];
	components = [[[path
	    componentsSeparatedByString: @"/"] mutableCopy] autorelease];
	count = [components count];

	for (size_t i = 0; i < count; i++) {
		OFString *component = [components objectAtIndex: i];

		if ([component isEqual: @"."]) {
			[components removeObjectAtIndex: i];
			count--;

			i--;
			continue;
		}

		if ([component isEqual: @".."])
			[components replaceObjectAtIndex: i
					      withObject: @"/"];
	}

	return [OFString pathWithComponents: components];
# else
	return path;
# endif
}
#endif

@interface OFCharacterSet_invertedSetWithPercent: OFCharacterSet
{
	OFCharacterSet *_characterSet;
	bool (*_characterIsMember)(id, SEL, of_unichar_t);
}

605
606
607
608
609
610
611




612
613
614
615
616
617
618
	@try {
		void *pool = objc_autoreleasePoolPush();

#if defined(OF_WINDOWS) || defined(OF_MSDOS)
		isDirectory = ([path hasSuffix: @"\\"] ||
		    [path hasSuffix: @"/"] ||
		    [OFURLHandler_file of_directoryExistsAtPath: path]);




#else
		isDirectory = ([path hasSuffix: @"/"] ||
		    [OFURLHandler_file of_directoryExistsAtPath: path]);
#endif

		objc_autoreleasePoolPop(pool);
	} @catch (id e) {







>
>
>
>







676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
	@try {
		void *pool = objc_autoreleasePoolPush();

#if defined(OF_WINDOWS) || defined(OF_MSDOS)
		isDirectory = ([path hasSuffix: @"\\"] ||
		    [path hasSuffix: @"/"] ||
		    [OFURLHandler_file of_directoryExistsAtPath: path]);
#elif defined(OF_AMIGAOS)
		isDirectory = ([path hasSuffix: @"/"] ||
		    [path hasSuffix: @":"] ||
		    [OFURLHandler_file of_directoryExistsAtPath: path]);
#else
		isDirectory = ([path hasSuffix: @"/"] ||
		    [OFURLHandler_file of_directoryExistsAtPath: path]);
#endif

		objc_autoreleasePoolPop(pool);
	} @catch (id e) {
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
			    defaultManager] currentDirectoryPath];

			path = [currentDirectoryPath
			    stringByAppendingPathComponent: path];
			path = [path stringByStandardizingPath];
		}

# if defined(OF_WINDOWS) || defined(OF_DJGPP)
		path = [path stringByReplacingOccurrencesOfString: @"\\"
						       withString: @"/"];
		path = [path stringByPrependingString: @"/"];
# endif

		if (isDirectory && ![path hasSuffix: @"/"])
			path = [path stringByAppendingString: @"/"];

		_URLEncodedScheme = @"file";
		_URLEncodedPath = [[path
		    stringByURLEncodingWithAllowedCharacters:







<
<
<
|
<







714
715
716
717
718
719
720



721

722
723
724
725
726
727
728
			    defaultManager] currentDirectoryPath];

			path = [currentDirectoryPath
			    stringByAppendingPathComponent: path];
			path = [path stringByStandardizingPath];
		}




		path = pathToURLPath(path);


		if (isDirectory && ![path hasSuffix: @"/"])
			path = [path stringByAppendingString: @"/"];

		_URLEncodedScheme = @"file";
		_URLEncodedPath = [[path
		    stringByURLEncodingWithAllowedCharacters:
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978

	path = [self path];

	if ([path hasSuffix: @"/"])
		path = [path substringWithRange:
		    of_range(0, [path length] - 1)];

#if defined(OF_WINDOWS) || defined(OF_MSDOS)
	path = [path substringWithRange: of_range(1, [path length] - 1)];
	path = [path stringByReplacingOccurrencesOfString: @"/"
					       withString: @"\\"];
#endif

	[path retain];

	objc_autoreleasePoolPop(pool);

	return [path autorelease];
}







<
<
|
<
<







1031
1032
1033
1034
1035
1036
1037


1038


1039
1040
1041
1042
1043
1044
1045

	path = [self path];

	if ([path hasSuffix: @"/"])
		path = [path substringWithRange:
		    of_range(0, [path length] - 1)];



	path = URLPathToPath(path);



	[path retain];

	objc_autoreleasePoolPop(pool);

	return [path autorelease];
}