ObjFW  Check-in [9e8164519c]

Overview
Comment:Several path handling improvements and more tests
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 9e8164519c1f02eb21f480ab96efbed9073d7aced02258fad0bf576e29ef515c
User & Date: js on 2018-08-19 02:12:12
Other Links: manifest | tags
Context
2018-08-19
02:40
tests: Ignore unimplemented user{Config,Data}Path check-in: e814441c17 user: js tags: trunk
02:12
Several path handling improvements and more tests check-in: 9e8164519c user: js tags: trunk
01:13
Don't use nanosleep() on Nintendo 3DS check-in: 06255a6aa8 user: js tags: trunk
Changes

Modified src/OFString+PathAdditions_3DS.m from [f97635b389] to [b4ffbdfd10].

41
42
43
44
45
46
47





48
49
50
51
52
53
54
55
56

57
58
59
60
61
62
63
64

65
66

67
68
69
70
71

72
73
74
75
76
77
78
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
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







+
+
+
+
+








-
+







-
+

-
+




-
+







		if (!first && ![ret hasSuffix: @"/"])
			[ret appendString: @"/"];

		[ret appendString: component];

		first = false;
	}

	if ([ret hasSuffix: @":"])
		[ret appendString: @"/"];

	[ret makeImmutable];

	objc_autoreleasePoolPop(pool);

	return ret;
}

- (bool)isAbsolutePath
{
	return [self containsString: @":"];
	return [self containsString: @":/"];
}

- (OFArray *)pathComponents
{
	OFMutableArray OF_GENERIC(OFString *) *ret = [OFMutableArray array];
	void *pool = objc_autoreleasePoolPush();
	const char *cString = [self UTF8String];
	size_t i, last = 0, pathCStringLength = [self UTF8StringLength];
	size_t i, last = 0, cStringLength = [self UTF8StringLength];

	if (pathCStringLength == 0) {
	if (cStringLength == 0) {
		objc_autoreleasePoolPop(pool);
		return ret;
	}

	for (i = 0; i < pathCStringLength; i++) {
	for (i = 0; i < cStringLength; i++) {
		if (cString[i] == '/') {
			if (i - last != 0)
				[ret addObject: [OFString
				    stringWithUTF8String: cString + last
						  length: i - last]];

			last = i + 1;
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
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
141

142
143
144
145
146
147
148
149







-
-
+
+



+
+
+
+
+
+
-
+




-
-
+
+

-
+




-
+


-
+














-
+








	return ret;
}

- (OFString *)lastPathComponent
{
	void *pool = objc_autoreleasePoolPush();
	const char *cString = [self UTF8String];
	size_t pathCStringLength = [self UTF8StringLength];
	const char *cString;
	size_t cStringLength;
	ssize_t i;
	OFString *ret;

	if ([self hasSuffix: @":/"])
		return self;

	cString = [self UTF8String];
	cStringLength = [self UTF8StringLength];

	if (pathCStringLength == 0) {
	if (cStringLength == 0) {
		objc_autoreleasePoolPop(pool);
		return @"";
	}

	if (cString[pathCStringLength - 1] == '/')
		pathCStringLength--;
	if (cString[cStringLength - 1] == '/')
		cStringLength--;

	if (pathCStringLength == 0) {
	if (cStringLength == 0) {
		objc_autoreleasePoolPop(pool);
		return @"";
	}

	if (pathCStringLength - 1 > SSIZE_MAX)
	if (cStringLength - 1 > SSIZE_MAX)
		@throw [OFOutOfRangeException exception];

	for (i = pathCStringLength - 1; i >= 0; i--) {
	for (i = cStringLength - 1; i >= 0; i--) {
		if (cString[i] == '/') {
			i++;
			break;
		}
	}

	/*
	 * Only one component, but the trailing delimiter might have been
	 * removed, so return a new string anyway.
	 */
	if (i < 0)
		i = 0;

	ret = [[OFString alloc] initWithUTF8String: cString + i
					    length: pathCStringLength - i];
					    length: cStringLength - i];

	objc_autoreleasePoolPop(pool);

	return [ret autorelease];
}

- (OFString *)pathExtension
156
157
158
159
160
161
162
163
164


165
166






167

168
169
170
171
172
173


174
175

176
177
178
179
180

181
182
183
184
185
186
187
167
168
169
170
171
172
173


174
175
176
177
178
179
180
181
182
183

184
185
186
187
188


189
190
191

192
193
194
195
196

197
198
199
200
201
202
203
204







-
-
+
+


+
+
+
+
+
+
-
+




-
-
+
+

-
+




-
+







	objc_autoreleasePoolPop(pool);
	return [ret autorelease];
}

- (OFString *)stringByDeletingLastPathComponent
{
	void *pool = objc_autoreleasePoolPush();
	const char *cString = [self UTF8String];
	size_t pathCStringLength = [self UTF8StringLength];
	const char *cString;
	size_t cStringLength;
	OFString *ret;

	if ([self hasSuffix: @":/"])
		return self;

	cString = [self UTF8String];
	cStringLength = [self UTF8StringLength];

	if (pathCStringLength == 0) {
	if (cStringLength == 0) {
		objc_autoreleasePoolPop(pool);
		return @"";
	}

	if (cString[pathCStringLength - 1] == '/')
		pathCStringLength--;
	if (cString[cStringLength - 1] == '/')
		cStringLength--;

	if (pathCStringLength == 0) {
	if (cStringLength == 0) {
		objc_autoreleasePoolPop(pool);
		return @"";
	}

	for (size_t i = pathCStringLength; i >= 1; i--) {
	for (size_t i = cStringLength; i >= 1; i--) {
		if (cString[i - 1] == '/') {
			ret = [[OFString alloc] initWithUTF8String: cString
							    length: i - 1];

			objc_autoreleasePoolPop(pool);

			return [ret autorelease];

Modified src/OFString+PathAdditions_AmigaOS.m from [d7d67ba75c] to [d2ed7eeb87].

39
40
41
42
43
44
45


46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62

63
64

65
66
67
68
69

70
71
72
73
74
75
76
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63

64
65

66
67
68
69
70

71
72
73
74
75
76
77
78







+
+
















-
+

-
+




-
+







			[ret appendString: @"/"];

		[ret appendString: component];

		if (![component hasSuffix: @":"])
			firstAfterDevice = false;
	}

	[ret makeImmutable];

	objc_autoreleasePoolPop(pool);

	return ret;
}

- (bool)isAbsolutePath
{
	return [self containsString: @":"];
}

- (OFArray *)pathComponents
{
	OFMutableArray OF_GENERIC(OFString *) *ret = [OFMutableArray array];
	void *pool = objc_autoreleasePoolPush();
	const char *cString = [self UTF8String];
	size_t i, last = 0, pathCStringLength = [self UTF8StringLength];
	size_t i, last = 0, cStringLength = [self UTF8StringLength];

	if (pathCStringLength == 0) {
	if (cStringLength == 0) {
		objc_autoreleasePoolPop(pool);
		return ret;
	}

	for (i = 0; i < pathCStringLength; i++) {
	for (i = 0; i < cStringLength; i++) {
		if (cString[i] == '/') {
			if (i - last != 0)
				[ret addObject: [OFString
				    stringWithUTF8String: cString + last
						  length: i - last]];
			else
				[ret addObject: @"/"];

Modified src/OFString+PathAdditions_DOS.m from [f5b56fbc72] to [24669dc9e9].

41
42
43
44
45
46
47





48
49
50
51
52
53
54
55
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
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







+
+
+
+
+








-
-
-
-
-
-
+
-
-
-







-
+

-
+




-
+







		if (!first && ![ret hasSuffix: @"\\"] && ![ret hasSuffix: @"/"])
			[ret appendString: @"\\"];

		[ret appendString: component];

		first = false;
	}

	if ([ret hasSuffix: @":"])
		[ret appendString: @"\\"];

	[ret makeImmutable];

	objc_autoreleasePoolPop(pool);

	return ret;
}

- (bool)isAbsolutePath
{
	void *pool = objc_autoreleasePoolPush();
	const char *UTF8String = [self UTF8String];
	size_t UTF8StringLength = [self UTF8StringLength];
	bool ret = (UTF8StringLength >= 3 && UTF8String[1] == ':' &&
	    (UTF8String[2] == '\\' || UTF8String[2] == '/'));

	return ([self containsString: @":\\"] || [self containsString: @":/"]);
	objc_autoreleasePoolPop(pool);

	return ret;
}

- (OFArray *)pathComponents
{
	OFMutableArray OF_GENERIC(OFString *) *ret = [OFMutableArray array];
	void *pool = objc_autoreleasePoolPush();
	const char *cString = [self UTF8String];
	size_t i, last = 0, pathCStringLength = [self UTF8StringLength];
	size_t i, last = 0, cStringLength = [self UTF8StringLength];

	if (pathCStringLength == 0) {
	if (cStringLength == 0) {
		objc_autoreleasePoolPop(pool);
		return ret;
	}

	for (i = 0; i < pathCStringLength; i++) {
	for (i = 0; i < cStringLength; i++) {
		if (cString[i] == '\\' || cString[i] == '/') {
			if (i - last != 0)
				[ret addObject: [OFString
				    stringWithUTF8String: cString + last
						  length: i - last]];

			last = i + 1;
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

141
142
143
144
145
146
147
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
141
142

143
144
145
146
147
148
149
150







-
-
+
+



+
+
+
+
+
+
-
+




-
-
-
+
+
+

-
+




-
+


-
+














-
+








	return ret;
}

- (OFString *)lastPathComponent
{
	void *pool = objc_autoreleasePoolPush();
	const char *cString = [self UTF8String];
	size_t pathCStringLength = [self UTF8StringLength];
	const char *cString;
	size_t cStringLength;
	ssize_t i;
	OFString *ret;

	if ([self hasSuffix: @":\\"] || [self hasSuffix: @":/"])
		return self;

	cString = [self UTF8String];
	cStringLength = [self UTF8StringLength];

	if (pathCStringLength == 0) {
	if (cStringLength == 0) {
		objc_autoreleasePoolPop(pool);
		return @"";
	}

	if (cString[pathCStringLength - 1] == '\\' ||
	    cString[pathCStringLength - 1] == '/')
		pathCStringLength--;
	if (cString[cStringLength - 1] == '\\' ||
	    cString[cStringLength - 1] == '/')
		cStringLength--;

	if (pathCStringLength == 0) {
	if (cStringLength == 0) {
		objc_autoreleasePoolPop(pool);
		return @"";
	}

	if (pathCStringLength - 1 > SSIZE_MAX)
	if (cStringLength - 1 > SSIZE_MAX)
		@throw [OFOutOfRangeException exception];

	for (i = pathCStringLength - 1; i >= 0; i--) {
	for (i = cStringLength - 1; i >= 0; i--) {
		if (cString[i] == '\\' || cString[i] == '/') {
			i++;
			break;
		}
	}

	/*
	 * Only one component, but the trailing delimiter might have been
	 * removed, so return a new string anyway.
	 */
	if (i < 0)
		i = 0;

	ret = [[OFString alloc] initWithUTF8String: cString + i
					    length: pathCStringLength - i];
					    length: cStringLength - i];

	objc_autoreleasePoolPop(pool);

	return [ret autorelease];
}

- (OFString *)pathExtension
165
166
167
168
169
170
171
172
173


174
175






176

177
178
179
180
181
182
183



184
185

186
187
188
189
190

191
192
193
194
195
196
197
168
169
170
171
172
173
174


175
176
177
178
179
180
181
182
183
184

185
186
187
188
189



190
191
192
193

194
195
196
197
198

199
200
201
202
203
204
205
206







-
-
+
+


+
+
+
+
+
+
-
+




-
-
-
+
+
+

-
+




-
+







	objc_autoreleasePoolPop(pool);
	return [ret autorelease];
}

- (OFString *)stringByDeletingLastPathComponent
{
	void *pool = objc_autoreleasePoolPush();
	const char *cString = [self UTF8String];
	size_t pathCStringLength = [self UTF8StringLength];
	const char *cString;
	size_t cStringLength;
	OFString *ret;

	if ([self hasSuffix: @":\\"] || [self hasSuffix: @":/"])
		return self;

	cString = [self UTF8String];
	cStringLength = [self UTF8StringLength];

	if (pathCStringLength == 0) {
	if (cStringLength == 0) {
		objc_autoreleasePoolPop(pool);
		return @"";
	}

	if (cString[pathCStringLength - 1] == '\\' ||
	    cString[pathCStringLength - 1] == '/')
		pathCStringLength--;
	if (cString[cStringLength - 1] == '\\' ||
	    cString[cStringLength - 1] == '/')
		cStringLength--;

	if (pathCStringLength == 0) {
	if (cStringLength == 0) {
		objc_autoreleasePoolPop(pool);
		return @"";
	}

	for (size_t i = pathCStringLength; i >= 1; i--) {
	for (size_t i = cStringLength; i >= 1; i--) {
		if (cString[i - 1] == '\\' || cString[i - 1] == '/') {
			ret = [[OFString alloc] initWithUTF8String: cString
							    length: i - 1];

			objc_autoreleasePoolPop(pool);

			return [ret autorelease];

Modified src/OFString+PathAdditions_UNIX.m from [a9ea632fbf] to [b277b6a05b].

41
42
43
44
45
46
47


48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64

65
66

67
68
69
70
71

72
73
74
75
76
77
78
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
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







+
+
















-
+

-
+




-
+







		if (!first && ![ret hasSuffix: @"/"])
			[ret appendString: @"/"];

		[ret appendString: component];

		first = false;
	}

	[ret makeImmutable];

	objc_autoreleasePoolPop(pool);

	return ret;
}

- (bool)isAbsolutePath
{
	return [self hasPrefix: @"/"];
}

- (OFArray *)pathComponents
{
	OFMutableArray OF_GENERIC(OFString *) *ret = [OFMutableArray array];
	void *pool = objc_autoreleasePoolPush();
	const char *cString = [self UTF8String];
	size_t i, last = 0, pathCStringLength = [self UTF8StringLength];
	size_t i, last = 0, cStringLength = [self UTF8StringLength];

	if (pathCStringLength == 0) {
	if (cStringLength == 0) {
		objc_autoreleasePoolPop(pool);
		return ret;
	}

	for (i = 0; i < pathCStringLength; i++) {
	for (i = 0; i < cStringLength; i++) {
		if (cString[i] == '/') {
			if (i == 0)
				[ret addObject: @"/"];
			else if (i - last != 0)
				[ret addObject: [OFString
				    stringWithUTF8String: cString + last
						  length: i - last]];
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
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
141
142







-
+



-
+




-
-
+
+

-
+




-
+


-
+














-
+







	return ret;
}

- (OFString *)lastPathComponent
{
	void *pool = objc_autoreleasePoolPush();
	const char *cString = [self UTF8String];
	size_t pathCStringLength = [self UTF8StringLength];
	size_t cStringLength = [self UTF8StringLength];
	ssize_t i;
	OFString *ret;

	if (pathCStringLength == 0) {
	if (cStringLength == 0) {
		objc_autoreleasePoolPop(pool);
		return @"";
	}

	if (cString[pathCStringLength - 1] == '/')
		pathCStringLength--;
	if (cString[cStringLength - 1] == '/')
		cStringLength--;

	if (pathCStringLength == 0) {
	if (cStringLength == 0) {
		objc_autoreleasePoolPop(pool);
		return @"/";
	}

	if (pathCStringLength - 1 > SSIZE_MAX)
	if (cStringLength - 1 > SSIZE_MAX)
		@throw [OFOutOfRangeException exception];

	for (i = pathCStringLength - 1; i >= 0; i--) {
	for (i = cStringLength - 1; i >= 0; i--) {
		if (cString[i] == '/') {
			i++;
			break;
		}
	}

	/*
	 * Only one component, but the trailing delimiter might have been
	 * removed, so return a new string anyway.
	 */
	if (i < 0)
		i = 0;

	ret = [[OFString alloc] initWithUTF8String: cString + i
					    length: pathCStringLength - i];
					    length: cStringLength - i];

	objc_autoreleasePoolPop(pool);

	return [ret autorelease];
}

- (OFString *)pathExtension
159
160
161
162
163
164
165
166

167
168
169

170
171
172
173
174
175


176
177

178
179
180
181
182

183
184
185
186
187
188
189
161
162
163
164
165
166
167

168
169
170

171
172
173
174
175


176
177
178

179
180
181
182
183

184
185
186
187
188
189
190
191







-
+


-
+




-
-
+
+

-
+




-
+







	return [ret autorelease];
}

- (OFString *)stringByDeletingLastPathComponent
{
	void *pool = objc_autoreleasePoolPush();
	const char *cString = [self UTF8String];
	size_t pathCStringLength = [self UTF8StringLength];
	size_t cStringLength = [self UTF8StringLength];
	OFString *ret;

	if (pathCStringLength == 0) {
	if (cStringLength == 0) {
		objc_autoreleasePoolPop(pool);
		return @"";
	}

	if (cString[pathCStringLength - 1] == '/')
		pathCStringLength--;
	if (cString[cStringLength - 1] == '/')
		cStringLength--;

	if (pathCStringLength == 0) {
	if (cStringLength == 0) {
		objc_autoreleasePoolPop(pool);
		return @"/";
	}

	for (size_t i = pathCStringLength; i >= 1; i--) {
	for (size_t i = cStringLength; i >= 1; i--) {
		if (cString[i - 1] == '/') {
			if (i == 1) {
				objc_autoreleasePoolPop(pool);
				return @"/";
			}

			ret = [[OFString alloc] initWithUTF8String: cString

Modified tests/OFStringTests.m from [9cd5a66eea] to [b8eafda052].

556
557
558
559
560
561
562





563
564
565
566
567
568
569
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574







+
+
+
+
+







	TEST(@"-[isAbsolutePath]",
	    [C(@"C:\\foo") isAbsolutePath] && [C(@"a:/foo") isAbsolutePath] &&
	    ![C(@"foo") isAbsolutePath] && ![C(@"b:foo") isAbsolutePath])
# elif defined(OF_AMIGAOS)
	TEST(@"-[isAbsolutePath]",
	    [C(@"dh0:foo") isAbsolutePath] && [C(@"dh0:a/b") isAbsolutePath] &&
	    ![C(@"foo/bar") isAbsolutePath] && ![C(@"foo") isAbsolutePath])
# elif defined(OF_NINTENDO_3DS)
	TEST(@"-[isAbsolutePath]",
	    [C(@"sdmc:/foo") isAbsolutePath] &&
	    ![C(@"sdmc:foo") isAbsolutePath] &&
	    ![C(@"foo/bar") isAbsolutePath] && ![C(@"foo") isAbsolutePath])
# else
	TEST(@"-[isAbsolutePath]",
	    [C(@"/foo") isAbsolutePath] && [C(@"/foo/bar") isAbsolutePath] &&
	    ![C(@"foo/bar") isAbsolutePath] && ![C(@"foo") isAbsolutePath])
# endif

	s[0] = [mutableStringClass stringWithString: @"foo"];
655
656
657
658
659
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
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







+
+
+




-
+
+
+












+
+
+
+
+
+
+
+
+
+
+
+
+
+







	    [a count] == i)

#ifdef OF_HAVE_FILES
# if defined(OF_WINDOWS) || defined(OF_MSDOS)
	TEST(@"+[pathWithComponents:]",
	    [[stringClass pathWithComponents: [OFArray arrayWithObjects:
	    @"foo", @"bar", @"baz", nil]] isEqual: @"foo\\bar\\baz"] &&
	    [[stringClass pathWithComponents: [OFArray arrayWithObjects:
	    @"c:", @"foo", @"bar", @"baz", nil]]
	    isEqual: @"c:\\foo\\bar\\baz"] &&
	    [[stringClass pathWithComponents: [OFArray arrayWithObjects:
	    @"foo/", @"bar\\", @"", @"baz", @"\\", nil]]
	    isEqual: @"foo/bar\\baz"] &&
	    [[stringClass pathWithComponents: [OFArray arrayWithObjects:
	    @"foo", nil]] isEqual: @"foo"])
	    @"foo", nil]] isEqual: @"foo"] &&
	    [[stringClass pathWithComponents: [OFArray arrayWithObject: @"c:"]]
	    isEqual: @"c:\\"])
# elif defined(OF_AMIGAOS)
	TEST(@"+[pathWithComponents:]",
	    [[stringClass pathWithComponents: [OFArray arrayWithObjects:
	    @"dh0:", @"foo", @"bar", @"baz", nil]]
	    isEqual: @"dh0:foo/bar/baz"] &&
	    [[stringClass pathWithComponents: [OFArray arrayWithObjects:
	    @"foo", @"bar", @"baz", nil]] isEqual: @"foo/bar/baz"] &&
	    [[stringClass pathWithComponents: [OFArray arrayWithObjects:
	    @"foo/", @"bar", @"", @"baz", @"/", nil]]
	    isEqual: @"foo//bar/baz//"] &&
	    [[stringClass pathWithComponents: [OFArray arrayWithObjects:
	    @"foo", nil]] isEqual: @"foo"])
# elif defined(OF_NINTENDO_3DS)
	TEST(@"+[pathWithComponents:]",
	    [[stringClass pathWithComponents: [OFArray arrayWithObjects:
	    @"foo", @"bar", @"baz", nil]] isEqual: @"foo/bar/baz"] &&
	    [[stringClass pathWithComponents: [OFArray arrayWithObjects:
	    @"sdmc:", @"foo", @"bar", @"baz", nil]]
	    isEqual: @"sdmc:/foo/bar/baz"] &&
	    [[stringClass pathWithComponents: [OFArray arrayWithObjects:
	    @"foo/", @"bar/", @"", @"baz", @"/", nil]]
	    isEqual: @"foo/bar/baz"] &&
	    [[stringClass pathWithComponents: [OFArray arrayWithObjects:
	    @"foo", nil]] isEqual: @"foo"] &&
	    [[stringClass pathWithComponents: [OFArray arrayWithObject:
	    @"sdmc:"]] isEqual: @"sdmc:/"])
# else
	TEST(@"+[pathWithComponents:]",
	    [[stringClass pathWithComponents: [OFArray arrayWithObjects:
	    @"/", @"foo", @"bar", @"baz", nil]] isEqual: @"/foo/bar/baz"] &&
	    [[stringClass pathWithComponents: [OFArray arrayWithObjects:
	    @"foo", @"bar", @"baz", nil]] isEqual: @"foo/bar/baz"] &&
	    [[stringClass pathWithComponents: [OFArray arrayWithObjects:
739
740
741
742
743
744
745






















746
747
748
749
750
751
752
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798







+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







	    [[a objectAtIndex: 1] isEqual: @"bar"] &&
	    [[a objectAtIndex: 2] isEqual: @"baz"] &&
	    /* foo// */
	    (a = [C(@"foo//") pathComponents]) && [a count] == 2 &&
	    [[a objectAtIndex: 0] isEqual: @"foo"] &&
	    [[a objectAtIndex: 1] isEqual: @"/"] &&
	    [[C(@"") pathComponents] count] == 0)
# elif defined(OF_NINTENDO_3DS)
	TEST(@"-[pathComponents]",
	    /* sdmc:/tmp */
	    (a = [C(@"sdmc:/tmp") pathComponents]) && [a count] == 2 &&
	    [[a objectAtIndex: 0] isEqual: @"sdmc:"] &&
	    [[a objectAtIndex: 1] isEqual: @"tmp"] &&
	    /* sdmc:/ */
	    (a = [C(@"sdmc:/") pathComponents]) && [a count] == 1 &&
	    [[a objectAtIndex: 0] isEqual: @"sdmc:"] &&
	    /* foo/bar */
	    (a = [C(@"foo/bar") pathComponents]) && [a count] == 2 &&
	    [[a objectAtIndex: 0] isEqual: @"foo"] &&
	    [[a objectAtIndex: 1] isEqual: @"bar"] &&
	    /* foo/bar/baz/ */
	    (a = [C(@"foo/bar/baz/") pathComponents]) && [a count] == 3 &&
	    [[a objectAtIndex: 0] isEqual: @"foo"] &&
	    [[a objectAtIndex: 1] isEqual: @"bar"] &&
	    [[a objectAtIndex: 2] isEqual: @"baz"] &&
	    /* foo// */
	    (a = [C(@"foo//") pathComponents]) && [a count] == 1 &&
	    [[a objectAtIndex: 0] isEqual: @"foo"] &&
	    [[C(@"") pathComponents] count] == 0)
# else
	TEST(@"-[pathComponents]",
	    /* /tmp */
	    (a = [C(@"/tmp") pathComponents]) && [a count] == 2 &&
	    [[a objectAtIndex: 0] isEqual: @"/"] &&
	    [[a objectAtIndex: 1] isEqual: @"tmp"] &&
	    /* /tmp/ */
771
772
773
774
775
776
777


778
779
780
781
782
783
784
785
786
787









788
789
790
791
792
793
794
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851







+
+










+
+
+
+
+
+
+
+
+







	    [[C(@"") pathComponents] count] == 0)
# endif

# if defined(OF_WINDOWS) || defined(OF_MSDOS)
	TEST(@"-[lastPathComponent]",
	    [[C(@"c:/tmp") lastPathComponent] isEqual: @"tmp"] &&
	    [[C(@"c:\\tmp\\") lastPathComponent] isEqual: @"tmp"] &&
	    [[C(@"c:\\") lastPathComponent] isEqual: @"c:\\"] &&
	    [[C(@"c:/") lastPathComponent] isEqual: @"c:/"] &&
	    [[C(@"\\") lastPathComponent] isEqual: @""] &&
	    [[C(@"foo") lastPathComponent] isEqual: @"foo"] &&
	    [[C(@"foo\\bar") lastPathComponent] isEqual: @"bar"] &&
	    [[C(@"foo/bar/baz/") lastPathComponent] isEqual: @"baz"])
# elif defined(OF_AMIGAOS)
	TEST(@"-[lastPathComponent]",
	    [[C(@"dh0:tmp") lastPathComponent] isEqual: @"tmp"] &&
	    [[C(@"dh0:tmp/") lastPathComponent] isEqual: @"tmp"] &&
	    [[C(@"dh0:/") lastPathComponent] isEqual: @"/"] &&
	    [[C(@"dh0:") lastPathComponent] isEqual: @"dh0:"] &&
	    [[C(@"foo") lastPathComponent] isEqual: @"foo"] &&
	    [[C(@"foo/bar") lastPathComponent] isEqual: @"bar"] &&
	    [[C(@"foo/bar/baz/") lastPathComponent] isEqual: @"baz"])
# elif defined(OF_NINTENDO_3DS)
	TEST(@"-[lastPathComponent]",
	    [[C(@"sdmc:/tmp") lastPathComponent] isEqual: @"tmp"] &&
	    [[C(@"sdmc:/tmp/") lastPathComponent] isEqual: @"tmp"] &&
	    [[C(@"sdmc:/") lastPathComponent] isEqual: @"sdmc:/"] &&
	    [[C(@"sdmc:") lastPathComponent] isEqual: @"sdmc:"] &&
	    [[C(@"foo") lastPathComponent] isEqual: @"foo"] &&
	    [[C(@"foo/bar") lastPathComponent] isEqual: @"bar"] &&
	    [[C(@"foo/bar/baz/") lastPathComponent] isEqual: @"baz"])
# else
	TEST(@"-[lastPathComponent]",
	    [[C(@"/tmp") lastPathComponent] isEqual: @"tmp"] &&
	    [[C(@"/tmp/") lastPathComponent] isEqual: @"tmp"] &&
804
805
806
807
808
809
810


811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830











831
832
833
834
835
836
837
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907







+
+




















+
+
+
+
+
+
+
+
+
+
+







	    [[C(@"foo/.bar.baz") pathExtension] isEqual: @"baz"] &&
	    [[C(@"foo/bar.baz/") pathExtension] isEqual: @"baz"])

# if defined(OF_WINDOWS) || defined(OF_MSDOS)
	TEST(@"-[stringByDeletingLastPathComponent]",
	    [[C(@"\\tmp") stringByDeletingLastPathComponent] isEqual: @""] &&
	    [[C(@"/tmp/") stringByDeletingLastPathComponent] isEqual: @""] &&
	    [[C(@"c:\\") stringByDeletingLastPathComponent] isEqual: @"c:\\"] &&
	    [[C(@"c:/") stringByDeletingLastPathComponent] isEqual: @"c:/"] &&
	    [[C(@"c:\\tmp/foo/") stringByDeletingLastPathComponent]
	    isEqual: @"c:\\tmp"] &&
	    [[C(@"foo\\bar") stringByDeletingLastPathComponent]
	    isEqual: @"foo"] &&
	    [[C(@"\\") stringByDeletingLastPathComponent] isEqual: @""] &&
	    [[C(@"foo") stringByDeletingLastPathComponent] isEqual: @"."])
# elif defined(OF_AMIGAOS)
	TEST(@"-[stringByDeletingLastPathComponent]",
	    [[C(@"dh0:") stringByDeletingLastPathComponent] isEqual: @"dh0:"] &&
	    [[C(@"dh0:tmp") stringByDeletingLastPathComponent]
	    isEqual: @"dh0:"] &&
	    [[C(@"dh0:tmp/") stringByDeletingLastPathComponent]
	    isEqual: @"dh0:"] &&
	    [[C(@"dh0:/") stringByDeletingLastPathComponent]
	    isEqual: @"dh0:"] &&
	    [[C(@"dh0:tmp/foo/") stringByDeletingLastPathComponent]
	    isEqual: @"dh0:tmp"] &&
	    [[C(@"foo/bar") stringByDeletingLastPathComponent]
	    isEqual: @"foo"] &&
	    [[C(@"foo") stringByDeletingLastPathComponent] isEqual: @""])
# elif defined(OF_NINTENDO_3DS)
	TEST(@"-[stringByDeletingLastPathComponent]",
	    [[C(@"/tmp/") stringByDeletingLastPathComponent] isEqual: @""] &&
	    [[C(@"sdmc:/tmp/foo/") stringByDeletingLastPathComponent]
	    isEqual: @"sdmc:/tmp"] &&
	    [[C(@"sdmc:/") stringByDeletingLastPathComponent]
	    isEqual: @"sdmc:/"] &&
	    [[C(@"foo/bar") stringByDeletingLastPathComponent]
	    isEqual: @"foo"] &&
	    [[C(@"/") stringByDeletingLastPathComponent] isEqual: @""] &&
	    [[C(@"foo") stringByDeletingLastPathComponent] isEqual: @"."])
# else
	TEST(@"-[stringByDeletingLastPathComponent]",
	    [[C(@"/tmp") stringByDeletingLastPathComponent] isEqual: @"/"] &&
	    [[C(@"/tmp/") stringByDeletingLastPathComponent] isEqual: @"/"] &&
	    [[C(@"/tmp/foo/") stringByDeletingLastPathComponent]
	    isEqual: @"/tmp"] &&
	    [[C(@"foo/bar") stringByDeletingLastPathComponent]
862
863
864
865
866
867
868











869
870
871
872
873
874
875
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956







+
+
+
+
+
+
+
+
+
+
+







	    [[C(@"dh0:foo./bar.baz") stringByDeletingPathExtension]
	    isEqual: @"dh0:foo./bar"] &&
	    [[C(@"foo.bar/") stringByDeletingPathExtension] isEqual: @"foo"] &&
	    [[C(@".foo") stringByDeletingPathExtension] isEqual: @".foo"] &&
	    [[C(@".foo\\bar") stringByDeletingPathExtension]
	    isEqual: @".foo\\bar"] &&
	    [[C(@".foo.bar") stringByDeletingPathExtension] isEqual: @".foo"])
# elif defined(OF_NINTENDO_3DS)
	TEST(@"-[stringByDeletingPathExtension]",
	    [[C(@"foo.bar") stringByDeletingPathExtension] isEqual: @"foo"] &&
	    [[C(@"foo..bar") stringByDeletingPathExtension] isEqual: @"foo."] &&
	    [[C(@"sdmc:/foo./bar") stringByDeletingPathExtension]
	    isEqual: @"sdmc:/foo./bar"] &&
	    [[C(@"sdmc:/foo./bar.baz") stringByDeletingPathExtension]
	    isEqual: @"sdmc:/foo./bar"] &&
	    [[C(@"foo.bar/") stringByDeletingPathExtension] isEqual: @"foo"] &&
	    [[C(@".foo") stringByDeletingPathExtension] isEqual: @".foo"] &&
	    [[C(@".foo.bar") stringByDeletingPathExtension] isEqual: @".foo"])
# else
	TEST(@"-[stringByDeletingPathExtension]",
	    [[C(@"foo.bar") stringByDeletingPathExtension] isEqual: @"foo"] &&
	    [[C(@"foo..bar") stringByDeletingPathExtension] isEqual: @"foo."] &&
	    [[C(@"/foo./bar") stringByDeletingPathExtension]
	    isEqual: @"/foo./bar"] &&
	    [[C(@"/foo./bar.baz") stringByDeletingPathExtension]