author | Stefan Vogel <sv@exept.de> |
Sat, 30 Oct 2004 16:34:04 +0200 | |
changeset 8625 | 0e0637c66519 |
parent 8548 | 19253a6783ce |
child 8661 | 2a7e152604fb |
permissions | -rw-r--r-- |
3336 | 1 |
" |
2 |
COPYRIGHT (c) 1997 by eXept Software AG |
|
3570 | 3 |
All Rights Reserved |
3336 | 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 |
" |
|
12 |
||
5826 | 13 |
"{ Package: 'stx:libbasic' }" |
14 |
||
3336 | 15 |
Filename subclass:#PCFilename |
16 |
instanceVariableNames:'' |
|
17 |
classVariableNames:'StandardSuffixTable' |
|
18 |
poolDictionaries:'' |
|
3708
27a62fa7b5bb
in #isVolumeAbsolute: care for filenames of the form: \hostname
Claus Gittinger <cg@exept.de>
parents:
3570
diff
changeset
|
19 |
category:'OS-Windows' |
27a62fa7b5bb
in #isVolumeAbsolute: care for filenames of the form: \hostname
Claus Gittinger <cg@exept.de>
parents:
3570
diff
changeset
|
20 |
! |
27a62fa7b5bb
in #isVolumeAbsolute: care for filenames of the form: \hostname
Claus Gittinger <cg@exept.de>
parents:
3570
diff
changeset
|
21 |
|
27a62fa7b5bb
in #isVolumeAbsolute: care for filenames of the form: \hostname
Claus Gittinger <cg@exept.de>
parents:
3570
diff
changeset
|
22 |
!PCFilename class methodsFor:'documentation'! |
27a62fa7b5bb
in #isVolumeAbsolute: care for filenames of the form: \hostname
Claus Gittinger <cg@exept.de>
parents:
3570
diff
changeset
|
23 |
|
3336 | 24 |
copyright |
25 |
" |
|
26 |
COPYRIGHT (c) 1997 by eXept Software AG |
|
3570 | 27 |
All Rights Reserved |
3336 | 28 |
|
29 |
This software is furnished under a license and may be used |
|
30 |
only in accordance with the terms of that license and with the |
|
31 |
inclusion of the above copyright notice. This software may not |
|
32 |
be provided or otherwise made available to, or used by, any |
|
33 |
other person. No title to or ownership of the software is |
|
34 |
hereby transferred. |
|
35 |
" |
|
3708
27a62fa7b5bb
in #isVolumeAbsolute: care for filenames of the form: \hostname
Claus Gittinger <cg@exept.de>
parents:
3570
diff
changeset
|
36 |
! |
27a62fa7b5bb
in #isVolumeAbsolute: care for filenames of the form: \hostname
Claus Gittinger <cg@exept.de>
parents:
3570
diff
changeset
|
37 |
|
3336 | 38 |
documentation |
39 |
" |
|
40 |
Filenames in Windows-NT / Win95. |
|
41 |
" |
|
3708
27a62fa7b5bb
in #isVolumeAbsolute: care for filenames of the form: \hostname
Claus Gittinger <cg@exept.de>
parents:
3570
diff
changeset
|
42 |
! ! |
27a62fa7b5bb
in #isVolumeAbsolute: care for filenames of the form: \hostname
Claus Gittinger <cg@exept.de>
parents:
3570
diff
changeset
|
43 |
|
27a62fa7b5bb
in #isVolumeAbsolute: care for filenames of the form: \hostname
Claus Gittinger <cg@exept.de>
parents:
3570
diff
changeset
|
44 |
!PCFilename class methodsFor:'initialization'! |
27a62fa7b5bb
in #isVolumeAbsolute: care for filenames of the form: \hostname
Claus Gittinger <cg@exept.de>
parents:
3570
diff
changeset
|
45 |
|
3336 | 46 |
initStandardSuffixTable |
47 |
"since there is no 'file' command to extract the type, |
|
48 |
return a guess based upon the files suffix. The following |
|
49 |
table defines what is returned." |
|
50 |
||
51 |
StandardSuffixTable := Dictionary new. |
|
52 |
#( |
|
3570 | 53 |
'COM' 'executable' |
54 |
'DIR' 'directory' |
|
55 |
'EXE' 'executable' |
|
56 |
'LST' 'listing' |
|
57 |
'OBJ' 'object file' |
|
58 |
'TMP' 'temporary' |
|
59 |
'BAS' 'basic source' |
|
60 |
'C' 'c source' |
|
61 |
'COB' 'cobol source' |
|
62 |
'FOR' 'fortran source' |
|
63 |
'PAS' 'pascal source' |
|
64 |
'PL1' 'PL/1 source' |
|
65 |
'ST' 'smalltalk source' |
|
66 |
'STH' 'stc generated header' |
|
67 |
'DLL' 'dynamic link library' |
|
3336 | 68 |
) pairWiseDo:[:k :v | |
3570 | 69 |
StandardSuffixTable at:k put:v |
3336 | 70 |
] |
71 |
||
72 |
" |
|
73 |
StandardSuffixTable := nil. |
|
74 |
self initStandardSuffixTable |
|
75 |
" |
|
76 |
||
77 |
"Modified: 16.10.1997 / 13:12:39 / cg" |
|
3708
27a62fa7b5bb
in #isVolumeAbsolute: care for filenames of the form: \hostname
Claus Gittinger <cg@exept.de>
parents:
3570
diff
changeset
|
78 |
! ! |
27a62fa7b5bb
in #isVolumeAbsolute: care for filenames of the form: \hostname
Claus Gittinger <cg@exept.de>
parents:
3570
diff
changeset
|
79 |
|
27a62fa7b5bb
in #isVolumeAbsolute: care for filenames of the form: \hostname
Claus Gittinger <cg@exept.de>
parents:
3570
diff
changeset
|
80 |
!PCFilename class methodsFor:'instance creation'! |
27a62fa7b5bb
in #isVolumeAbsolute: care for filenames of the form: \hostname
Claus Gittinger <cg@exept.de>
parents:
3570
diff
changeset
|
81 |
|
7062 | 82 |
named:aString |
83 |
"return a filename for a directory named aString. |
|
84 |
This is the same as 'aString asFilename'." |
|
85 |
||
86 |
|fn| |
|
87 |
||
88 |
fn := super named:aString. |
|
89 |
fn makeNonDOSName. |
|
90 |
^fn |
|
91 |
! |
|
92 |
||
3336 | 93 |
newTemporaryIn:aDirectoryPrefix |
94 |
"return a new unique filename - use this for temporary files. |
|
95 |
redefined to always return an MSDOS 8+3 fileName, |
|
96 |
in case the tempFile is passed to an OLD dos utility.." |
|
97 |
||
98 |
|pid nr nameString| |
|
99 |
||
100 |
(self ~~ ConcreteClass) ifTrue:[ |
|
3570 | 101 |
^ ConcreteClass newTemporaryIn:aDirectoryPrefix |
3336 | 102 |
]. |
103 |
||
104 |
"/ although the above allows things to be redefined in concrete classes, |
|
105 |
"/ the following should work on all systems ... |
|
106 |
||
107 |
NextTempFilenameIndex isNil ifTrue:[ |
|
3570 | 108 |
NextTempFilenameIndex := 1. |
3336 | 109 |
]. |
110 |
||
111 |
pid := OperatingSystem getProcessId printString. |
|
112 |
pid := pid copyLast:(3 min:pid size). |
|
113 |
nr := NextTempFilenameIndex printString. |
|
114 |
nr := nr copyLast:(3 min:nr size). |
|
115 |
nameString := (self tempFileNameTemplate) |
|
3570 | 116 |
bindWith:pid |
117 |
with:nr. |
|
3336 | 118 |
NextTempFilenameIndex := NextTempFilenameIndex + 1. |
119 |
||
120 |
(aDirectoryPrefix isNil or:[aDirectoryPrefix asString isEmpty]) ifFalse:[ |
|
3570 | 121 |
^ aDirectoryPrefix asFilename construct:nameString |
3336 | 122 |
]. |
123 |
^ self named:nameString |
|
124 |
||
125 |
"temp files in '/tmp': |
|
126 |
||
127 |
Filename newTemporary |
|
128 |
" |
|
129 |
||
130 |
"temp files somewhere |
|
131 |
(not recommended - use above since it can be controlled via shell variables): |
|
132 |
||
133 |
Filename newTemporaryIn:'/tmp' |
|
134 |
Filename newTemporaryIn:'/tmp' |
|
135 |
Filename newTemporaryIn:'/usr/tmp' |
|
136 |
Filename newTemporaryIn:'/' |
|
137 |
" |
|
138 |
||
139 |
"a local temp file: |
|
140 |
||
141 |
Filename newTemporaryIn:'' |
|
142 |
Filename newTemporaryIn:nil |
|
143 |
Filename newTemporaryIn:'.' |
|
144 |
Filename newTemporaryIn:('source' asFilename) |
|
145 |
" |
|
146 |
||
147 |
"Modified: 7.9.1995 / 10:48:31 / claus" |
|
148 |
"Modified: 8.9.1997 / 00:28:33 / cg" |
|
149 |
"Created: 30.1.1998 / 11:49:33 / md" |
|
150 |
"Modified: 30.1.1998 / 11:52:06 / md" |
|
151 |
"Modified: 30.1.1998 / 12:09:18 / dq" |
|
3848 | 152 |
! |
153 |
||
154 |
rootDirectoryOnVolume:aVolumeName |
|
155 |
"return a filename for the root directory on some volume" |
|
156 |
||
3853 | 157 |
^ self named:(aVolumeName , '\') |
3848 | 158 |
|
159 |
" |
|
3853 | 160 |
Filename rootDirectoryOnVolume:'d:' |
161 |
Filename rootDirectoryOnVolume:'\\idefix\home' |
|
3848 | 162 |
" |
163 |
||
3853 | 164 |
"Modified: / 24.9.1998 / 19:06:15 / cg" |
3708
27a62fa7b5bb
in #isVolumeAbsolute: care for filenames of the form: \hostname
Claus Gittinger <cg@exept.de>
parents:
3570
diff
changeset
|
165 |
! ! |
27a62fa7b5bb
in #isVolumeAbsolute: care for filenames of the form: \hostname
Claus Gittinger <cg@exept.de>
parents:
3570
diff
changeset
|
166 |
|
7837 | 167 |
!PCFilename class methodsFor:'defaults'! |
168 |
||
169 |
defaultTempDirectoryName |
|
170 |
"return the default temp directory as a filename. |
|
171 |
This is used, if no special preferences were defined in |
|
172 |
any of the TEMP-environment variables (see tempDirectory)." |
|
173 |
||
174 |
^ 'c:\temp' |
|
175 |
||
176 |
" |
|
177 |
Filename defaultTempDirectoryName |
|
178 |
Filename defaultTempDirectoryName asFilename exists |
|
179 |
Filename defaultTempDirectoryName asFilename isWritable |
|
180 |
" |
|
181 |
! ! |
|
182 |
||
3708
27a62fa7b5bb
in #isVolumeAbsolute: care for filenames of the form: \hostname
Claus Gittinger <cg@exept.de>
parents:
3570
diff
changeset
|
183 |
!PCFilename class methodsFor:'queries'! |
27a62fa7b5bb
in #isVolumeAbsolute: care for filenames of the form: \hostname
Claus Gittinger <cg@exept.de>
parents:
3570
diff
changeset
|
184 |
|
3336 | 185 |
isBadCharacter:aCharacter |
186 |
"return true, if aCharacter is unallowed in a filename." |
|
187 |
||
188 |
('<>:"/\|' includes:aCharacter) ifTrue:[^ true]. |
|
189 |
^ super isBadCharacter:aCharacter |
|
190 |
||
191 |
"Created: 8.9.1997 / 00:14:06 / cg" |
|
3708
27a62fa7b5bb
in #isVolumeAbsolute: care for filenames of the form: \hostname
Claus Gittinger <cg@exept.de>
parents:
3570
diff
changeset
|
192 |
! |
27a62fa7b5bb
in #isVolumeAbsolute: care for filenames of the form: \hostname
Claus Gittinger <cg@exept.de>
parents:
3570
diff
changeset
|
193 |
|
3336 | 194 |
isCaseSensitive |
195 |
"return true, if filenames are case sensitive." |
|
196 |
||
197 |
^ false |
|
3708
27a62fa7b5bb
in #isVolumeAbsolute: care for filenames of the form: \hostname
Claus Gittinger <cg@exept.de>
parents:
3570
diff
changeset
|
198 |
! |
27a62fa7b5bb
in #isVolumeAbsolute: care for filenames of the form: \hostname
Claus Gittinger <cg@exept.de>
parents:
3570
diff
changeset
|
199 |
|
3336 | 200 |
separator |
201 |
"return the file/directory separator." |
|
202 |
||
203 |
^ $\ |
|
204 |
||
205 |
" |
|
206 |
Filename concreteClass separator |
|
207 |
" |
|
208 |
||
209 |
"Modified: 8.9.1997 / 00:18:03 / cg" |
|
3708
27a62fa7b5bb
in #isVolumeAbsolute: care for filenames of the form: \hostname
Claus Gittinger <cg@exept.de>
parents:
3570
diff
changeset
|
210 |
! |
27a62fa7b5bb
in #isVolumeAbsolute: care for filenames of the form: \hostname
Claus Gittinger <cg@exept.de>
parents:
3570
diff
changeset
|
211 |
|
3336 | 212 |
tempFileNameTemplate |
213 |
"return a template for temporary files. |
|
214 |
This is expanded with the current processID and a sequenceNumber |
|
215 |
to generate a unique filename. |
|
216 |
Redefined for MSDOS 8+3 filenames" |
|
217 |
||
3749 | 218 |
^ 'st%1%2' |
3336 | 219 |
|
220 |
"Created: 30.1.1998 / 12:09:18 / dq" |
|
3708
27a62fa7b5bb
in #isVolumeAbsolute: care for filenames of the form: \hostname
Claus Gittinger <cg@exept.de>
parents:
3570
diff
changeset
|
221 |
! ! |
27a62fa7b5bb
in #isVolumeAbsolute: care for filenames of the form: \hostname
Claus Gittinger <cg@exept.de>
parents:
3570
diff
changeset
|
222 |
|
3789 | 223 |
!PCFilename methodsFor:'converting'! |
224 |
||
7062 | 225 |
makeFullPathName |
226 |
"convert the receivers name to be a full filename, in case its an abbreviated (alternative) |
|
227 |
DOS name. |
|
228 |
This removes/replaces components of the form FOOBAR~n by the real, full components name." |
|
229 |
||
230 |
|directory baseName| |
|
231 |
||
232 |
(nameString includes:$~) ifFalse:[^self]. |
|
233 |
directory := self directoryName. |
|
234 |
baseName := self baseName. |
|
235 |
||
236 |
^ self |
|
237 |
||
238 |
" |
|
239 |
'hello world' asFilename makeLegalFilename |
|
240 |
'hello:world' asFilename makeLegalFilename |
|
241 |
'hello::world' asFilename makeLegalFilename |
|
242 |
'c:hello::world' asFilename makeLegalFilename |
|
243 |
'\\idefix' asFilename makeLegalFilename |
|
244 |
'\\idefix\' asFilename makeLegalFilename |
|
245 |
" |
|
246 |
||
247 |
"Modified: / 11.10.1998 / 01:40:47 / cg" |
|
248 |
! |
|
249 |
||
3789 | 250 |
makeLegalFilename |
251 |
"convert the receivers name to be a legal filename. |
|
252 |
This removes/replaces invalid characters and/or compresses |
|
253 |
the name as required by Win95-WinNT." |
|
254 |
||
255 |
|srchStart| |
|
256 |
||
257 |
"/ there may be only one colon in the name |
|
258 |
"/ (and if present, it must be the second character) |
|
259 |
||
260 |
((nameString size >= 2) |
|
261 |
and:[(nameString at:2) == $:]) ifTrue:[ |
|
262 |
srchStart := 3. |
|
263 |
] ifFalse:[ |
|
264 |
srchStart := 1 |
|
265 |
]. |
|
266 |
||
267 |
"/ replace colons by underscore |
|
268 |
"/ may need more to convert - time will show |
|
269 |
||
3873
4a81549760f7
also replace spaces by underlines to make a legal filename
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
270 |
(nameString indexOfAny:#($: $ ) startingAt:srchStart) ~~ 0 ifTrue:[ |
3789 | 271 |
nameString := nameString copy. |
3873
4a81549760f7
also replace spaces by underlines to make a legal filename
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
272 |
nameString replaceAny:#($: $ ) with:$_ from:srchStart to:(nameString size). |
3789 | 273 |
]. |
274 |
^ self |
|
275 |
||
276 |
" |
|
277 |
'hello world' asFilename makeLegalFilename |
|
278 |
'hello:world' asFilename makeLegalFilename |
|
279 |
'hello::world' asFilename makeLegalFilename |
|
280 |
'c:hello::world' asFilename makeLegalFilename |
|
3850
f4d25f3deac8
fixes for network drives (isRootDirectory)
Claus Gittinger <cg@exept.de>
parents:
3848
diff
changeset
|
281 |
'\\idefix' asFilename makeLegalFilename |
f4d25f3deac8
fixes for network drives (isRootDirectory)
Claus Gittinger <cg@exept.de>
parents:
3848
diff
changeset
|
282 |
'\\idefix\' asFilename makeLegalFilename |
3789 | 283 |
" |
284 |
||
3873
4a81549760f7
also replace spaces by underlines to make a legal filename
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
285 |
"Modified: / 11.10.1998 / 01:40:47 / cg" |
7062 | 286 |
! |
287 |
||
288 |
makeNonDOSName |
|
289 |
"convert the receivers name to be a full filename, in case its an abbreviated (alternative) DOS name. |
|
290 |
This removes/replaces components of the form FOOBAR~n by the real, full components name." |
|
291 |
||
8548 | 292 |
|directory directoryName baseName info| |
7062 | 293 |
|
294 |
(nameString includes:$~) ifFalse:[^self]. |
|
295 |
||
8548 | 296 |
directoryName := self directoryName. |
297 |
directoryName = nameString ifTrue:[^self]. |
|
298 |
||
7062 | 299 |
baseName := self baseName. |
8548 | 300 |
|
7062 | 301 |
(baseName includes:$~) ifTrue:[ |
7101 | 302 |
info := self info. |
303 |
info notNil ifTrue:[ |
|
304 |
baseName := self info fullName. |
|
305 |
]. |
|
8548 | 306 |
directory := self class named:directoryName. |
7101 | 307 |
directory isRootDirectory ifFalse:[ |
308 |
directory makeNonDOSName. |
|
309 |
]. |
|
8548 | 310 |
nameString := directory constructString:baseName |
7062 | 311 |
]. |
312 |
||
313 |
" |
|
314 |
Filename tempDirectory makeNonDOSName |
|
315 |
" |
|
316 |
||
317 |
"Modified: / 11.10.1998 / 01:40:47 / cg" |
|
3789 | 318 |
! ! |
319 |
||
3708
27a62fa7b5bb
in #isVolumeAbsolute: care for filenames of the form: \hostname
Claus Gittinger <cg@exept.de>
parents:
3570
diff
changeset
|
320 |
!PCFilename methodsFor:'file operations'! |
27a62fa7b5bb
in #isVolumeAbsolute: care for filenames of the form: \hostname
Claus Gittinger <cg@exept.de>
parents:
3570
diff
changeset
|
321 |
|
3570 | 322 |
renameTo:newName |
323 |
"rename the file - the argument must be convertable to a String. |
|
324 |
Raise an error if not successful. |
|
325 |
Redefined to delete any existing target-file first." |
|
3336 | 326 |
|
3570 | 327 |
newName asFilename exists ifTrue:[ |
328 |
newName asFilename delete |
|
329 |
]. |
|
330 |
||
331 |
^ super renameTo:newName |
|
3336 | 332 |
|
3570 | 333 |
" |
334 |
'\tmp\foo' asFilename renameTo:'\tmp\bar' |
|
335 |
" |
|
336 |
||
337 |
"Modified: 20.1.1998 / 15:33:00 / md" |
|
3708
27a62fa7b5bb
in #isVolumeAbsolute: care for filenames of the form: \hostname
Claus Gittinger <cg@exept.de>
parents:
3570
diff
changeset
|
338 |
! ! |
27a62fa7b5bb
in #isVolumeAbsolute: care for filenames of the form: \hostname
Claus Gittinger <cg@exept.de>
parents:
3570
diff
changeset
|
339 |
|
27a62fa7b5bb
in #isVolumeAbsolute: care for filenames of the form: \hostname
Claus Gittinger <cg@exept.de>
parents:
3570
diff
changeset
|
340 |
!PCFilename methodsFor:'queries'! |
27a62fa7b5bb
in #isVolumeAbsolute: care for filenames of the form: \hostname
Claus Gittinger <cg@exept.de>
parents:
3570
diff
changeset
|
341 |
|
4374
0b2a18a8cf84
fixed directoryName and isAbsolute.
Claus Gittinger <cg@exept.de>
parents:
3873
diff
changeset
|
342 |
directoryName |
0b2a18a8cf84
fixed directoryName and isAbsolute.
Claus Gittinger <cg@exept.de>
parents:
3873
diff
changeset
|
343 |
"return the directory name part of the file/directory as a string. |
0b2a18a8cf84
fixed directoryName and isAbsolute.
Claus Gittinger <cg@exept.de>
parents:
3873
diff
changeset
|
344 |
- thats the name of the directory where the file/dir represented by |
0b2a18a8cf84
fixed directoryName and isAbsolute.
Claus Gittinger <cg@exept.de>
parents:
3873
diff
changeset
|
345 |
the receiver is contained in. |
0b2a18a8cf84
fixed directoryName and isAbsolute.
Claus Gittinger <cg@exept.de>
parents:
3873
diff
changeset
|
346 |
This method does not check if the path is valid. |
0b2a18a8cf84
fixed directoryName and isAbsolute.
Claus Gittinger <cg@exept.de>
parents:
3873
diff
changeset
|
347 |
|
0b2a18a8cf84
fixed directoryName and isAbsolute.
Claus Gittinger <cg@exept.de>
parents:
3873
diff
changeset
|
348 |
(i.e. '/usr/lib/st/file' asFilename directoryName -> '/usr/lib/st' |
0b2a18a8cf84
fixed directoryName and isAbsolute.
Claus Gittinger <cg@exept.de>
parents:
3873
diff
changeset
|
349 |
and '/usr/lib' asFilename directoryName -> /usr'). |
0b2a18a8cf84
fixed directoryName and isAbsolute.
Claus Gittinger <cg@exept.de>
parents:
3873
diff
changeset
|
350 |
|
0b2a18a8cf84
fixed directoryName and isAbsolute.
Claus Gittinger <cg@exept.de>
parents:
3873
diff
changeset
|
351 |
(this is almost equivalent to #directory, but returns |
0b2a18a8cf84
fixed directoryName and isAbsolute.
Claus Gittinger <cg@exept.de>
parents:
3873
diff
changeset
|
352 |
a string instead of a Filename instance). |
0b2a18a8cf84
fixed directoryName and isAbsolute.
Claus Gittinger <cg@exept.de>
parents:
3873
diff
changeset
|
353 |
|
0b2a18a8cf84
fixed directoryName and isAbsolute.
Claus Gittinger <cg@exept.de>
parents:
3873
diff
changeset
|
354 |
See also: #pathName, #directoryPathName and #baseName. |
0b2a18a8cf84
fixed directoryName and isAbsolute.
Claus Gittinger <cg@exept.de>
parents:
3873
diff
changeset
|
355 |
Compatibility note: use #head for ST-80 compatibility." |
0b2a18a8cf84
fixed directoryName and isAbsolute.
Claus Gittinger <cg@exept.de>
parents:
3873
diff
changeset
|
356 |
|
0b2a18a8cf84
fixed directoryName and isAbsolute.
Claus Gittinger <cg@exept.de>
parents:
3873
diff
changeset
|
357 |
|nm| |
0b2a18a8cf84
fixed directoryName and isAbsolute.
Claus Gittinger <cg@exept.de>
parents:
3873
diff
changeset
|
358 |
|
0b2a18a8cf84
fixed directoryName and isAbsolute.
Claus Gittinger <cg@exept.de>
parents:
3873
diff
changeset
|
359 |
nm := super directoryName. |
0b2a18a8cf84
fixed directoryName and isAbsolute.
Claus Gittinger <cg@exept.de>
parents:
3873
diff
changeset
|
360 |
(nm size == 2 and:[(nm at:2) == $:]) ifTrue:[ |
0b2a18a8cf84
fixed directoryName and isAbsolute.
Claus Gittinger <cg@exept.de>
parents:
3873
diff
changeset
|
361 |
^ nm , '\' |
0b2a18a8cf84
fixed directoryName and isAbsolute.
Claus Gittinger <cg@exept.de>
parents:
3873
diff
changeset
|
362 |
]. |
0b2a18a8cf84
fixed directoryName and isAbsolute.
Claus Gittinger <cg@exept.de>
parents:
3873
diff
changeset
|
363 |
^ nm |
0b2a18a8cf84
fixed directoryName and isAbsolute.
Claus Gittinger <cg@exept.de>
parents:
3873
diff
changeset
|
364 |
|
0b2a18a8cf84
fixed directoryName and isAbsolute.
Claus Gittinger <cg@exept.de>
parents:
3873
diff
changeset
|
365 |
" |
0b2a18a8cf84
fixed directoryName and isAbsolute.
Claus Gittinger <cg@exept.de>
parents:
3873
diff
changeset
|
366 |
(PCFilename named:'c:\users') directoryName |
0b2a18a8cf84
fixed directoryName and isAbsolute.
Claus Gittinger <cg@exept.de>
parents:
3873
diff
changeset
|
367 |
(PCFilename named:'c:\users') directory pathName |
0b2a18a8cf84
fixed directoryName and isAbsolute.
Claus Gittinger <cg@exept.de>
parents:
3873
diff
changeset
|
368 |
(PCFilename named:'c:\users') directory isRootDirectory |
0b2a18a8cf84
fixed directoryName and isAbsolute.
Claus Gittinger <cg@exept.de>
parents:
3873
diff
changeset
|
369 |
" |
0b2a18a8cf84
fixed directoryName and isAbsolute.
Claus Gittinger <cg@exept.de>
parents:
3873
diff
changeset
|
370 |
! |
0b2a18a8cf84
fixed directoryName and isAbsolute.
Claus Gittinger <cg@exept.de>
parents:
3873
diff
changeset
|
371 |
|
3336 | 372 |
fileType |
373 |
"this returns a string describing the type of contents of |
|
374 |
the file. Here, the suffix is examined for a standard |
|
375 |
suffix and an appropriate string is returned. |
|
376 |
Poor MSDOS - no file command." |
|
377 |
||
378 |
|suff type info fmt| |
|
379 |
||
380 |
StandardSuffixTable isNil ifTrue:[ |
|
3570 | 381 |
self class initStandardSuffixTable |
3336 | 382 |
]. |
383 |
||
384 |
suff := self suffix asUppercase. |
|
385 |
type := StandardSuffixTable at:suff ifAbsent:nil. |
|
386 |
type isNil ifTrue:[ |
|
3570 | 387 |
type := super fileType. |
3336 | 388 |
]. |
389 |
^ type |
|
390 |
||
391 |
"Created: 16.10.1997 / 13:07:24 / cg" |
|
392 |
"Modified: 16.10.1997 / 13:10:00 / cg" |
|
3708
27a62fa7b5bb
in #isVolumeAbsolute: care for filenames of the form: \hostname
Claus Gittinger <cg@exept.de>
parents:
3570
diff
changeset
|
393 |
! |
27a62fa7b5bb
in #isVolumeAbsolute: care for filenames of the form: \hostname
Claus Gittinger <cg@exept.de>
parents:
3570
diff
changeset
|
394 |
|
3850
f4d25f3deac8
fixes for network drives (isRootDirectory)
Claus Gittinger <cg@exept.de>
parents:
3848
diff
changeset
|
395 |
isDirectory |
f4d25f3deac8
fixes for network drives (isRootDirectory)
Claus Gittinger <cg@exept.de>
parents:
3848
diff
changeset
|
396 |
"return true, if I represent a root directory |
f4d25f3deac8
fixes for network drives (isRootDirectory)
Claus Gittinger <cg@exept.de>
parents:
3848
diff
changeset
|
397 |
(i.e. I have no parentDir). |
f4d25f3deac8
fixes for network drives (isRootDirectory)
Claus Gittinger <cg@exept.de>
parents:
3848
diff
changeset
|
398 |
Redefined to care for volumeRoots." |
f4d25f3deac8
fixes for network drives (isRootDirectory)
Claus Gittinger <cg@exept.de>
parents:
3848
diff
changeset
|
399 |
|
f4d25f3deac8
fixes for network drives (isRootDirectory)
Claus Gittinger <cg@exept.de>
parents:
3848
diff
changeset
|
400 |
self isRootDirectory ifTrue:[^ true]. |
f4d25f3deac8
fixes for network drives (isRootDirectory)
Claus Gittinger <cg@exept.de>
parents:
3848
diff
changeset
|
401 |
^super isDirectory. |
f4d25f3deac8
fixes for network drives (isRootDirectory)
Claus Gittinger <cg@exept.de>
parents:
3848
diff
changeset
|
402 |
|
f4d25f3deac8
fixes for network drives (isRootDirectory)
Claus Gittinger <cg@exept.de>
parents:
3848
diff
changeset
|
403 |
"Created: / 24.9.1998 / 14:04:31 / cg" |
f4d25f3deac8
fixes for network drives (isRootDirectory)
Claus Gittinger <cg@exept.de>
parents:
3848
diff
changeset
|
404 |
! |
f4d25f3deac8
fixes for network drives (isRootDirectory)
Claus Gittinger <cg@exept.de>
parents:
3848
diff
changeset
|
405 |
|
3336 | 406 |
isExecutableProgram |
407 |
"return true, if such a file exists and is an executable program. |
|
408 |
(i.e. for directories, false is returned.)" |
|
409 |
||
3815 | 410 |
|mySuffix| |
411 |
||
412 |
mySuffix := self suffix asLowercase. |
|
413 |
(mySuffix = 'exe' or:[mySuffix = 'com']) ifTrue:[ |
|
414 |
^ super isExecutableProgram |
|
3336 | 415 |
]. |
416 |
^ false |
|
417 |
||
3815 | 418 |
"Created: / 16.10.1997 / 13:19:10 / cg" |
419 |
"Modified: / 9.9.1998 / 20:17:52 / cg" |
|
3708
27a62fa7b5bb
in #isVolumeAbsolute: care for filenames of the form: \hostname
Claus Gittinger <cg@exept.de>
parents:
3570
diff
changeset
|
420 |
! |
27a62fa7b5bb
in #isVolumeAbsolute: care for filenames of the form: \hostname
Claus Gittinger <cg@exept.de>
parents:
3570
diff
changeset
|
421 |
|
3336 | 422 |
isExplicitRelative |
423 |
"return true, if this name is an explicit relative name |
|
424 |
(i.e. starts with './' or '../', to avoid path-prepending)" |
|
425 |
||
426 |
(nameString startsWith:'.\') ifTrue:[ |
|
427 |
^ true |
|
428 |
]. |
|
429 |
(nameString startsWith:'..\') ifTrue:[ |
|
430 |
^ true |
|
431 |
]. |
|
432 |
^ false |
|
3708
27a62fa7b5bb
in #isVolumeAbsolute: care for filenames of the form: \hostname
Claus Gittinger <cg@exept.de>
parents:
3570
diff
changeset
|
433 |
! |
27a62fa7b5bb
in #isVolumeAbsolute: care for filenames of the form: \hostname
Claus Gittinger <cg@exept.de>
parents:
3570
diff
changeset
|
434 |
|
3844
fb51bffc0aa3
redefined isRootDirectory for drive-letters & net-drives
Claus Gittinger <cg@exept.de>
parents:
3815
diff
changeset
|
435 |
isRootDirectory |
fb51bffc0aa3
redefined isRootDirectory for drive-letters & net-drives
Claus Gittinger <cg@exept.de>
parents:
3815
diff
changeset
|
436 |
"return true, if I represent a root directory |
fb51bffc0aa3
redefined isRootDirectory for drive-letters & net-drives
Claus Gittinger <cg@exept.de>
parents:
3815
diff
changeset
|
437 |
(i.e. I have no parentDir)" |
fb51bffc0aa3
redefined isRootDirectory for drive-letters & net-drives
Claus Gittinger <cg@exept.de>
parents:
3815
diff
changeset
|
438 |
|
3850
f4d25f3deac8
fixes for network drives (isRootDirectory)
Claus Gittinger <cg@exept.de>
parents:
3848
diff
changeset
|
439 |
|sz nm i| |
3844
fb51bffc0aa3
redefined isRootDirectory for drive-letters & net-drives
Claus Gittinger <cg@exept.de>
parents:
3815
diff
changeset
|
440 |
|
fb51bffc0aa3
redefined isRootDirectory for drive-letters & net-drives
Claus Gittinger <cg@exept.de>
parents:
3815
diff
changeset
|
441 |
nm := self pathName. |
3850
f4d25f3deac8
fixes for network drives (isRootDirectory)
Claus Gittinger <cg@exept.de>
parents:
3848
diff
changeset
|
442 |
sz := nm size. |
3844
fb51bffc0aa3
redefined isRootDirectory for drive-letters & net-drives
Claus Gittinger <cg@exept.de>
parents:
3815
diff
changeset
|
443 |
|
4374
0b2a18a8cf84
fixed directoryName and isAbsolute.
Claus Gittinger <cg@exept.de>
parents:
3873
diff
changeset
|
444 |
sz == 1 ifTrue:[ |
0b2a18a8cf84
fixed directoryName and isAbsolute.
Claus Gittinger <cg@exept.de>
parents:
3873
diff
changeset
|
445 |
(nm = '\') ifTrue:[ |
0b2a18a8cf84
fixed directoryName and isAbsolute.
Claus Gittinger <cg@exept.de>
parents:
3873
diff
changeset
|
446 |
"/ \ alone |
0b2a18a8cf84
fixed directoryName and isAbsolute.
Claus Gittinger <cg@exept.de>
parents:
3873
diff
changeset
|
447 |
^ true |
0b2a18a8cf84
fixed directoryName and isAbsolute.
Claus Gittinger <cg@exept.de>
parents:
3873
diff
changeset
|
448 |
] |
0b2a18a8cf84
fixed directoryName and isAbsolute.
Claus Gittinger <cg@exept.de>
parents:
3873
diff
changeset
|
449 |
]. |
0b2a18a8cf84
fixed directoryName and isAbsolute.
Claus Gittinger <cg@exept.de>
parents:
3873
diff
changeset
|
450 |
|
3850
f4d25f3deac8
fixes for network drives (isRootDirectory)
Claus Gittinger <cg@exept.de>
parents:
3848
diff
changeset
|
451 |
sz >= 2 ifTrue:[ |
f4d25f3deac8
fixes for network drives (isRootDirectory)
Claus Gittinger <cg@exept.de>
parents:
3848
diff
changeset
|
452 |
(nm at:2) == $: ifTrue:[ |
f4d25f3deac8
fixes for network drives (isRootDirectory)
Claus Gittinger <cg@exept.de>
parents:
3848
diff
changeset
|
453 |
sz == 2 ifTrue:[ |
f4d25f3deac8
fixes for network drives (isRootDirectory)
Claus Gittinger <cg@exept.de>
parents:
3848
diff
changeset
|
454 |
"/ <DRIVE-char>: |
f4d25f3deac8
fixes for network drives (isRootDirectory)
Claus Gittinger <cg@exept.de>
parents:
3848
diff
changeset
|
455 |
^ true |
f4d25f3deac8
fixes for network drives (isRootDirectory)
Claus Gittinger <cg@exept.de>
parents:
3848
diff
changeset
|
456 |
]. |
f4d25f3deac8
fixes for network drives (isRootDirectory)
Claus Gittinger <cg@exept.de>
parents:
3848
diff
changeset
|
457 |
sz == 3 ifTrue:[ |
f4d25f3deac8
fixes for network drives (isRootDirectory)
Claus Gittinger <cg@exept.de>
parents:
3848
diff
changeset
|
458 |
(nm at:3) == $\ ifTrue:[ |
f4d25f3deac8
fixes for network drives (isRootDirectory)
Claus Gittinger <cg@exept.de>
parents:
3848
diff
changeset
|
459 |
"/ <DRIVE-char>:\ |
f4d25f3deac8
fixes for network drives (isRootDirectory)
Claus Gittinger <cg@exept.de>
parents:
3848
diff
changeset
|
460 |
^ true |
f4d25f3deac8
fixes for network drives (isRootDirectory)
Claus Gittinger <cg@exept.de>
parents:
3848
diff
changeset
|
461 |
] |
f4d25f3deac8
fixes for network drives (isRootDirectory)
Claus Gittinger <cg@exept.de>
parents:
3848
diff
changeset
|
462 |
] |
f4d25f3deac8
fixes for network drives (isRootDirectory)
Claus Gittinger <cg@exept.de>
parents:
3848
diff
changeset
|
463 |
]. |
3844
fb51bffc0aa3
redefined isRootDirectory for drive-letters & net-drives
Claus Gittinger <cg@exept.de>
parents:
3815
diff
changeset
|
464 |
]. |
3850
f4d25f3deac8
fixes for network drives (isRootDirectory)
Claus Gittinger <cg@exept.de>
parents:
3848
diff
changeset
|
465 |
|
f4d25f3deac8
fixes for network drives (isRootDirectory)
Claus Gittinger <cg@exept.de>
parents:
3848
diff
changeset
|
466 |
"/ \\<REMOTE-HOST> |
3844
fb51bffc0aa3
redefined isRootDirectory for drive-letters & net-drives
Claus Gittinger <cg@exept.de>
parents:
3815
diff
changeset
|
467 |
(((nm size > 3) |
fb51bffc0aa3
redefined isRootDirectory for drive-letters & net-drives
Claus Gittinger <cg@exept.de>
parents:
3815
diff
changeset
|
468 |
and:[(nm at:1) == $\]) |
fb51bffc0aa3
redefined isRootDirectory for drive-letters & net-drives
Claus Gittinger <cg@exept.de>
parents:
3815
diff
changeset
|
469 |
and:[(nm at:2) == $\]) ifTrue:[ |
fb51bffc0aa3
redefined isRootDirectory for drive-letters & net-drives
Claus Gittinger <cg@exept.de>
parents:
3815
diff
changeset
|
470 |
"/ something like \\hostname\ |
fb51bffc0aa3
redefined isRootDirectory for drive-letters & net-drives
Claus Gittinger <cg@exept.de>
parents:
3815
diff
changeset
|
471 |
i := nm indexOf:$\ startingAt:4. |
3850
f4d25f3deac8
fixes for network drives (isRootDirectory)
Claus Gittinger <cg@exept.de>
parents:
3848
diff
changeset
|
472 |
((i == 0) or:[i == nameString size]) ifTrue:[ |
f4d25f3deac8
fixes for network drives (isRootDirectory)
Claus Gittinger <cg@exept.de>
parents:
3848
diff
changeset
|
473 |
"/ not really a root (its not readable) |
3844
fb51bffc0aa3
redefined isRootDirectory for drive-letters & net-drives
Claus Gittinger <cg@exept.de>
parents:
3815
diff
changeset
|
474 |
^ true |
fb51bffc0aa3
redefined isRootDirectory for drive-letters & net-drives
Claus Gittinger <cg@exept.de>
parents:
3815
diff
changeset
|
475 |
]. |
3850
f4d25f3deac8
fixes for network drives (isRootDirectory)
Claus Gittinger <cg@exept.de>
parents:
3848
diff
changeset
|
476 |
i ~~ 0 ifTrue:[ |
f4d25f3deac8
fixes for network drives (isRootDirectory)
Claus Gittinger <cg@exept.de>
parents:
3848
diff
changeset
|
477 |
"/ something like \\hostname\dirName |
f4d25f3deac8
fixes for network drives (isRootDirectory)
Claus Gittinger <cg@exept.de>
parents:
3848
diff
changeset
|
478 |
i := nm indexOf:$\ startingAt:i+1. |
f4d25f3deac8
fixes for network drives (isRootDirectory)
Claus Gittinger <cg@exept.de>
parents:
3848
diff
changeset
|
479 |
((i == 0) or:[i == nameString size]) ifTrue:[ |
f4d25f3deac8
fixes for network drives (isRootDirectory)
Claus Gittinger <cg@exept.de>
parents:
3848
diff
changeset
|
480 |
"/ yeah - really a root |
f4d25f3deac8
fixes for network drives (isRootDirectory)
Claus Gittinger <cg@exept.de>
parents:
3848
diff
changeset
|
481 |
^ true |
f4d25f3deac8
fixes for network drives (isRootDirectory)
Claus Gittinger <cg@exept.de>
parents:
3848
diff
changeset
|
482 |
]. |
f4d25f3deac8
fixes for network drives (isRootDirectory)
Claus Gittinger <cg@exept.de>
parents:
3848
diff
changeset
|
483 |
] |
3844
fb51bffc0aa3
redefined isRootDirectory for drive-letters & net-drives
Claus Gittinger <cg@exept.de>
parents:
3815
diff
changeset
|
484 |
]. |
fb51bffc0aa3
redefined isRootDirectory for drive-letters & net-drives
Claus Gittinger <cg@exept.de>
parents:
3815
diff
changeset
|
485 |
^ super isRootDirectory |
fb51bffc0aa3
redefined isRootDirectory for drive-letters & net-drives
Claus Gittinger <cg@exept.de>
parents:
3815
diff
changeset
|
486 |
|
fb51bffc0aa3
redefined isRootDirectory for drive-letters & net-drives
Claus Gittinger <cg@exept.de>
parents:
3815
diff
changeset
|
487 |
"Created: / 21.9.1998 / 15:37:41 / cg" |
3850
f4d25f3deac8
fixes for network drives (isRootDirectory)
Claus Gittinger <cg@exept.de>
parents:
3848
diff
changeset
|
488 |
"Modified: / 24.9.1998 / 15:57:10 / cg" |
3844
fb51bffc0aa3
redefined isRootDirectory for drive-letters & net-drives
Claus Gittinger <cg@exept.de>
parents:
3815
diff
changeset
|
489 |
! |
fb51bffc0aa3
redefined isRootDirectory for drive-letters & net-drives
Claus Gittinger <cg@exept.de>
parents:
3815
diff
changeset
|
490 |
|
3336 | 491 |
isVolumeAbsolute |
492 |
"return true, if the receiver represents an absolute pathname |
|
493 |
on some disk volume." |
|
494 |
||
3815 | 495 |
"/ <DRIVE-CHAR>: |
3708
27a62fa7b5bb
in #isVolumeAbsolute: care for filenames of the form: \hostname
Claus Gittinger <cg@exept.de>
parents:
3570
diff
changeset
|
496 |
(((nameString size >= 3) |
27a62fa7b5bb
in #isVolumeAbsolute: care for filenames of the form: \hostname
Claus Gittinger <cg@exept.de>
parents:
3570
diff
changeset
|
497 |
and:[(nameString at:2) == $:]) |
27a62fa7b5bb
in #isVolumeAbsolute: care for filenames of the form: \hostname
Claus Gittinger <cg@exept.de>
parents:
3570
diff
changeset
|
498 |
and:[(nameString at:3) == $\]) ifTrue:[ |
3815 | 499 |
"/ something like x:\foo |
500 |
^ true |
|
3708
27a62fa7b5bb
in #isVolumeAbsolute: care for filenames of the form: \hostname
Claus Gittinger <cg@exept.de>
parents:
3570
diff
changeset
|
501 |
]. |
3815 | 502 |
|
503 |
"/ \\REMOTE-HOST: |
|
3708
27a62fa7b5bb
in #isVolumeAbsolute: care for filenames of the form: \hostname
Claus Gittinger <cg@exept.de>
parents:
3570
diff
changeset
|
504 |
(((nameString size >= 3) |
27a62fa7b5bb
in #isVolumeAbsolute: care for filenames of the form: \hostname
Claus Gittinger <cg@exept.de>
parents:
3570
diff
changeset
|
505 |
and:[(nameString at:1) == $\]) |
27a62fa7b5bb
in #isVolumeAbsolute: care for filenames of the form: \hostname
Claus Gittinger <cg@exept.de>
parents:
3570
diff
changeset
|
506 |
and:[(nameString at:2) == $\]) ifTrue:[ |
3815 | 507 |
"/ something like \\hostname |
508 |
^ true |
|
3708
27a62fa7b5bb
in #isVolumeAbsolute: care for filenames of the form: \hostname
Claus Gittinger <cg@exept.de>
parents:
3570
diff
changeset
|
509 |
]. |
27a62fa7b5bb
in #isVolumeAbsolute: care for filenames of the form: \hostname
Claus Gittinger <cg@exept.de>
parents:
3570
diff
changeset
|
510 |
^ false |
3336 | 511 |
|
3708
27a62fa7b5bb
in #isVolumeAbsolute: care for filenames of the form: \hostname
Claus Gittinger <cg@exept.de>
parents:
3570
diff
changeset
|
512 |
"Created: / 7.9.1997 / 23:54:20 / cg" |
3815 | 513 |
"Modified: / 9.9.1998 / 20:38:54 / cg" |
3708
27a62fa7b5bb
in #isVolumeAbsolute: care for filenames of the form: \hostname
Claus Gittinger <cg@exept.de>
parents:
3570
diff
changeset
|
514 |
! |
27a62fa7b5bb
in #isVolumeAbsolute: care for filenames of the form: \hostname
Claus Gittinger <cg@exept.de>
parents:
3570
diff
changeset
|
515 |
|
3336 | 516 |
localNameStringFrom:aString |
517 |
"ST-80 compatibility. |
|
518 |
what does this do ? (used in FileNavigator-goody). |
|
519 |
GUESS: does it strip off the voulume-character and initial '\' ?" |
|
520 |
||
521 |
(aString at:2) == $: ifTrue:[ |
|
522 |
(aString at:3) == $\ ifTrue:[ |
|
523 |
^ aString copyFrom:4 |
|
524 |
]. |
|
525 |
^ aString copyFrom:3 |
|
526 |
]. |
|
527 |
(aString at:1) == $\ ifTrue:[ |
|
528 |
^ aString copyFrom:1 |
|
529 |
]. |
|
530 |
^ aString |
|
3708
27a62fa7b5bb
in #isVolumeAbsolute: care for filenames of the form: \hostname
Claus Gittinger <cg@exept.de>
parents:
3570
diff
changeset
|
531 |
! |
27a62fa7b5bb
in #isVolumeAbsolute: care for filenames of the form: \hostname
Claus Gittinger <cg@exept.de>
parents:
3570
diff
changeset
|
532 |
|
3853 | 533 |
localPathName |
534 |
"return the full pathname of the file represented by the receiver, |
|
535 |
but without any volume information. |
|
536 |
Only makes a difference on MSDOS & VMS systems." |
|
537 |
||
538 |
|vol vsz rest| |
|
539 |
||
540 |
vol := self volume. |
|
541 |
(vsz := vol size) > 0 ifTrue:[ |
|
542 |
rest := nameString copyFrom:vsz + 1. |
|
543 |
rest size == 0 ifTrue:[ |
|
544 |
^ '\' |
|
545 |
]. |
|
546 |
(rest startsWith:$\) ifFalse:[ |
|
547 |
^ '\' , rest |
|
548 |
]. |
|
549 |
^ rest |
|
550 |
]. |
|
551 |
^ nameString |
|
552 |
||
553 |
" |
|
554 |
'\foo' asFilename localPathName |
|
555 |
'\foo\' asFilename localPathName |
|
556 |
'\foo\bar' asFilename localPathName |
|
557 |
'\foo\bar\' asFilename localPathName |
|
558 |
'c:' asFilename localPathName |
|
559 |
'c:\' asFilename localPathName |
|
560 |
'c:\foo' asFilename localPathName |
|
561 |
'c:\foo\' asFilename localPathName |
|
562 |
'c:\foo\bar' asFilename localPathName |
|
563 |
'c:\foo\bar\' asFilename localPathName |
|
564 |
'\\idefix' asFilename localPathName |
|
565 |
'\\idefix\home' asFilename localPathName |
|
566 |
'\\idefix\home\foo' asFilename localPathName |
|
567 |
" |
|
568 |
||
569 |
"Modified: / 24.9.1998 / 19:09:53 / cg" |
|
570 |
! |
|
571 |
||
3336 | 572 |
volume |
573 |
"return the disc volume part of the name or an empty string. |
|
3853 | 574 |
This is only used with DOS filenames - on unix, an empty string is returned. |
575 |
A full path can be reconstructed from |
|
576 |
aFilename volume , aFilename localPathName |
|
577 |
" |
|
3336 | 578 |
|
3853 | 579 |
|endIdx endIdx2| |
3850
f4d25f3deac8
fixes for network drives (isRootDirectory)
Claus Gittinger <cg@exept.de>
parents:
3848
diff
changeset
|
580 |
|
3848 | 581 |
nameString size >= 2 ifTrue:[ |
582 |
(nameString at:2) == $: ifTrue:[ |
|
3853 | 583 |
^ nameString copyTo:2 |
3848 | 584 |
]. |
3850
f4d25f3deac8
fixes for network drives (isRootDirectory)
Claus Gittinger <cg@exept.de>
parents:
3848
diff
changeset
|
585 |
(nameString startsWith:'\\') ifTrue:[ |
f4d25f3deac8
fixes for network drives (isRootDirectory)
Claus Gittinger <cg@exept.de>
parents:
3848
diff
changeset
|
586 |
endIdx := nameString indexOf:$\ startingAt:3. |
f4d25f3deac8
fixes for network drives (isRootDirectory)
Claus Gittinger <cg@exept.de>
parents:
3848
diff
changeset
|
587 |
endIdx == 0 ifTrue:[ |
3853 | 588 |
^ nameString. |
3850
f4d25f3deac8
fixes for network drives (isRootDirectory)
Claus Gittinger <cg@exept.de>
parents:
3848
diff
changeset
|
589 |
]. |
3853 | 590 |
endIdx2 := nameString indexOf:$\ startingAt:endIdx+1. |
591 |
endIdx2 == 0 ifTrue:[ |
|
592 |
^ nameString. |
|
593 |
]. |
|
594 |
^ nameString copyFrom:1 to:endIdx2-1 |
|
3850
f4d25f3deac8
fixes for network drives (isRootDirectory)
Claus Gittinger <cg@exept.de>
parents:
3848
diff
changeset
|
595 |
]. |
3336 | 596 |
]. |
3815 | 597 |
|
3336 | 598 |
^ '' |
599 |
||
3853 | 600 |
" |
601 |
'\foo' asFilename volume |
|
602 |
'\foo\' asFilename volume |
|
603 |
'\foo\bar' asFilename volume |
|
604 |
'\foo\bar\' asFilename volume |
|
605 |
'c:' asFilename volume |
|
606 |
'c:\' asFilename volume |
|
607 |
'c:\foo' asFilename volume |
|
608 |
'c:\foo\' asFilename volume |
|
609 |
'c:\foo\bar' asFilename volume |
|
610 |
'c:\foo\bar\' asFilename volume |
|
611 |
'c:\foo\bar\' asFilename localPathName |
|
612 |
'\\idefix' asFilename volume |
|
613 |
'\\idefix\home' asFilename volume |
|
614 |
'\\idefix\home\foo' asFilename volume |
|
615 |
'\\idefix\home\foo' asFilename localPathName |
|
616 |
" |
|
617 |
||
618 |
"Modified: / 24.9.1998 / 19:04:27 / cg" |
|
3708
27a62fa7b5bb
in #isVolumeAbsolute: care for filenames of the form: \hostname
Claus Gittinger <cg@exept.de>
parents:
3570
diff
changeset
|
619 |
! ! |
27a62fa7b5bb
in #isVolumeAbsolute: care for filenames of the form: \hostname
Claus Gittinger <cg@exept.de>
parents:
3570
diff
changeset
|
620 |
|
27a62fa7b5bb
in #isVolumeAbsolute: care for filenames of the form: \hostname
Claus Gittinger <cg@exept.de>
parents:
3570
diff
changeset
|
621 |
!PCFilename methodsFor:'special accessing'! |
27a62fa7b5bb
in #isVolumeAbsolute: care for filenames of the form: \hostname
Claus Gittinger <cg@exept.de>
parents:
3570
diff
changeset
|
622 |
|
7062 | 623 |
osNameForAccess |
624 |
^ nameString |
|
625 |
! |
|
626 |
||
3570 | 627 |
osNameForDirectory |
628 |
"special - return the OS's name for the receiver to |
|
629 |
access it as a directory. |
|
3749 | 630 |
Care remove trailing backSlashes here and to use the shortName |
631 |
if available" |
|
632 |
||
633 |
|n i shortName| |
|
3336 | 634 |
|
7062 | 635 |
(nameString includes:$~) ifTrue:[ |
636 |
self makeNonDOSName |
|
637 |
]. |
|
638 |
||
3749 | 639 |
((n := nameString) endsWith:'\') ifTrue:[ |
3765 | 640 |
((n size == 3) and:[(n at:2) == $:]) ifFalse:[ |
641 |
n := n copyWithoutLast:1 |
|
642 |
] |
|
3570 | 643 |
]. |
3765 | 644 |
"/ i := OperatingSystem infoOf:n. |
645 |
"/ (i notNil and:[(shortName := i alternativeName) notNil]) ifTrue:[ |
|
646 |
"/ ^ shortName |
|
647 |
"/ ]. |
|
3749 | 648 |
^ n |
3336 | 649 |
|
3721
75e65b780e45
oops - need a kludge to read the top directory.
Claus Gittinger <cg@exept.de>
parents:
3708
diff
changeset
|
650 |
"Modified: / 20.1.1998 / 15:39:06 / md" |
3765 | 651 |
"Modified: / 17.8.1998 / 10:04:01 / cg" |
3721
75e65b780e45
oops - need a kludge to read the top directory.
Claus Gittinger <cg@exept.de>
parents:
3708
diff
changeset
|
652 |
! |
75e65b780e45
oops - need a kludge to read the top directory.
Claus Gittinger <cg@exept.de>
parents:
3708
diff
changeset
|
653 |
|
75e65b780e45
oops - need a kludge to read the top directory.
Claus Gittinger <cg@exept.de>
parents:
3708
diff
changeset
|
654 |
osNameForDirectoryContents |
75e65b780e45
oops - need a kludge to read the top directory.
Claus Gittinger <cg@exept.de>
parents:
3708
diff
changeset
|
655 |
"special - return the OS's name for the receiver to |
75e65b780e45
oops - need a kludge to read the top directory.
Claus Gittinger <cg@exept.de>
parents:
3708
diff
changeset
|
656 |
access it as a directory for reading the contents. |
3765 | 657 |
Care to remove trailing backSlashes here" |
3721
75e65b780e45
oops - need a kludge to read the top directory.
Claus Gittinger <cg@exept.de>
parents:
3708
diff
changeset
|
658 |
|
75e65b780e45
oops - need a kludge to read the top directory.
Claus Gittinger <cg@exept.de>
parents:
3708
diff
changeset
|
659 |
(nameString endsWith:'\') ifTrue:[ |
3765 | 660 |
^ nameString copyWithoutLast:1 |
3721
75e65b780e45
oops - need a kludge to read the top directory.
Claus Gittinger <cg@exept.de>
parents:
3708
diff
changeset
|
661 |
]. |
75e65b780e45
oops - need a kludge to read the top directory.
Claus Gittinger <cg@exept.de>
parents:
3708
diff
changeset
|
662 |
^ nameString |
75e65b780e45
oops - need a kludge to read the top directory.
Claus Gittinger <cg@exept.de>
parents:
3708
diff
changeset
|
663 |
|
75e65b780e45
oops - need a kludge to read the top directory.
Claus Gittinger <cg@exept.de>
parents:
3708
diff
changeset
|
664 |
"Modified: / 20.1.1998 / 15:39:06 / md" |
75e65b780e45
oops - need a kludge to read the top directory.
Claus Gittinger <cg@exept.de>
parents:
3708
diff
changeset
|
665 |
"Created: / 3.8.1998 / 21:37:46 / cg" |
3765 | 666 |
"Modified: / 17.8.1998 / 10:04:22 / cg" |
3708
27a62fa7b5bb
in #isVolumeAbsolute: care for filenames of the form: \hostname
Claus Gittinger <cg@exept.de>
parents:
3570
diff
changeset
|
667 |
! |
27a62fa7b5bb
in #isVolumeAbsolute: care for filenames of the form: \hostname
Claus Gittinger <cg@exept.de>
parents:
3570
diff
changeset
|
668 |
|
7062 | 669 |
osNameForFile |
670 |
"special - return the OS's name for the receiver to |
|
671 |
access it as a directory. |
|
672 |
Care remove trailing backSlashes here and to use the shortName |
|
673 |
if available" |
|
674 |
||
675 |
(nameString includes:$~) ifTrue:[ |
|
676 |
self makeNonDOSName |
|
677 |
]. |
|
678 |
||
679 |
^ nameString |
|
680 |
! |
|
681 |
||
3570 | 682 |
setName:aString |
683 |
"set the filename" |
|
684 |
||
685 |
nameString := aString copy replaceAll:$/ with:$\ |
|
686 |
||
687 |
"Created: 22.1.1998 / 17:32:45 / md" |
|
3708
27a62fa7b5bb
in #isVolumeAbsolute: care for filenames of the form: \hostname
Claus Gittinger <cg@exept.de>
parents:
3570
diff
changeset
|
688 |
! ! |
27a62fa7b5bb
in #isVolumeAbsolute: care for filenames of the form: \hostname
Claus Gittinger <cg@exept.de>
parents:
3570
diff
changeset
|
689 |
|
27a62fa7b5bb
in #isVolumeAbsolute: care for filenames of the form: \hostname
Claus Gittinger <cg@exept.de>
parents:
3570
diff
changeset
|
690 |
!PCFilename class methodsFor:'documentation'! |
27a62fa7b5bb
in #isVolumeAbsolute: care for filenames of the form: \hostname
Claus Gittinger <cg@exept.de>
parents:
3570
diff
changeset
|
691 |
|
3336 | 692 |
version |
8548 | 693 |
^ '$Header: /cvs/stx/stx/libbasic/PCFilename.st,v 1.26 2004-09-17 11:13:18 ca Exp $' |
3708
27a62fa7b5bb
in #isVolumeAbsolute: care for filenames of the form: \hostname
Claus Gittinger <cg@exept.de>
parents:
3570
diff
changeset
|
694 |
! ! |