author | Claus Gittinger <cg@exept.de> |
Thu, 09 Jun 2016 18:09:58 +0200 | |
changeset 3934 | 3fc6968232c1 |
parent 1992 | be159b5be71f |
child 4181 | d7d3be3e8f19 |
permissions | -rw-r--r-- |
1309 | 1 |
" |
2 |
COPYRIGHT (c) 2002 by eXept Software AG |
|
3 |
All Rights Reserved |
|
4 |
||
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
1005 | 12 |
"{ Package: 'stx:libbasic2' }" |
13 |
||
14 |
URI subclass:#HierarchicalURI |
|
1257 | 15 |
instanceVariableNames:'authority isAbsolute isDirectory pathSegments query fragment' |
1005 | 16 |
classVariableNames:'' |
17 |
poolDictionaries:'' |
|
1310 | 18 |
category:'Net-Resources' |
1005 | 19 |
! |
20 |
||
21 |
!HierarchicalURI class methodsFor:'documentation'! |
|
22 |
||
1309 | 23 |
copyright |
24 |
" |
|
25 |
COPYRIGHT (c) 2002 by eXept Software AG |
|
26 |
All Rights Reserved |
|
27 |
||
28 |
This software is furnished under a license and may be used |
|
29 |
only in accordance with the terms of that license and with the |
|
30 |
inclusion of the above copyright notice. This software may not |
|
31 |
be provided or otherwise made available to, or used by, any |
|
32 |
other person. No title to or ownership of the software is |
|
33 |
hereby transferred. |
|
34 |
" |
|
35 |
! |
|
36 |
||
1005 | 37 |
documentation |
38 |
" |
|
39 |
Hierarchical URI as defined in RFC2396: |
|
40 |
||
41 |
<scheme:[//authority][/absolute_path][?query][#fragment]> |
|
42 |
||
43 |
[author:] |
|
44 |
Stefan Vogel (stefan@zwerg) |
|
45 |
||
46 |
[see also:] |
|
47 |
||
48 |
[instance variables:] |
|
49 |
||
50 |
[class variables:] |
|
51 |
" |
|
52 |
! |
|
53 |
||
54 |
examples |
|
55 |
" |
|
56 |
||
57 |
more examples to be added: |
|
58 |
[exBegin] |
|
1254 | 59 |
|u1 u2| |
60 |
||
61 |
u1 := URI fromString:'file:/phys/exept/tmp/'. |
|
62 |
u2 := u1 construct:'test.txt'. |
|
63 |
Transcript showCR:u1. |
|
64 |
Transcript showCR:u2. |
|
65 |
[exEnd] |
|
66 |
||
67 |
[exBegin] |
|
68 |
|u1 u2| |
|
69 |
||
70 |
u1 := URI fromString:'file:/phys/exept/tmp'. |
|
71 |
u2 := u1 construct:'test.txt'. |
|
72 |
Transcript showCR:u1. |
|
73 |
Transcript showCR:u2. |
|
1005 | 74 |
[exEnd] |
75 |
" |
|
76 |
! ! |
|
77 |
||
78 |
!HierarchicalURI class methodsFor:'instance creation'! |
|
79 |
||
80 |
new |
|
81 |
||
82 |
^ self basicNew initialize |
|
83 |
! |
|
84 |
||
85 |
scheme:aSchemeString fromString:aString |
|
86 |
"parse the hierarchical information. |
|
87 |
schemeString is ignored here" |
|
88 |
||
89 |
^ self new scheme:aSchemeString; |
|
90 |
fromString:aString |
|
91 |
! ! |
|
92 |
||
93 |
!HierarchicalURI methodsFor:'accessing'! |
|
94 |
||
95 |
authority |
|
96 |
"return the value of the instance variable 'authority' (automatically generated)" |
|
97 |
||
98 |
^ authority |
|
99 |
! |
|
100 |
||
101 |
authority:something |
|
102 |
"set the value of the instance variable 'authority' (automatically generated)" |
|
103 |
||
104 |
authority := something. |
|
105 |
! |
|
106 |
||
1271
ca2e206e7c7f
Working version: tilde-expansion, patterns
Stefan Vogel <sv@exept.de>
parents:
1268
diff
changeset
|
107 |
baseName |
ca2e206e7c7f
Working version: tilde-expansion, patterns
Stefan Vogel <sv@exept.de>
parents:
1268
diff
changeset
|
108 |
^ pathSegments last |
1520 | 109 |
|
110 |
" |
|
111 |
(URI fromString:'file:/phys/exept/tmp/foo.html') baseName. |
|
112 |
(URI fromString:'file:/phys/exept/tmp/foo') baseName. |
|
113 |
(URI fromString:'file:/phys/exept/tmp/') baseName. |
|
114 |
(URI fromString:'file:/phys/') baseName. |
|
115 |
(URI fromString:'file:/phys') baseName. |
|
116 |
||
117 |
(URI fromString:'file://phys/exept/tmp/foo.html') baseName. |
|
118 |
(URI fromString:'file://phys/exept/tmp/foo') baseName. |
|
119 |
(URI fromString:'file://phys/exept/tmp/') baseName. |
|
120 |
(URI fromString:'file://phys/exept/tmp') baseName. |
|
121 |
(URI fromString:'file://phys/exept/') baseName. |
|
122 |
(URI fromString:'file://phys/exept') baseName. |
|
123 |
(URI fromString:'file://phys/') baseName. |
|
124 |
(URI fromString:'file://phys') baseName. |
|
125 |
(URI fromString:'file://') baseName. |
|
126 |
" |
|
1271
ca2e206e7c7f
Working version: tilde-expansion, patterns
Stefan Vogel <sv@exept.de>
parents:
1268
diff
changeset
|
127 |
! |
ca2e206e7c7f
Working version: tilde-expansion, patterns
Stefan Vogel <sv@exept.de>
parents:
1268
diff
changeset
|
128 |
|
1254 | 129 |
examples |
130 |
" |
|
131 |
||
132 |
more examples to be added: |
|
133 |
[exBegin] |
|
134 |
URI fromString:'file:/phys/exept/home/tm/tmp' |
|
135 |
[exEnd] |
|
136 |
" |
|
137 |
! |
|
138 |
||
1005 | 139 |
fragment |
140 |
"return the value of the instance variable 'fragment' (automatically generated)" |
|
141 |
||
142 |
^ fragment |
|
143 |
! |
|
144 |
||
145 |
fragment:something |
|
146 |
"set the value of the instance variable 'fragment' (automatically generated)" |
|
147 |
||
148 |
fragment := something. |
|
149 |
! |
|
150 |
||
151 |
isAbsolute |
|
152 |
"return the value of the instance variable 'isAbsolute' (automatically generated)" |
|
153 |
||
154 |
^ isAbsolute |
|
155 |
! |
|
156 |
||
1257 | 157 |
isDirectory |
158 |
"return the value of the instance variable 'isDirectory' (automatically generated)" |
|
159 |
||
160 |
^ isDirectory ? false |
|
161 |
! |
|
162 |
||
1271
ca2e206e7c7f
Working version: tilde-expansion, patterns
Stefan Vogel <sv@exept.de>
parents:
1268
diff
changeset
|
163 |
pathSegments |
ca2e206e7c7f
Working version: tilde-expansion, patterns
Stefan Vogel <sv@exept.de>
parents:
1268
diff
changeset
|
164 |
"return the value of the instance variable 'pathSegments' (automatically generated)" |
1005 | 165 |
|
166 |
^ pathSegments |
|
167 |
! |
|
168 |
||
1271
ca2e206e7c7f
Working version: tilde-expansion, patterns
Stefan Vogel <sv@exept.de>
parents:
1268
diff
changeset
|
169 |
pathSegments:something |
ca2e206e7c7f
Working version: tilde-expansion, patterns
Stefan Vogel <sv@exept.de>
parents:
1268
diff
changeset
|
170 |
"set the value of the instance variable 'pathSegments' (automatically generated)" |
1005 | 171 |
|
172 |
pathSegments := something. |
|
173 |
! |
|
174 |
||
175 |
query |
|
176 |
"return the value of the instance variable 'query' (automatically generated)" |
|
177 |
||
178 |
^ query |
|
179 |
! |
|
180 |
||
181 |
query:something |
|
182 |
"set the value of the instance variable 'query' (automatically generated)" |
|
183 |
||
184 |
query := something. |
|
185 |
! ! |
|
186 |
||
187 |
!HierarchicalURI methodsFor:'accessing-details'! |
|
188 |
||
189 |
host |
|
190 |
"answer the host part of authority" |
|
191 |
||
192 |
|start end| |
|
193 |
||
194 |
authority isNil ifTrue:[ |
|
195 |
^ nil |
|
196 |
]. |
|
197 |
start := (authority indexOf:$@) + 1. |
|
198 |
end := (authority indexOf:$: startingAt:start) - 1. |
|
199 |
end == -1 ifTrue:[ |
|
200 |
end := authority size |
|
201 |
]. |
|
202 |
^ authority copyFrom:start to:end |
|
203 |
||
204 |
" |
|
205 |
(self fromString:'ftp://stefan@www.exept.de:80/test') host |
|
206 |
(self fromString:'ftp://www.exept.de:80/test') host |
|
207 |
(self fromString:'ftp://www.exept.de/test') host |
|
208 |
" |
|
209 |
! |
|
210 |
||
211 |
password |
|
212 |
"answer the user part of authority" |
|
213 |
||
214 |
|end start| |
|
215 |
||
216 |
authority isNil ifTrue:[ |
|
217 |
^ nil |
|
218 |
]. |
|
219 |
end := authority indexOf:$@. |
|
220 |
end == 0 ifTrue:[ |
|
221 |
^ nil |
|
222 |
]. |
|
223 |
start := authority indexOf:$:. |
|
224 |
(start == 0 or:[start > end]) ifTrue:[ |
|
225 |
^ nil |
|
226 |
]. |
|
227 |
^ authority copyFrom:start+1 to:end-1 |
|
228 |
||
229 |
" |
|
230 |
(self fromString:'ftp://stefan@www.exept.de:80/test') password |
|
231 |
(self fromString:'ftp://stefan:pass@www.exept.de:80/test') password |
|
232 |
(self fromString:'ftp://www.exept.de:80/test') password |
|
233 |
" |
|
234 |
! |
|
235 |
||
236 |
port |
|
237 |
"answer the port part of authority" |
|
238 |
||
239 |
|start| |
|
240 |
||
241 |
authority isNil ifTrue:[ |
|
242 |
^ self defaultPort |
|
243 |
]. |
|
1992 | 244 |
start := authority indexOf:$@ ifAbsent:1. |
1005 | 245 |
start := authority indexOf:$: startingAt:start. |
1992 | 246 |
|
1005 | 247 |
start == 0 ifTrue:[ |
248 |
^ self defaultPort |
|
249 |
]. |
|
250 |
||
251 |
^ authority copyFrom:start+1 |
|
252 |
||
253 |
" |
|
1992 | 254 |
(self fromString:'ftp://stefan@www.exept.de:80/test') port |
255 |
(self fromString:'ftp://www.exept.de:80/test') port |
|
256 |
(self fromString:'ftp://www.exept.de/test') port |
|
1005 | 257 |
" |
258 |
! |
|
259 |
||
260 |
user |
|
261 |
"answer the user part of authority" |
|
262 |
||
263 |
|end end1| |
|
264 |
||
265 |
authority isNil ifTrue:[ |
|
266 |
^ nil |
|
267 |
]. |
|
268 |
end := authority indexOf:$@. |
|
269 |
end == 0 ifTrue:[ |
|
270 |
^ nil |
|
271 |
]. |
|
272 |
end1 := authority indexOf:$:. |
|
273 |
end1 ~~ 0 ifTrue:[ |
|
274 |
end := end min:end1. |
|
275 |
]. |
|
276 |
^ authority copyTo:end-1 |
|
277 |
||
278 |
" |
|
279 |
(self fromString:'ftp://stefan@www.exept.de:80/test') user |
|
280 |
(self fromString:'ftp://stefan:pass@www.exept.de:80/test') user |
|
281 |
(self fromString:'ftp://www.exept.de:80/test') user |
|
282 |
" |
|
283 |
! ! |
|
284 |
||
1289 | 285 |
!HierarchicalURI methodsFor:'comparing'! |
286 |
||
287 |
= anHierarchicalUri |
|
288 |
||
289 |
^ self class == anHierarchicalUri class |
|
290 |
and:[self scheme = anHierarchicalUri scheme |
|
291 |
and:[pathSegments = anHierarchicalUri pathSegments |
|
292 |
and:[authority = anHierarchicalUri authority |
|
293 |
and:[self isAbsolute = anHierarchicalUri isAbsolute |
|
294 |
and:[self isDirectory = anHierarchicalUri isDirectory |
|
295 |
and:[query = anHierarchicalUri query |
|
296 |
and:[fragment = anHierarchicalUri fragment]]]]]]] |
|
297 |
! |
|
298 |
||
299 |
hash |
|
300 |
||
301 |
^ pathSegments hash xor:query hash |
|
302 |
! ! |
|
303 |
||
1254 | 304 |
!HierarchicalURI methodsFor:'copying'! |
305 |
||
306 |
postCopy |
|
307 |
||
308 |
pathSegments := pathSegments copy |
|
309 |
! ! |
|
310 |
||
1005 | 311 |
!HierarchicalURI methodsFor:'defaults'! |
312 |
||
313 |
defaultPort |
|
314 |
"answer the default port for the given scheme. |
|
315 |
Concrete subclasses redefine this method" |
|
316 |
||
317 |
^ nil |
|
318 |
! ! |
|
319 |
||
320 |
!HierarchicalURI methodsFor:'escape'! |
|
321 |
||
322 |
unEscape |
|
323 |
"convert escaped characters (such as %20 for ' ') to their native |
|
324 |
representation" |
|
325 |
||
326 |
authority := self class unEscape:authority readStream. |
|
327 |
pathSegments keysAndValuesDo:[:i :v| |
|
328 |
pathSegments at:i put:(self class unEscape:v readStream). |
|
329 |
]. |
|
330 |
query := self class unEscape:query readStream. |
|
331 |
fragment := self class unEscape:fragment readStream. |
|
332 |
! ! |
|
333 |
||
1374 | 334 |
!HierarchicalURI methodsFor:'initialization'! |
1005 | 335 |
|
336 |
fromString:aString |
|
337 |
||
338 |
|i i1 separator| |
|
339 |
||
340 |
(aString startsWith:'//') ifTrue:[ |
|
1268 | 341 |
i := aString indexOfAny:'/?#' startingAt:3. |
1005 | 342 |
i == 0 ifTrue:[ |
343 |
authority := aString copyFrom:3. |
|
344 |
^ self. |
|
345 |
] ifFalse:[ |
|
346 |
separator := aString at:i. |
|
347 |
authority := aString copyFrom:3 to:i-1. |
|
348 |
]. |
|
1267 | 349 |
(isAbsolute := (aString at:i) == $/). |
1005 | 350 |
] ifFalse:[ |
351 |
(isAbsolute := aString startsWith:$/) ifTrue:[ |
|
352 |
i := 1. |
|
353 |
] ifFalse:[ |
|
354 |
i := 0. |
|
355 |
] |
|
356 |
]. |
|
357 |
||
358 |
[ |
|
359 |
i1 := aString indexOfAny:'/?#' startingAt:i+1. |
|
1254 | 360 |
i1 == 0 ifTrue:[ |path| |
361 |
path := aString copyFrom:i+1. |
|
362 |
path size ~~ 0 ifTrue:[ |
|
363 |
pathSegments add:path. |
|
1257 | 364 |
] ifFalse:[ |
365 |
(aString at:i) == $/ ifTrue:[ |
|
366 |
isDirectory := true |
|
367 |
]. |
|
1254 | 368 |
]. |
1005 | 369 |
^ self. |
370 |
] ifFalse:[ |
|
371 |
separator := aString at:i1. |
|
372 |
pathSegments add:(aString copyFrom:i+1 to:i1-1). |
|
1267 | 373 |
isAbsolute ifTrue:[ |
374 |
pathSegments size == 1 ifTrue:[ |
|
1268 | 375 |
(pathSegments first startsWith:$~) ifTrue:[ |
1267 | 376 |
isAbsolute := false |
377 |
]. |
|
378 |
]. |
|
379 |
]. |
|
1005 | 380 |
i := i1. |
381 |
]. |
|
382 |
] doWhile:[separator == $/]. |
|
383 |
||
384 |
separator == $? ifTrue:[ |
|
385 |
i1 := aString indexOf:$# startingAt:i+1. |
|
386 |
i1 == 0 ifTrue:[ |
|
387 |
query := aString copyFrom:i+1. |
|
388 |
^ self. |
|
389 |
] ifFalse:[ |
|
390 |
separator := aString at:i1. |
|
391 |
query := aString copyFrom:i+1 to:i1-1. |
|
392 |
i := i1. |
|
393 |
]. |
|
394 |
]. |
|
395 |
separator == $# ifTrue:[ |
|
396 |
fragment := aString copyFrom:i+1. |
|
397 |
]. |
|
398 |
||
399 |
" |
|
1267 | 400 |
self new fromString:'//exept~/tmp' |
401 |
self new fromString:'~/tmp' |
|
402 |
self new fromString:'/~/tmp' |
|
1257 | 403 |
self new fromString:'//authority/path1/path2/' |
1005 | 404 |
self new fromString:'//authority/path1/path2?query' |
405 |
self new fromString:'//authority/path1/path2?query#fragment' |
|
406 |
self new fromString:'/path1/path2?query#fragment' |
|
407 |
self new fromString:'/path1/path2#fragment' |
|
408 |
self new fromString:'path1/path2#fragment' |
|
409 |
" |
|
410 |
! |
|
411 |
||
412 |
initialize |
|
413 |
||
414 |
pathSegments := OrderedCollection new. |
|
415 |
! ! |
|
416 |
||
417 |
!HierarchicalURI methodsFor:'printing & storing'! |
|
418 |
||
1268 | 419 |
directoryPath |
420 |
"answer the directory path part of the URI" |
|
421 |
||
422 |
|aStream| |
|
423 |
||
424 |
aStream := WriteStream on:''. |
|
425 |
||
426 |
pathSegments size ~~ 0 ifTrue: [ |
|
427 |
self isAbsolute ifTrue:[ |
|
428 |
aStream nextPut:$/. |
|
429 |
]. |
|
430 |
pathSegments size > 1 ifTrue:[ |
|
1271
ca2e206e7c7f
Working version: tilde-expansion, patterns
Stefan Vogel <sv@exept.de>
parents:
1268
diff
changeset
|
431 |
(pathSegments copyTo:pathSegments size-1) do:[:p| |
1268 | 432 |
self class escape:p allow:'~;:@&=+",' on:aStream |
433 |
] separatedBy:[ |
|
434 |
aStream nextPut:$/ |
|
435 |
]. |
|
436 |
]. |
|
437 |
]. |
|
438 |
||
439 |
^ aStream contents |
|
440 |
! |
|
441 |
||
1005 | 442 |
path |
443 |
"answer the path part of the URI" |
|
444 |
||
445 |
|aStream| |
|
446 |
||
447 |
aStream := WriteStream on:''. |
|
448 |
||
449 |
pathSegments size ~~ 0 ifTrue: [ |
|
1268 | 450 |
self isAbsolute ifTrue:[ |
1005 | 451 |
aStream nextPut:$/. |
452 |
]. |
|
453 |
pathSegments do:[:p| |
|
1268 | 454 |
self class escape:p allow:'~;:@&=+",' on:aStream |
1005 | 455 |
] separatedBy:[ |
456 |
aStream nextPut:$/ |
|
457 |
]. |
|
458 |
]. |
|
459 |
query notNil ifTrue: [ |
|
460 |
aStream nextPut:$?. |
|
461 |
self class escape:query allow:nil on:aStream |
|
462 |
]. |
|
463 |
fragment notNil ifTrue: [ |
|
464 |
aStream nextPut:$#. |
|
465 |
self class escape:fragment allow:nil on:aStream |
|
466 |
]. |
|
467 |
||
468 |
^ aStream contents |
|
469 |
! |
|
470 |
||
471 |
printOn:aStream |
|
472 |
||
473 |
self printOn:aStream escape:false |
|
474 |
! |
|
475 |
||
476 |
printOn:aStream escape:doEscape |
|
477 |
"print the URI on aStream. If doEscape is set, escape special |
|
478 |
characters" |
|
479 |
||
480 |
super printOn:aStream. |
|
481 |
authority notNil ifTrue: [ |
|
482 |
aStream nextPutAll:'//'. |
|
483 |
doEscape ifTrue:[ |
|
1268 | 484 |
self class escape:authority allow:'~$,;:@&=+' on:aStream |
1005 | 485 |
] ifFalse:[ |
486 |
aStream nextPutAll:authority |
|
487 |
] |
|
488 |
]. |
|
1276 | 489 |
|
490 |
self printPathOn:aStream escape:doEscape. |
|
491 |
! |
|
492 |
||
493 |
printPathOn:aStream escape:doEscape |
|
494 |
"print the path part" |
|
495 |
||
1005 | 496 |
pathSegments size ~~ 0 ifTrue: [ |
1268 | 497 |
self isAbsolute ifTrue:[ |
1005 | 498 |
aStream nextPut:$/. |
499 |
]. |
|
500 |
pathSegments do:[:p| |
|
501 |
doEscape ifTrue:[ |
|
1268 | 502 |
self class escape:p allow:'~;:@&=+",' on:aStream |
1005 | 503 |
] ifFalse:[ |
504 |
aStream nextPutAll:p |
|
505 |
] |
|
506 |
] separatedBy:[ |
|
507 |
aStream nextPut:$/ |
|
508 |
]. |
|
509 |
]. |
|
510 |
query notNil ifTrue: [ |
|
511 |
aStream nextPut:$?. |
|
512 |
doEscape ifTrue:[ |
|
513 |
self class escape:query allow:nil on:aStream |
|
514 |
] ifFalse:[ |
|
515 |
aStream nextPutAll:query |
|
516 |
] |
|
517 |
||
518 |
]. |
|
519 |
fragment notNil ifTrue: [ |
|
520 |
aStream nextPut:$#. |
|
521 |
doEscape ifTrue:[ |
|
522 |
self class escape:fragment allow:nil on:aStream |
|
523 |
] ifFalse:[ |
|
524 |
aStream nextPutAll:fragment |
|
525 |
] |
|
526 |
]. |
|
1276 | 527 |
! |
528 |
||
529 |
publicPrintOn:aStream |
|
530 |
"print, but omit password information" |
|
531 |
||
532 |
|password| |
|
533 |
||
534 |
password := self password. |
|
535 |
password size ~~ 0 ifTrue:[ |
|
1277 | 536 |
super printOn:aStream. |
1276 | 537 |
aStream |
538 |
nextPutAll:'//'; |
|
539 |
nextPutAll:self user; |
|
540 |
nextPut:$@; |
|
541 |
nextPutAll:self host. |
|
1277 | 542 |
self printPathOn:aStream escape:true. |
543 |
] ifFalse:[ |
|
544 |
"no password, use normal printing" |
|
545 |
self printOn:aStream |
|
1276 | 546 |
]. |
1005 | 547 |
! ! |
548 |
||
549 |
!HierarchicalURI methodsFor:'resolution'! |
|
550 |
||
1962
b2044230fdc4
added #'/' (synonym of #construct:)
Stefan Vogel <sv@exept.de>
parents:
1520
diff
changeset
|
551 |
/ aString |
b2044230fdc4
added #'/' (synonym of #construct:)
Stefan Vogel <sv@exept.de>
parents:
1520
diff
changeset
|
552 |
"concatenate aString to my path. |
b2044230fdc4
added #'/' (synonym of #construct:)
Stefan Vogel <sv@exept.de>
parents:
1520
diff
changeset
|
553 |
Same as #construct:, but simpler to use" |
b2044230fdc4
added #'/' (synonym of #construct:)
Stefan Vogel <sv@exept.de>
parents:
1520
diff
changeset
|
554 |
|
b2044230fdc4
added #'/' (synonym of #construct:)
Stefan Vogel <sv@exept.de>
parents:
1520
diff
changeset
|
555 |
^ self construct:aString. |
b2044230fdc4
added #'/' (synonym of #construct:)
Stefan Vogel <sv@exept.de>
parents:
1520
diff
changeset
|
556 |
! |
b2044230fdc4
added #'/' (synonym of #construct:)
Stefan Vogel <sv@exept.de>
parents:
1520
diff
changeset
|
557 |
|
1005 | 558 |
addComponent:aString |
559 |
"concatenate aString to my path" |
|
560 |
||
561 |
(aString = '..' |
|
562 |
and:[pathSegments size ~~ 0 |
|
1271
ca2e206e7c7f
Working version: tilde-expansion, patterns
Stefan Vogel <sv@exept.de>
parents:
1268
diff
changeset
|
563 |
and:[pathSegments last ~= '..']]) ifTrue:[ |
1005 | 564 |
pathSegments removeLast. |
565 |
] ifFalse:[ |
|
566 |
pathSegments add:aString |
|
567 |
]. |
|
568 |
! |
|
569 |
||
570 |
construct:aString |
|
1271
ca2e206e7c7f
Working version: tilde-expansion, patterns
Stefan Vogel <sv@exept.de>
parents:
1268
diff
changeset
|
571 |
"concatenate aString to my path" |
1005 | 572 |
|
573 |
^ self copy |
|
574 |
addComponent:aString; |
|
575 |
yourself. |
|
1271
ca2e206e7c7f
Working version: tilde-expansion, patterns
Stefan Vogel <sv@exept.de>
parents:
1268
diff
changeset
|
576 |
! |
ca2e206e7c7f
Working version: tilde-expansion, patterns
Stefan Vogel <sv@exept.de>
parents:
1268
diff
changeset
|
577 |
|
ca2e206e7c7f
Working version: tilde-expansion, patterns
Stefan Vogel <sv@exept.de>
parents:
1268
diff
changeset
|
578 |
directory |
ca2e206e7c7f
Working version: tilde-expansion, patterns
Stefan Vogel <sv@exept.de>
parents:
1268
diff
changeset
|
579 |
"remove the last path component" |
ca2e206e7c7f
Working version: tilde-expansion, patterns
Stefan Vogel <sv@exept.de>
parents:
1268
diff
changeset
|
580 |
|
ca2e206e7c7f
Working version: tilde-expansion, patterns
Stefan Vogel <sv@exept.de>
parents:
1268
diff
changeset
|
581 |
^ self copy |
ca2e206e7c7f
Working version: tilde-expansion, patterns
Stefan Vogel <sv@exept.de>
parents:
1268
diff
changeset
|
582 |
removeLastComponent; |
ca2e206e7c7f
Working version: tilde-expansion, patterns
Stefan Vogel <sv@exept.de>
parents:
1268
diff
changeset
|
583 |
yourself. |
ca2e206e7c7f
Working version: tilde-expansion, patterns
Stefan Vogel <sv@exept.de>
parents:
1268
diff
changeset
|
584 |
! |
ca2e206e7c7f
Working version: tilde-expansion, patterns
Stefan Vogel <sv@exept.de>
parents:
1268
diff
changeset
|
585 |
|
ca2e206e7c7f
Working version: tilde-expansion, patterns
Stefan Vogel <sv@exept.de>
parents:
1268
diff
changeset
|
586 |
removeLastComponent |
ca2e206e7c7f
Working version: tilde-expansion, patterns
Stefan Vogel <sv@exept.de>
parents:
1268
diff
changeset
|
587 |
"remove the last component" |
ca2e206e7c7f
Working version: tilde-expansion, patterns
Stefan Vogel <sv@exept.de>
parents:
1268
diff
changeset
|
588 |
|
ca2e206e7c7f
Working version: tilde-expansion, patterns
Stefan Vogel <sv@exept.de>
parents:
1268
diff
changeset
|
589 |
pathSegments size ~~ 0 ifTrue:[ |
ca2e206e7c7f
Working version: tilde-expansion, patterns
Stefan Vogel <sv@exept.de>
parents:
1268
diff
changeset
|
590 |
pathSegments last = '..' ifTrue:[ |
ca2e206e7c7f
Working version: tilde-expansion, patterns
Stefan Vogel <sv@exept.de>
parents:
1268
diff
changeset
|
591 |
pathSegments add:'..'. |
ca2e206e7c7f
Working version: tilde-expansion, patterns
Stefan Vogel <sv@exept.de>
parents:
1268
diff
changeset
|
592 |
] ifFalse:[ |
ca2e206e7c7f
Working version: tilde-expansion, patterns
Stefan Vogel <sv@exept.de>
parents:
1268
diff
changeset
|
593 |
pathSegments removeLast. |
ca2e206e7c7f
Working version: tilde-expansion, patterns
Stefan Vogel <sv@exept.de>
parents:
1268
diff
changeset
|
594 |
]. |
ca2e206e7c7f
Working version: tilde-expansion, patterns
Stefan Vogel <sv@exept.de>
parents:
1268
diff
changeset
|
595 |
]. |
1005 | 596 |
! ! |
597 |
||
598 |
!HierarchicalURI class methodsFor:'documentation'! |
|
599 |
||
600 |
version |
|
1992 | 601 |
^ '$Header: /cvs/stx/stx/libbasic2/HierarchicalURI.st,v 1.15 2008-05-15 13:32:05 mb Exp $' |
1005 | 602 |
! ! |