author | Claus Gittinger <cg@exept.de> |
Tue, 17 Jun 2003 22:13:34 +0200 | |
changeset 7412 | daae29634e02 |
parent 7101 | bc6ce4e44acd |
child 7837 | e7f4d73e184c |
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 |
|
27a62fa7b5bb
in #isVolumeAbsolute: care for filenames of the form: \hostname
Claus Gittinger <cg@exept.de>
parents:
3570
diff
changeset
|
167 |
!PCFilename class methodsFor:'queries'! |
27a62fa7b5bb
in #isVolumeAbsolute: care for filenames of the form: \hostname
Claus Gittinger <cg@exept.de>
parents:
3570
diff
changeset
|
168 |
|
3336 | 169 |
isBadCharacter:aCharacter |
170 |
"return true, if aCharacter is unallowed in a filename." |
|
171 |
||
172 |
('<>:"/\|' includes:aCharacter) ifTrue:[^ true]. |
|
173 |
^ super isBadCharacter:aCharacter |
|
174 |
||
175 |
"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
|
176 |
! |
27a62fa7b5bb
in #isVolumeAbsolute: care for filenames of the form: \hostname
Claus Gittinger <cg@exept.de>
parents:
3570
diff
changeset
|
177 |
|
3336 | 178 |
isCaseSensitive |
179 |
"return true, if filenames are case sensitive." |
|
180 |
||
181 |
^ false |
|
3708
27a62fa7b5bb
in #isVolumeAbsolute: care for filenames of the form: \hostname
Claus Gittinger <cg@exept.de>
parents:
3570
diff
changeset
|
182 |
! |
27a62fa7b5bb
in #isVolumeAbsolute: care for filenames of the form: \hostname
Claus Gittinger <cg@exept.de>
parents:
3570
diff
changeset
|
183 |
|
3336 | 184 |
separator |
185 |
"return the file/directory separator." |
|
186 |
||
187 |
^ $\ |
|
188 |
||
189 |
" |
|
190 |
Filename concreteClass separator |
|
191 |
" |
|
192 |
||
193 |
"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
|
194 |
! |
27a62fa7b5bb
in #isVolumeAbsolute: care for filenames of the form: \hostname
Claus Gittinger <cg@exept.de>
parents:
3570
diff
changeset
|
195 |
|
3336 | 196 |
tempFileNameTemplate |
197 |
"return a template for temporary files. |
|
198 |
This is expanded with the current processID and a sequenceNumber |
|
199 |
to generate a unique filename. |
|
200 |
Redefined for MSDOS 8+3 filenames" |
|
201 |
||
3749 | 202 |
^ 'st%1%2' |
3336 | 203 |
|
204 |
"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
|
205 |
! ! |
27a62fa7b5bb
in #isVolumeAbsolute: care for filenames of the form: \hostname
Claus Gittinger <cg@exept.de>
parents:
3570
diff
changeset
|
206 |
|
3789 | 207 |
!PCFilename methodsFor:'converting'! |
208 |
||
7062 | 209 |
makeFullPathName |
210 |
"convert the receivers name to be a full filename, in case its an abbreviated (alternative) |
|
211 |
DOS name. |
|
212 |
This removes/replaces components of the form FOOBAR~n by the real, full components name." |
|
213 |
||
214 |
|directory baseName| |
|
215 |
||
216 |
(nameString includes:$~) ifFalse:[^self]. |
|
217 |
directory := self directoryName. |
|
218 |
baseName := self baseName. |
|
219 |
||
220 |
^ self |
|
221 |
||
222 |
" |
|
223 |
'hello world' asFilename makeLegalFilename |
|
224 |
'hello:world' asFilename makeLegalFilename |
|
225 |
'hello::world' asFilename makeLegalFilename |
|
226 |
'c:hello::world' asFilename makeLegalFilename |
|
227 |
'\\idefix' asFilename makeLegalFilename |
|
228 |
'\\idefix\' asFilename makeLegalFilename |
|
229 |
" |
|
230 |
||
231 |
"Modified: / 11.10.1998 / 01:40:47 / cg" |
|
232 |
! |
|
233 |
||
3789 | 234 |
makeLegalFilename |
235 |
"convert the receivers name to be a legal filename. |
|
236 |
This removes/replaces invalid characters and/or compresses |
|
237 |
the name as required by Win95-WinNT." |
|
238 |
||
239 |
|srchStart| |
|
240 |
||
241 |
"/ there may be only one colon in the name |
|
242 |
"/ (and if present, it must be the second character) |
|
243 |
||
244 |
((nameString size >= 2) |
|
245 |
and:[(nameString at:2) == $:]) ifTrue:[ |
|
246 |
srchStart := 3. |
|
247 |
] ifFalse:[ |
|
248 |
srchStart := 1 |
|
249 |
]. |
|
250 |
||
251 |
"/ replace colons by underscore |
|
252 |
"/ may need more to convert - time will show |
|
253 |
||
3873
4a81549760f7
also replace spaces by underlines to make a legal filename
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
254 |
(nameString indexOfAny:#($: $ ) startingAt:srchStart) ~~ 0 ifTrue:[ |
3789 | 255 |
nameString := nameString copy. |
3873
4a81549760f7
also replace spaces by underlines to make a legal filename
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
256 |
nameString replaceAny:#($: $ ) with:$_ from:srchStart to:(nameString size). |
3789 | 257 |
]. |
258 |
^ self |
|
259 |
||
260 |
" |
|
261 |
'hello world' asFilename makeLegalFilename |
|
262 |
'hello:world' asFilename makeLegalFilename |
|
263 |
'hello::world' asFilename makeLegalFilename |
|
264 |
'c:hello::world' asFilename makeLegalFilename |
|
3850
f4d25f3deac8
fixes for network drives (isRootDirectory)
Claus Gittinger <cg@exept.de>
parents:
3848
diff
changeset
|
265 |
'\\idefix' asFilename makeLegalFilename |
f4d25f3deac8
fixes for network drives (isRootDirectory)
Claus Gittinger <cg@exept.de>
parents:
3848
diff
changeset
|
266 |
'\\idefix\' asFilename makeLegalFilename |
3789 | 267 |
" |
268 |
||
3873
4a81549760f7
also replace spaces by underlines to make a legal filename
Claus Gittinger <cg@exept.de>
parents:
3853
diff
changeset
|
269 |
"Modified: / 11.10.1998 / 01:40:47 / cg" |
7062 | 270 |
! |
271 |
||
272 |
makeNonDOSName |
|
273 |
"convert the receivers name to be a full filename, in case its an abbreviated (alternative) DOS name. |
|
274 |
This removes/replaces components of the form FOOBAR~n by the real, full components name." |
|
275 |
||
7101 | 276 |
|directory baseName info| |
7062 | 277 |
|
278 |
(nameString includes:$~) ifFalse:[^self]. |
|
279 |
||
280 |
directory := self directory. |
|
281 |
baseName := self baseName. |
|
282 |
(baseName includes:$~) ifTrue:[ |
|
7101 | 283 |
info := self info. |
284 |
info notNil ifTrue:[ |
|
285 |
baseName := self info fullName. |
|
286 |
]. |
|
287 |
directory isRootDirectory ifFalse:[ |
|
288 |
directory makeNonDOSName. |
|
289 |
]. |
|
7062 | 290 |
]. |
7101 | 291 |
nameString := directory constructString:baseName |
7062 | 292 |
|
293 |
" |
|
294 |
Filename tempDirectory makeNonDOSName |
|
295 |
" |
|
296 |
||
297 |
"Modified: / 11.10.1998 / 01:40:47 / cg" |
|
3789 | 298 |
! ! |
299 |
||
3708
27a62fa7b5bb
in #isVolumeAbsolute: care for filenames of the form: \hostname
Claus Gittinger <cg@exept.de>
parents:
3570
diff
changeset
|
300 |
!PCFilename methodsFor:'file operations'! |
27a62fa7b5bb
in #isVolumeAbsolute: care for filenames of the form: \hostname
Claus Gittinger <cg@exept.de>
parents:
3570
diff
changeset
|
301 |
|
3570 | 302 |
renameTo:newName |
303 |
"rename the file - the argument must be convertable to a String. |
|
304 |
Raise an error if not successful. |
|
305 |
Redefined to delete any existing target-file first." |
|
3336 | 306 |
|
3570 | 307 |
newName asFilename exists ifTrue:[ |
308 |
newName asFilename delete |
|
309 |
]. |
|
310 |
||
311 |
^ super renameTo:newName |
|
3336 | 312 |
|
3570 | 313 |
" |
314 |
'\tmp\foo' asFilename renameTo:'\tmp\bar' |
|
315 |
" |
|
316 |
||
317 |
"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
|
318 |
! ! |
27a62fa7b5bb
in #isVolumeAbsolute: care for filenames of the form: \hostname
Claus Gittinger <cg@exept.de>
parents:
3570
diff
changeset
|
319 |
|
27a62fa7b5bb
in #isVolumeAbsolute: care for filenames of the form: \hostname
Claus Gittinger <cg@exept.de>
parents:
3570
diff
changeset
|
320 |
!PCFilename methodsFor:'queries'! |
27a62fa7b5bb
in #isVolumeAbsolute: care for filenames of the form: \hostname
Claus Gittinger <cg@exept.de>
parents:
3570
diff
changeset
|
321 |
|
4374
0b2a18a8cf84
fixed directoryName and isAbsolute.
Claus Gittinger <cg@exept.de>
parents:
3873
diff
changeset
|
322 |
directoryName |
0b2a18a8cf84
fixed directoryName and isAbsolute.
Claus Gittinger <cg@exept.de>
parents:
3873
diff
changeset
|
323 |
"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
|
324 |
- 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
|
325 |
the receiver is contained in. |
0b2a18a8cf84
fixed directoryName and isAbsolute.
Claus Gittinger <cg@exept.de>
parents:
3873
diff
changeset
|
326 |
This method does not check if the path is valid. |
0b2a18a8cf84
fixed directoryName and isAbsolute.
Claus Gittinger <cg@exept.de>
parents:
3873
diff
changeset
|
327 |
|
0b2a18a8cf84
fixed directoryName and isAbsolute.
Claus Gittinger <cg@exept.de>
parents:
3873
diff
changeset
|
328 |
(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
|
329 |
and '/usr/lib' asFilename directoryName -> /usr'). |
0b2a18a8cf84
fixed directoryName and isAbsolute.
Claus Gittinger <cg@exept.de>
parents:
3873
diff
changeset
|
330 |
|
0b2a18a8cf84
fixed directoryName and isAbsolute.
Claus Gittinger <cg@exept.de>
parents:
3873
diff
changeset
|
331 |
(this is almost equivalent to #directory, but returns |
0b2a18a8cf84
fixed directoryName and isAbsolute.
Claus Gittinger <cg@exept.de>
parents:
3873
diff
changeset
|
332 |
a string instead of a Filename instance). |
0b2a18a8cf84
fixed directoryName and isAbsolute.
Claus Gittinger <cg@exept.de>
parents:
3873
diff
changeset
|
333 |
|
0b2a18a8cf84
fixed directoryName and isAbsolute.
Claus Gittinger <cg@exept.de>
parents:
3873
diff
changeset
|
334 |
See also: #pathName, #directoryPathName and #baseName. |
0b2a18a8cf84
fixed directoryName and isAbsolute.
Claus Gittinger <cg@exept.de>
parents:
3873
diff
changeset
|
335 |
Compatibility note: use #head for ST-80 compatibility." |
0b2a18a8cf84
fixed directoryName and isAbsolute.
Claus Gittinger <cg@exept.de>
parents:
3873
diff
changeset
|
336 |
|
0b2a18a8cf84
fixed directoryName and isAbsolute.
Claus Gittinger <cg@exept.de>
parents:
3873
diff
changeset
|
337 |
|nm| |
0b2a18a8cf84
fixed directoryName and isAbsolute.
Claus Gittinger <cg@exept.de>
parents:
3873
diff
changeset
|
338 |
|
0b2a18a8cf84
fixed directoryName and isAbsolute.
Claus Gittinger <cg@exept.de>
parents:
3873
diff
changeset
|
339 |
nm := super directoryName. |
0b2a18a8cf84
fixed directoryName and isAbsolute.
Claus Gittinger <cg@exept.de>
parents:
3873
diff
changeset
|
340 |
(nm size == 2 and:[(nm at:2) == $:]) ifTrue:[ |
0b2a18a8cf84
fixed directoryName and isAbsolute.
Claus Gittinger <cg@exept.de>
parents:
3873
diff
changeset
|
341 |
^ nm , '\' |
0b2a18a8cf84
fixed directoryName and isAbsolute.
Claus Gittinger <cg@exept.de>
parents:
3873
diff
changeset
|
342 |
]. |
0b2a18a8cf84
fixed directoryName and isAbsolute.
Claus Gittinger <cg@exept.de>
parents:
3873
diff
changeset
|
343 |
^ nm |
0b2a18a8cf84
fixed directoryName and isAbsolute.
Claus Gittinger <cg@exept.de>
parents:
3873
diff
changeset
|
344 |
|
0b2a18a8cf84
fixed directoryName and isAbsolute.
Claus Gittinger <cg@exept.de>
parents:
3873
diff
changeset
|
345 |
" |
0b2a18a8cf84
fixed directoryName and isAbsolute.
Claus Gittinger <cg@exept.de>
parents:
3873
diff
changeset
|
346 |
(PCFilename named:'c:\users') directoryName |
0b2a18a8cf84
fixed directoryName and isAbsolute.
Claus Gittinger <cg@exept.de>
parents:
3873
diff
changeset
|
347 |
(PCFilename named:'c:\users') directory pathName |
0b2a18a8cf84
fixed directoryName and isAbsolute.
Claus Gittinger <cg@exept.de>
parents:
3873
diff
changeset
|
348 |
(PCFilename named:'c:\users') directory isRootDirectory |
0b2a18a8cf84
fixed directoryName and isAbsolute.
Claus Gittinger <cg@exept.de>
parents:
3873
diff
changeset
|
349 |
" |
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 |
|
3336 | 352 |
fileType |
353 |
"this returns a string describing the type of contents of |
|
354 |
the file. Here, the suffix is examined for a standard |
|
355 |
suffix and an appropriate string is returned. |
|
356 |
Poor MSDOS - no file command." |
|
357 |
||
358 |
|suff type info fmt| |
|
359 |
||
360 |
StandardSuffixTable isNil ifTrue:[ |
|
3570 | 361 |
self class initStandardSuffixTable |
3336 | 362 |
]. |
363 |
||
364 |
suff := self suffix asUppercase. |
|
365 |
type := StandardSuffixTable at:suff ifAbsent:nil. |
|
366 |
type isNil ifTrue:[ |
|
3570 | 367 |
type := super fileType. |
3336 | 368 |
]. |
369 |
^ type |
|
370 |
||
371 |
"Created: 16.10.1997 / 13:07:24 / cg" |
|
372 |
"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
|
373 |
! |
27a62fa7b5bb
in #isVolumeAbsolute: care for filenames of the form: \hostname
Claus Gittinger <cg@exept.de>
parents:
3570
diff
changeset
|
374 |
|
3850
f4d25f3deac8
fixes for network drives (isRootDirectory)
Claus Gittinger <cg@exept.de>
parents:
3848
diff
changeset
|
375 |
isDirectory |
f4d25f3deac8
fixes for network drives (isRootDirectory)
Claus Gittinger <cg@exept.de>
parents:
3848
diff
changeset
|
376 |
"return true, if I represent a root directory |
f4d25f3deac8
fixes for network drives (isRootDirectory)
Claus Gittinger <cg@exept.de>
parents:
3848
diff
changeset
|
377 |
(i.e. I have no parentDir). |
f4d25f3deac8
fixes for network drives (isRootDirectory)
Claus Gittinger <cg@exept.de>
parents:
3848
diff
changeset
|
378 |
Redefined to care for volumeRoots." |
f4d25f3deac8
fixes for network drives (isRootDirectory)
Claus Gittinger <cg@exept.de>
parents:
3848
diff
changeset
|
379 |
|
f4d25f3deac8
fixes for network drives (isRootDirectory)
Claus Gittinger <cg@exept.de>
parents:
3848
diff
changeset
|
380 |
self isRootDirectory ifTrue:[^ true]. |
f4d25f3deac8
fixes for network drives (isRootDirectory)
Claus Gittinger <cg@exept.de>
parents:
3848
diff
changeset
|
381 |
^super isDirectory. |
f4d25f3deac8
fixes for network drives (isRootDirectory)
Claus Gittinger <cg@exept.de>
parents:
3848
diff
changeset
|
382 |
|
f4d25f3deac8
fixes for network drives (isRootDirectory)
Claus Gittinger <cg@exept.de>
parents:
3848
diff
changeset
|
383 |
"Created: / 24.9.1998 / 14:04:31 / cg" |
f4d25f3deac8
fixes for network drives (isRootDirectory)
Claus Gittinger <cg@exept.de>
parents:
3848
diff
changeset
|
384 |
! |
f4d25f3deac8
fixes for network drives (isRootDirectory)
Claus Gittinger <cg@exept.de>
parents:
3848
diff
changeset
|
385 |
|
3336 | 386 |
isExecutableProgram |
387 |
"return true, if such a file exists and is an executable program. |
|
388 |
(i.e. for directories, false is returned.)" |
|
389 |
||
3815 | 390 |
|mySuffix| |
391 |
||
392 |
mySuffix := self suffix asLowercase. |
|
393 |
(mySuffix = 'exe' or:[mySuffix = 'com']) ifTrue:[ |
|
394 |
^ super isExecutableProgram |
|
3336 | 395 |
]. |
396 |
^ false |
|
397 |
||
3815 | 398 |
"Created: / 16.10.1997 / 13:19:10 / cg" |
399 |
"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
|
400 |
! |
27a62fa7b5bb
in #isVolumeAbsolute: care for filenames of the form: \hostname
Claus Gittinger <cg@exept.de>
parents:
3570
diff
changeset
|
401 |
|
3336 | 402 |
isExplicitRelative |
403 |
"return true, if this name is an explicit relative name |
|
404 |
(i.e. starts with './' or '../', to avoid path-prepending)" |
|
405 |
||
406 |
(nameString startsWith:'.\') ifTrue:[ |
|
407 |
^ true |
|
408 |
]. |
|
409 |
(nameString startsWith:'..\') ifTrue:[ |
|
410 |
^ true |
|
411 |
]. |
|
412 |
^ false |
|
3708
27a62fa7b5bb
in #isVolumeAbsolute: care for filenames of the form: \hostname
Claus Gittinger <cg@exept.de>
parents:
3570
diff
changeset
|
413 |
! |
27a62fa7b5bb
in #isVolumeAbsolute: care for filenames of the form: \hostname
Claus Gittinger <cg@exept.de>
parents:
3570
diff
changeset
|
414 |
|
3844
fb51bffc0aa3
redefined isRootDirectory for drive-letters & net-drives
Claus Gittinger <cg@exept.de>
parents:
3815
diff
changeset
|
415 |
isRootDirectory |
fb51bffc0aa3
redefined isRootDirectory for drive-letters & net-drives
Claus Gittinger <cg@exept.de>
parents:
3815
diff
changeset
|
416 |
"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
|
417 |
(i.e. I have no parentDir)" |
fb51bffc0aa3
redefined isRootDirectory for drive-letters & net-drives
Claus Gittinger <cg@exept.de>
parents:
3815
diff
changeset
|
418 |
|
3850
f4d25f3deac8
fixes for network drives (isRootDirectory)
Claus Gittinger <cg@exept.de>
parents:
3848
diff
changeset
|
419 |
|sz nm i| |
3844
fb51bffc0aa3
redefined isRootDirectory for drive-letters & net-drives
Claus Gittinger <cg@exept.de>
parents:
3815
diff
changeset
|
420 |
|
fb51bffc0aa3
redefined isRootDirectory for drive-letters & net-drives
Claus Gittinger <cg@exept.de>
parents:
3815
diff
changeset
|
421 |
nm := self pathName. |
3850
f4d25f3deac8
fixes for network drives (isRootDirectory)
Claus Gittinger <cg@exept.de>
parents:
3848
diff
changeset
|
422 |
sz := nm size. |
3844
fb51bffc0aa3
redefined isRootDirectory for drive-letters & net-drives
Claus Gittinger <cg@exept.de>
parents:
3815
diff
changeset
|
423 |
|
4374
0b2a18a8cf84
fixed directoryName and isAbsolute.
Claus Gittinger <cg@exept.de>
parents:
3873
diff
changeset
|
424 |
sz == 1 ifTrue:[ |
0b2a18a8cf84
fixed directoryName and isAbsolute.
Claus Gittinger <cg@exept.de>
parents:
3873
diff
changeset
|
425 |
(nm = '\') ifTrue:[ |
0b2a18a8cf84
fixed directoryName and isAbsolute.
Claus Gittinger <cg@exept.de>
parents:
3873
diff
changeset
|
426 |
"/ \ alone |
0b2a18a8cf84
fixed directoryName and isAbsolute.
Claus Gittinger <cg@exept.de>
parents:
3873
diff
changeset
|
427 |
^ true |
0b2a18a8cf84
fixed directoryName and isAbsolute.
Claus Gittinger <cg@exept.de>
parents:
3873
diff
changeset
|
428 |
] |
0b2a18a8cf84
fixed directoryName and isAbsolute.
Claus Gittinger <cg@exept.de>
parents:
3873
diff
changeset
|
429 |
]. |
0b2a18a8cf84
fixed directoryName and isAbsolute.
Claus Gittinger <cg@exept.de>
parents:
3873
diff
changeset
|
430 |
|
3850
f4d25f3deac8
fixes for network drives (isRootDirectory)
Claus Gittinger <cg@exept.de>
parents:
3848
diff
changeset
|
431 |
sz >= 2 ifTrue:[ |
f4d25f3deac8
fixes for network drives (isRootDirectory)
Claus Gittinger <cg@exept.de>
parents:
3848
diff
changeset
|
432 |
(nm at:2) == $: ifTrue:[ |
f4d25f3deac8
fixes for network drives (isRootDirectory)
Claus Gittinger <cg@exept.de>
parents:
3848
diff
changeset
|
433 |
sz == 2 ifTrue:[ |
f4d25f3deac8
fixes for network drives (isRootDirectory)
Claus Gittinger <cg@exept.de>
parents:
3848
diff
changeset
|
434 |
"/ <DRIVE-char>: |
f4d25f3deac8
fixes for network drives (isRootDirectory)
Claus Gittinger <cg@exept.de>
parents:
3848
diff
changeset
|
435 |
^ true |
f4d25f3deac8
fixes for network drives (isRootDirectory)
Claus Gittinger <cg@exept.de>
parents:
3848
diff
changeset
|
436 |
]. |
f4d25f3deac8
fixes for network drives (isRootDirectory)
Claus Gittinger <cg@exept.de>
parents:
3848
diff
changeset
|
437 |
sz == 3 ifTrue:[ |
f4d25f3deac8
fixes for network drives (isRootDirectory)
Claus Gittinger <cg@exept.de>
parents:
3848
diff
changeset
|
438 |
(nm at:3) == $\ ifTrue:[ |
f4d25f3deac8
fixes for network drives (isRootDirectory)
Claus Gittinger <cg@exept.de>
parents:
3848
diff
changeset
|
439 |
"/ <DRIVE-char>:\ |
f4d25f3deac8
fixes for network drives (isRootDirectory)
Claus Gittinger <cg@exept.de>
parents:
3848
diff
changeset
|
440 |
^ true |
f4d25f3deac8
fixes for network drives (isRootDirectory)
Claus Gittinger <cg@exept.de>
parents:
3848
diff
changeset
|
441 |
] |
f4d25f3deac8
fixes for network drives (isRootDirectory)
Claus Gittinger <cg@exept.de>
parents:
3848
diff
changeset
|
442 |
] |
f4d25f3deac8
fixes for network drives (isRootDirectory)
Claus Gittinger <cg@exept.de>
parents:
3848
diff
changeset
|
443 |
]. |
3844
fb51bffc0aa3
redefined isRootDirectory for drive-letters & net-drives
Claus Gittinger <cg@exept.de>
parents:
3815
diff
changeset
|
444 |
]. |
3850
f4d25f3deac8
fixes for network drives (isRootDirectory)
Claus Gittinger <cg@exept.de>
parents:
3848
diff
changeset
|
445 |
|
f4d25f3deac8
fixes for network drives (isRootDirectory)
Claus Gittinger <cg@exept.de>
parents:
3848
diff
changeset
|
446 |
"/ \\<REMOTE-HOST> |
3844
fb51bffc0aa3
redefined isRootDirectory for drive-letters & net-drives
Claus Gittinger <cg@exept.de>
parents:
3815
diff
changeset
|
447 |
(((nm size > 3) |
fb51bffc0aa3
redefined isRootDirectory for drive-letters & net-drives
Claus Gittinger <cg@exept.de>
parents:
3815
diff
changeset
|
448 |
and:[(nm at:1) == $\]) |
fb51bffc0aa3
redefined isRootDirectory for drive-letters & net-drives
Claus Gittinger <cg@exept.de>
parents:
3815
diff
changeset
|
449 |
and:[(nm at:2) == $\]) ifTrue:[ |
fb51bffc0aa3
redefined isRootDirectory for drive-letters & net-drives
Claus Gittinger <cg@exept.de>
parents:
3815
diff
changeset
|
450 |
"/ something like \\hostname\ |
fb51bffc0aa3
redefined isRootDirectory for drive-letters & net-drives
Claus Gittinger <cg@exept.de>
parents:
3815
diff
changeset
|
451 |
i := nm indexOf:$\ startingAt:4. |
3850
f4d25f3deac8
fixes for network drives (isRootDirectory)
Claus Gittinger <cg@exept.de>
parents:
3848
diff
changeset
|
452 |
((i == 0) or:[i == nameString size]) ifTrue:[ |
f4d25f3deac8
fixes for network drives (isRootDirectory)
Claus Gittinger <cg@exept.de>
parents:
3848
diff
changeset
|
453 |
"/ 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
|
454 |
^ true |
fb51bffc0aa3
redefined isRootDirectory for drive-letters & net-drives
Claus Gittinger <cg@exept.de>
parents:
3815
diff
changeset
|
455 |
]. |
3850
f4d25f3deac8
fixes for network drives (isRootDirectory)
Claus Gittinger <cg@exept.de>
parents:
3848
diff
changeset
|
456 |
i ~~ 0 ifTrue:[ |
f4d25f3deac8
fixes for network drives (isRootDirectory)
Claus Gittinger <cg@exept.de>
parents:
3848
diff
changeset
|
457 |
"/ something like \\hostname\dirName |
f4d25f3deac8
fixes for network drives (isRootDirectory)
Claus Gittinger <cg@exept.de>
parents:
3848
diff
changeset
|
458 |
i := nm indexOf:$\ startingAt:i+1. |
f4d25f3deac8
fixes for network drives (isRootDirectory)
Claus Gittinger <cg@exept.de>
parents:
3848
diff
changeset
|
459 |
((i == 0) or:[i == nameString size]) ifTrue:[ |
f4d25f3deac8
fixes for network drives (isRootDirectory)
Claus Gittinger <cg@exept.de>
parents:
3848
diff
changeset
|
460 |
"/ yeah - really a root |
f4d25f3deac8
fixes for network drives (isRootDirectory)
Claus Gittinger <cg@exept.de>
parents:
3848
diff
changeset
|
461 |
^ true |
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 |
]. |
fb51bffc0aa3
redefined isRootDirectory for drive-letters & net-drives
Claus Gittinger <cg@exept.de>
parents:
3815
diff
changeset
|
465 |
^ super isRootDirectory |
fb51bffc0aa3
redefined isRootDirectory for drive-letters & net-drives
Claus Gittinger <cg@exept.de>
parents:
3815
diff
changeset
|
466 |
|
fb51bffc0aa3
redefined isRootDirectory for drive-letters & net-drives
Claus Gittinger <cg@exept.de>
parents:
3815
diff
changeset
|
467 |
"Created: / 21.9.1998 / 15:37:41 / cg" |
3850
f4d25f3deac8
fixes for network drives (isRootDirectory)
Claus Gittinger <cg@exept.de>
parents:
3848
diff
changeset
|
468 |
"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
|
469 |
! |
fb51bffc0aa3
redefined isRootDirectory for drive-letters & net-drives
Claus Gittinger <cg@exept.de>
parents:
3815
diff
changeset
|
470 |
|
3336 | 471 |
isVolumeAbsolute |
472 |
"return true, if the receiver represents an absolute pathname |
|
473 |
on some disk volume." |
|
474 |
||
3815 | 475 |
"/ <DRIVE-CHAR>: |
3708
27a62fa7b5bb
in #isVolumeAbsolute: care for filenames of the form: \hostname
Claus Gittinger <cg@exept.de>
parents:
3570
diff
changeset
|
476 |
(((nameString size >= 3) |
27a62fa7b5bb
in #isVolumeAbsolute: care for filenames of the form: \hostname
Claus Gittinger <cg@exept.de>
parents:
3570
diff
changeset
|
477 |
and:[(nameString at:2) == $:]) |
27a62fa7b5bb
in #isVolumeAbsolute: care for filenames of the form: \hostname
Claus Gittinger <cg@exept.de>
parents:
3570
diff
changeset
|
478 |
and:[(nameString at:3) == $\]) ifTrue:[ |
3815 | 479 |
"/ something like x:\foo |
480 |
^ true |
|
3708
27a62fa7b5bb
in #isVolumeAbsolute: care for filenames of the form: \hostname
Claus Gittinger <cg@exept.de>
parents:
3570
diff
changeset
|
481 |
]. |
3815 | 482 |
|
483 |
"/ \\REMOTE-HOST: |
|
3708
27a62fa7b5bb
in #isVolumeAbsolute: care for filenames of the form: \hostname
Claus Gittinger <cg@exept.de>
parents:
3570
diff
changeset
|
484 |
(((nameString size >= 3) |
27a62fa7b5bb
in #isVolumeAbsolute: care for filenames of the form: \hostname
Claus Gittinger <cg@exept.de>
parents:
3570
diff
changeset
|
485 |
and:[(nameString at:1) == $\]) |
27a62fa7b5bb
in #isVolumeAbsolute: care for filenames of the form: \hostname
Claus Gittinger <cg@exept.de>
parents:
3570
diff
changeset
|
486 |
and:[(nameString at:2) == $\]) ifTrue:[ |
3815 | 487 |
"/ something like \\hostname |
488 |
^ true |
|
3708
27a62fa7b5bb
in #isVolumeAbsolute: care for filenames of the form: \hostname
Claus Gittinger <cg@exept.de>
parents:
3570
diff
changeset
|
489 |
]. |
27a62fa7b5bb
in #isVolumeAbsolute: care for filenames of the form: \hostname
Claus Gittinger <cg@exept.de>
parents:
3570
diff
changeset
|
490 |
^ false |
3336 | 491 |
|
3708
27a62fa7b5bb
in #isVolumeAbsolute: care for filenames of the form: \hostname
Claus Gittinger <cg@exept.de>
parents:
3570
diff
changeset
|
492 |
"Created: / 7.9.1997 / 23:54:20 / cg" |
3815 | 493 |
"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
|
494 |
! |
27a62fa7b5bb
in #isVolumeAbsolute: care for filenames of the form: \hostname
Claus Gittinger <cg@exept.de>
parents:
3570
diff
changeset
|
495 |
|
3336 | 496 |
localNameStringFrom:aString |
497 |
"ST-80 compatibility. |
|
498 |
what does this do ? (used in FileNavigator-goody). |
|
499 |
GUESS: does it strip off the voulume-character and initial '\' ?" |
|
500 |
||
501 |
(aString at:2) == $: ifTrue:[ |
|
502 |
(aString at:3) == $\ ifTrue:[ |
|
503 |
^ aString copyFrom:4 |
|
504 |
]. |
|
505 |
^ aString copyFrom:3 |
|
506 |
]. |
|
507 |
(aString at:1) == $\ ifTrue:[ |
|
508 |
^ aString copyFrom:1 |
|
509 |
]. |
|
510 |
^ aString |
|
3708
27a62fa7b5bb
in #isVolumeAbsolute: care for filenames of the form: \hostname
Claus Gittinger <cg@exept.de>
parents:
3570
diff
changeset
|
511 |
! |
27a62fa7b5bb
in #isVolumeAbsolute: care for filenames of the form: \hostname
Claus Gittinger <cg@exept.de>
parents:
3570
diff
changeset
|
512 |
|
3853 | 513 |
localPathName |
514 |
"return the full pathname of the file represented by the receiver, |
|
515 |
but without any volume information. |
|
516 |
Only makes a difference on MSDOS & VMS systems." |
|
517 |
||
518 |
|vol vsz rest| |
|
519 |
||
520 |
vol := self volume. |
|
521 |
(vsz := vol size) > 0 ifTrue:[ |
|
522 |
rest := nameString copyFrom:vsz + 1. |
|
523 |
rest size == 0 ifTrue:[ |
|
524 |
^ '\' |
|
525 |
]. |
|
526 |
(rest startsWith:$\) ifFalse:[ |
|
527 |
^ '\' , rest |
|
528 |
]. |
|
529 |
^ rest |
|
530 |
]. |
|
531 |
^ nameString |
|
532 |
||
533 |
" |
|
534 |
'\foo' asFilename localPathName |
|
535 |
'\foo\' asFilename localPathName |
|
536 |
'\foo\bar' asFilename localPathName |
|
537 |
'\foo\bar\' asFilename localPathName |
|
538 |
'c:' asFilename localPathName |
|
539 |
'c:\' asFilename localPathName |
|
540 |
'c:\foo' asFilename localPathName |
|
541 |
'c:\foo\' asFilename localPathName |
|
542 |
'c:\foo\bar' asFilename localPathName |
|
543 |
'c:\foo\bar\' asFilename localPathName |
|
544 |
'\\idefix' asFilename localPathName |
|
545 |
'\\idefix\home' asFilename localPathName |
|
546 |
'\\idefix\home\foo' asFilename localPathName |
|
547 |
" |
|
548 |
||
549 |
"Modified: / 24.9.1998 / 19:09:53 / cg" |
|
550 |
! |
|
551 |
||
3336 | 552 |
volume |
553 |
"return the disc volume part of the name or an empty string. |
|
3853 | 554 |
This is only used with DOS filenames - on unix, an empty string is returned. |
555 |
A full path can be reconstructed from |
|
556 |
aFilename volume , aFilename localPathName |
|
557 |
" |
|
3336 | 558 |
|
3853 | 559 |
|endIdx endIdx2| |
3850
f4d25f3deac8
fixes for network drives (isRootDirectory)
Claus Gittinger <cg@exept.de>
parents:
3848
diff
changeset
|
560 |
|
3848 | 561 |
nameString size >= 2 ifTrue:[ |
562 |
(nameString at:2) == $: ifTrue:[ |
|
3853 | 563 |
^ nameString copyTo:2 |
3848 | 564 |
]. |
3850
f4d25f3deac8
fixes for network drives (isRootDirectory)
Claus Gittinger <cg@exept.de>
parents:
3848
diff
changeset
|
565 |
(nameString startsWith:'\\') ifTrue:[ |
f4d25f3deac8
fixes for network drives (isRootDirectory)
Claus Gittinger <cg@exept.de>
parents:
3848
diff
changeset
|
566 |
endIdx := nameString indexOf:$\ startingAt:3. |
f4d25f3deac8
fixes for network drives (isRootDirectory)
Claus Gittinger <cg@exept.de>
parents:
3848
diff
changeset
|
567 |
endIdx == 0 ifTrue:[ |
3853 | 568 |
^ nameString. |
3850
f4d25f3deac8
fixes for network drives (isRootDirectory)
Claus Gittinger <cg@exept.de>
parents:
3848
diff
changeset
|
569 |
]. |
3853 | 570 |
endIdx2 := nameString indexOf:$\ startingAt:endIdx+1. |
571 |
endIdx2 == 0 ifTrue:[ |
|
572 |
^ nameString. |
|
573 |
]. |
|
574 |
^ nameString copyFrom:1 to:endIdx2-1 |
|
3850
f4d25f3deac8
fixes for network drives (isRootDirectory)
Claus Gittinger <cg@exept.de>
parents:
3848
diff
changeset
|
575 |
]. |
3336 | 576 |
]. |
3815 | 577 |
|
3336 | 578 |
^ '' |
579 |
||
3853 | 580 |
" |
581 |
'\foo' asFilename volume |
|
582 |
'\foo\' asFilename volume |
|
583 |
'\foo\bar' asFilename volume |
|
584 |
'\foo\bar\' asFilename volume |
|
585 |
'c:' asFilename volume |
|
586 |
'c:\' asFilename volume |
|
587 |
'c:\foo' asFilename volume |
|
588 |
'c:\foo\' asFilename volume |
|
589 |
'c:\foo\bar' asFilename volume |
|
590 |
'c:\foo\bar\' asFilename volume |
|
591 |
'c:\foo\bar\' asFilename localPathName |
|
592 |
'\\idefix' asFilename volume |
|
593 |
'\\idefix\home' asFilename volume |
|
594 |
'\\idefix\home\foo' asFilename volume |
|
595 |
'\\idefix\home\foo' asFilename localPathName |
|
596 |
" |
|
597 |
||
598 |
"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
|
599 |
! ! |
27a62fa7b5bb
in #isVolumeAbsolute: care for filenames of the form: \hostname
Claus Gittinger <cg@exept.de>
parents:
3570
diff
changeset
|
600 |
|
27a62fa7b5bb
in #isVolumeAbsolute: care for filenames of the form: \hostname
Claus Gittinger <cg@exept.de>
parents:
3570
diff
changeset
|
601 |
!PCFilename methodsFor:'special accessing'! |
27a62fa7b5bb
in #isVolumeAbsolute: care for filenames of the form: \hostname
Claus Gittinger <cg@exept.de>
parents:
3570
diff
changeset
|
602 |
|
7062 | 603 |
osNameForAccess |
604 |
^ nameString |
|
605 |
! |
|
606 |
||
3570 | 607 |
osNameForDirectory |
608 |
"special - return the OS's name for the receiver to |
|
609 |
access it as a directory. |
|
3749 | 610 |
Care remove trailing backSlashes here and to use the shortName |
611 |
if available" |
|
612 |
||
613 |
|n i shortName| |
|
3336 | 614 |
|
7062 | 615 |
(nameString includes:$~) ifTrue:[ |
616 |
self makeNonDOSName |
|
617 |
]. |
|
618 |
||
3749 | 619 |
((n := nameString) endsWith:'\') ifTrue:[ |
3765 | 620 |
((n size == 3) and:[(n at:2) == $:]) ifFalse:[ |
621 |
n := n copyWithoutLast:1 |
|
622 |
] |
|
3570 | 623 |
]. |
3765 | 624 |
"/ i := OperatingSystem infoOf:n. |
625 |
"/ (i notNil and:[(shortName := i alternativeName) notNil]) ifTrue:[ |
|
626 |
"/ ^ shortName |
|
627 |
"/ ]. |
|
3749 | 628 |
^ n |
3336 | 629 |
|
3721
75e65b780e45
oops - need a kludge to read the top directory.
Claus Gittinger <cg@exept.de>
parents:
3708
diff
changeset
|
630 |
"Modified: / 20.1.1998 / 15:39:06 / md" |
3765 | 631 |
"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
|
632 |
! |
75e65b780e45
oops - need a kludge to read the top directory.
Claus Gittinger <cg@exept.de>
parents:
3708
diff
changeset
|
633 |
|
75e65b780e45
oops - need a kludge to read the top directory.
Claus Gittinger <cg@exept.de>
parents:
3708
diff
changeset
|
634 |
osNameForDirectoryContents |
75e65b780e45
oops - need a kludge to read the top directory.
Claus Gittinger <cg@exept.de>
parents:
3708
diff
changeset
|
635 |
"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
|
636 |
access it as a directory for reading the contents. |
3765 | 637 |
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
|
638 |
|
75e65b780e45
oops - need a kludge to read the top directory.
Claus Gittinger <cg@exept.de>
parents:
3708
diff
changeset
|
639 |
(nameString endsWith:'\') ifTrue:[ |
3765 | 640 |
^ nameString copyWithoutLast:1 |
3721
75e65b780e45
oops - need a kludge to read the top directory.
Claus Gittinger <cg@exept.de>
parents:
3708
diff
changeset
|
641 |
]. |
75e65b780e45
oops - need a kludge to read the top directory.
Claus Gittinger <cg@exept.de>
parents:
3708
diff
changeset
|
642 |
^ nameString |
75e65b780e45
oops - need a kludge to read the top directory.
Claus Gittinger <cg@exept.de>
parents:
3708
diff
changeset
|
643 |
|
75e65b780e45
oops - need a kludge to read the top directory.
Claus Gittinger <cg@exept.de>
parents:
3708
diff
changeset
|
644 |
"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
|
645 |
"Created: / 3.8.1998 / 21:37:46 / cg" |
3765 | 646 |
"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
|
647 |
! |
27a62fa7b5bb
in #isVolumeAbsolute: care for filenames of the form: \hostname
Claus Gittinger <cg@exept.de>
parents:
3570
diff
changeset
|
648 |
|
7062 | 649 |
osNameForFile |
650 |
"special - return the OS's name for the receiver to |
|
651 |
access it as a directory. |
|
652 |
Care remove trailing backSlashes here and to use the shortName |
|
653 |
if available" |
|
654 |
||
655 |
(nameString includes:$~) ifTrue:[ |
|
656 |
self makeNonDOSName |
|
657 |
]. |
|
658 |
||
659 |
^ nameString |
|
660 |
! |
|
661 |
||
3570 | 662 |
setName:aString |
663 |
"set the filename" |
|
664 |
||
665 |
nameString := aString copy replaceAll:$/ with:$\ |
|
666 |
||
667 |
"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
|
668 |
! ! |
27a62fa7b5bb
in #isVolumeAbsolute: care for filenames of the form: \hostname
Claus Gittinger <cg@exept.de>
parents:
3570
diff
changeset
|
669 |
|
27a62fa7b5bb
in #isVolumeAbsolute: care for filenames of the form: \hostname
Claus Gittinger <cg@exept.de>
parents:
3570
diff
changeset
|
670 |
!PCFilename class methodsFor:'documentation'! |
27a62fa7b5bb
in #isVolumeAbsolute: care for filenames of the form: \hostname
Claus Gittinger <cg@exept.de>
parents:
3570
diff
changeset
|
671 |
|
3336 | 672 |
version |
7101 | 673 |
^ '$Header: /cvs/stx/stx/libbasic/PCFilename.st,v 1.24 2003-03-03 10:10:26 penk Exp $' |
3708
27a62fa7b5bb
in #isVolumeAbsolute: care for filenames of the form: \hostname
Claus Gittinger <cg@exept.de>
parents:
3570
diff
changeset
|
674 |
! ! |