2911
|
1 |
'From Smalltalk/X, Version:3.1.9 on 9-sep-1997 at 11:55:40 pm' !
|
2907
|
2 |
|
|
3 |
Filename subclass:#OpenVMSFilename
|
|
4 |
instanceVariableNames:''
|
|
5 |
classVariableNames:''
|
|
6 |
poolDictionaries:''
|
|
7 |
category:'OS-OpenVMS'
|
|
8 |
!
|
|
9 |
|
2911
|
10 |
Object subclass:#NameComponents
|
|
11 |
instanceVariableNames:'volume directory filename'
|
|
12 |
classVariableNames:''
|
|
13 |
poolDictionaries:''
|
|
14 |
privateIn:OpenVMSFilename
|
|
15 |
!
|
|
16 |
|
|
17 |
!OpenVMSFilename class methodsFor:'documentation'!
|
|
18 |
|
|
19 |
documentation
|
|
20 |
"
|
|
21 |
Filenames in OpenVMS.
|
|
22 |
"
|
|
23 |
! !
|
|
24 |
|
2913
|
25 |
!OpenVMSFilename class methodsFor:'instance creation'!
|
|
26 |
|
|
27 |
currentDirectory
|
|
28 |
"return a filename for the current directory"
|
|
29 |
|
|
30 |
^ self named:'[]'
|
|
31 |
|
|
32 |
"
|
|
33 |
Filename currentDirectory
|
|
34 |
"
|
|
35 |
! !
|
|
36 |
|
2911
|
37 |
!OpenVMSFilename class methodsFor:'helpers'!
|
|
38 |
|
|
39 |
nameFromComponents:aComponentObject
|
|
40 |
"concatenate the components, return a fileNameString"
|
|
41 |
|
|
42 |
|s volume directory filename|
|
|
43 |
|
|
44 |
volume := aComponentObject volume.
|
|
45 |
directory := aComponentObject directory.
|
|
46 |
filename := aComponentObject filename.
|
|
47 |
|
|
48 |
volume notNil ifTrue:[
|
|
49 |
s := volume , ':'
|
|
50 |
] ifFalse:[
|
|
51 |
s := ''
|
|
52 |
].
|
|
53 |
directory notNil ifTrue:[
|
|
54 |
s := s , '[' , directory , ']'
|
|
55 |
].
|
|
56 |
filename notNil ifTrue:[
|
|
57 |
s := s , filename
|
|
58 |
].
|
|
59 |
s isEmpty ifTrue:[
|
|
60 |
^ '[]'
|
|
61 |
].
|
|
62 |
^ s
|
|
63 |
|
|
64 |
"Modified: 9.9.1997 / 09:38:41 / cg"
|
|
65 |
!
|
|
66 |
|
|
67 |
parseComponentsFrom:aString
|
|
68 |
"given a pathName, decompose into volume, directory & filename.
|
|
69 |
Return the components as a componentObject."
|
|
70 |
|
|
71 |
|v d f idx0 idx|
|
|
72 |
|
|
73 |
idx := aString indexOf:$:.
|
|
74 |
idx ~~ 0 ifTrue:[
|
|
75 |
v := aString copyTo:idx - 1.
|
|
76 |
].
|
|
77 |
idx := idx + 1.
|
|
78 |
(aString at:idx) == $[ ifTrue:[
|
|
79 |
idx0 := idx + 1.
|
|
80 |
idx := aString indexOf:$] startingAt:idx0.
|
|
81 |
idx == 0 ifTrue:[
|
|
82 |
"/ mhmh - malformed. what should we do here ?
|
|
83 |
self error:'malformed filename'
|
|
84 |
].
|
|
85 |
d := aString copyFrom:idx0 to:(idx-1).
|
|
86 |
idx := idx + 1.
|
|
87 |
].
|
|
88 |
f := aString copyFrom:idx.
|
|
89 |
^ NameComponents basicNew volume:v directory:d filename:f
|
|
90 |
|
|
91 |
"
|
|
92 |
OpenVMSFilename nameFromComponents:(OpenVMSFilename parseComponentsFrom:'dka100:[stx.libbasic]Object.st')
|
|
93 |
OpenVMSFilename nameFromComponents:(OpenVMSFilename parseComponentsFrom:'dka100:[stx.libbasic.-]Object.st')
|
|
94 |
OpenVMSFilename nameFromComponents:(OpenVMSFilename parseComponentsFrom:'dka100:[-]Object.st')
|
|
95 |
OpenVMSFilename nameFromComponents:(OpenVMSFilename parseComponentsFrom:'dka100:[]Object.st')
|
|
96 |
OpenVMSFilename nameFromComponents:(OpenVMSFilename parseComponentsFrom:'dka100:Object.st')
|
|
97 |
OpenVMSFilename nameFromComponents:(OpenVMSFilename parseComponentsFrom:'dka100:[stx.libbasic]')
|
|
98 |
"
|
|
99 |
|
|
100 |
"Modified: 9.9.1997 / 08:50:04 / cg"
|
|
101 |
! !
|
|
102 |
|
2907
|
103 |
!OpenVMSFilename class methodsFor:'queries'!
|
|
104 |
|
2911
|
105 |
directorySuffix
|
|
106 |
^ '.DIR'
|
|
107 |
!
|
|
108 |
|
2907
|
109 |
isBadCharacter:aCharacter
|
|
110 |
"return true, if aCharacter is unallowed in a filename."
|
|
111 |
|
|
112 |
('/\' includes:aCharacter) ifTrue:[^ true].
|
|
113 |
^ super isBadCharacter:aCharacter
|
|
114 |
|
|
115 |
"Created: 8.9.1997 / 00:14:47 / cg"
|
|
116 |
!
|
|
117 |
|
2911
|
118 |
isCaseSensitive
|
|
119 |
"return true, if filenames are case sensitive.return true, if filenames are case sensitive."
|
|
120 |
|
|
121 |
^ false
|
|
122 |
!
|
|
123 |
|
|
124 |
maxComponentLength
|
|
125 |
"return the maximum number of characters a filename component
|
|
126 |
may have in VMS"
|
|
127 |
|
|
128 |
^ 39
|
|
129 |
!
|
|
130 |
|
|
131 |
maxLength
|
|
132 |
"return the maximum number of characters a filename may have in VMS"
|
|
133 |
|
|
134 |
^ 1024
|
|
135 |
!
|
|
136 |
|
2907
|
137 |
separator
|
|
138 |
"return the file/directory separator.
|
|
139 |
For openVMS, the separator concept does not really fit,
|
2911
|
140 |
since names are composed as 'volume:[dir.dir.dir]file.ext'."
|
2907
|
141 |
|
|
142 |
^ $.
|
|
143 |
|
|
144 |
"
|
|
145 |
Filename concreteClass separator
|
|
146 |
"
|
|
147 |
|
|
148 |
"Created: 8.9.1997 / 00:17:28 / cg"
|
2911
|
149 |
"Modified: 9.9.1997 / 08:51:01 / cg"
|
2907
|
150 |
!
|
|
151 |
|
|
152 |
tempFileNameTemplate
|
|
153 |
"return a template for temporary files.
|
|
154 |
This is expanded with the current processID and a sequenceNumber
|
|
155 |
to generate a unique filename."
|
|
156 |
|
|
157 |
^ 'AAA_%1_%2.TMP'
|
|
158 |
|
|
159 |
"Created: 8.9.1997 / 00:01:46 / cg"
|
|
160 |
"Modified: 8.9.1997 / 00:29:23 / cg"
|
|
161 |
! !
|
|
162 |
|
2911
|
163 |
!OpenVMSFilename methodsFor:'instance creation'!
|
|
164 |
|
|
165 |
constructString:subname
|
|
166 |
"taking the receiver as a directory name, construct a new
|
|
167 |
filename-string for an entry within this directory
|
|
168 |
(i.e. for a file or a subdirectory in that directory)."
|
|
169 |
|
|
170 |
|v d f comps|
|
|
171 |
|
|
172 |
comps := self class parseComponentsFrom:nameString.
|
|
173 |
(f := comps filename) notNil ifTrue:[
|
|
174 |
"/ path was of the form vol:[d1...dN]foo
|
|
175 |
"/ assume foo is a directory and append it to directory path.
|
|
176 |
|
|
177 |
(f asUppercase endsWith:'.DIR') ifTrue:[
|
|
178 |
f := f copyWithoutLast:4
|
|
179 |
].
|
2913
|
180 |
d := comps directory.
|
|
181 |
d isNil ifTrue:[
|
|
182 |
d := f.
|
|
183 |
] ifFalse:[
|
|
184 |
d := d , '.' , f.
|
|
185 |
].
|
2911
|
186 |
comps directory:d.
|
|
187 |
].
|
|
188 |
comps filename:subname.
|
|
189 |
^ self class nameFromComponents:comps
|
|
190 |
|
|
191 |
"
|
|
192 |
(OpenVMSFilename named:'sys$root:[foo.bar]') construct:'baz'
|
|
193 |
(OpenVMSFilename named:'sys$root:[foo.bar]baz') construct:'foo'
|
|
194 |
"
|
|
195 |
|
|
196 |
"Modified: 9.9.1997 / 05:26:04 / cg"
|
|
197 |
! !
|
|
198 |
|
|
199 |
!OpenVMSFilename methodsFor:'queries'!
|
|
200 |
|
|
201 |
isAbsolute
|
|
202 |
"return true, if the receiver represents an absolute pathname
|
|
203 |
(in contrast to one relative to the current directory)."
|
|
204 |
|
|
205 |
|comps dir|
|
|
206 |
|
|
207 |
comps := self class parseComponentsFrom:nameString.
|
|
208 |
(dir := comps directory) isNil ifTrue:[
|
|
209 |
"/ mhmh ...
|
|
210 |
^ false
|
|
211 |
].
|
|
212 |
dir size == 0 ifTrue:[
|
|
213 |
"/ [] - the current directory is relative
|
|
214 |
^ false
|
|
215 |
].
|
|
216 |
dir = '-' ifTrue:[
|
|
217 |
"/ [-] - the parent directory is relative
|
|
218 |
^ false
|
|
219 |
].
|
|
220 |
(dir startsWith:'-.') ifTrue:[
|
|
221 |
"/ [-.] - some parent directory is relative
|
|
222 |
^ false
|
|
223 |
].
|
|
224 |
^ (dir startsWith:'.') not
|
|
225 |
|
|
226 |
"
|
|
227 |
(OpenVMSFilename named:'dka:[foo.bar]baz.st') isAbsolute
|
|
228 |
(OpenVMSFilename named:'[foo.bar]baz.st') isAbsolute
|
|
229 |
(OpenVMSFilename named:'[.foo.bar]baz.st') isAbsolute
|
|
230 |
(OpenVMSFilename named:'[]baz.st') isAbsolute
|
|
231 |
(OpenVMSFilename named:'[-]baz.st') isAbsolute
|
|
232 |
(OpenVMSFilename named:'[-.-]baz.st') isAbsolute
|
|
233 |
"
|
|
234 |
|
|
235 |
"Modified: 9.9.1997 / 09:03:42 / cg"
|
|
236 |
! !
|
|
237 |
|
|
238 |
!OpenVMSFilename methodsFor:'queries-path & name'!
|
|
239 |
|
|
240 |
baseName
|
|
241 |
"return my baseName as a string.
|
|
242 |
- thats the file/directory name without leading parent-dirs.
|
|
243 |
See also: #pathName, #directoryName and #directoryPathName.
|
|
244 |
Compatibility note: use #tail for ST-80 compatibility."
|
|
245 |
|
|
246 |
|idx d f comps|
|
|
247 |
|
|
248 |
comps := self class parseComponentsFrom:nameString.
|
|
249 |
(f := comps filename) size > 0 ifTrue:[
|
|
250 |
^ f
|
|
251 |
].
|
|
252 |
|
|
253 |
"/ path was of the form vol:[d1...dN]
|
|
254 |
"/ cut off the last directory.
|
|
255 |
d := comps directory.
|
|
256 |
d notNil ifTrue:[
|
|
257 |
d = '' ifTrue:[
|
|
258 |
"/ []
|
|
259 |
"/ ought to get the current directory ...
|
|
260 |
^ ''
|
|
261 |
].
|
|
262 |
d = '-' ifTrue:[
|
|
263 |
"/ [-]
|
|
264 |
"/ ought to get the current directory ...
|
|
265 |
^ ''
|
|
266 |
].
|
|
267 |
(d endsWith:'.-') ifTrue:[
|
|
268 |
"/ [rest.-]
|
|
269 |
"/ ought to expand and get final directory ...
|
|
270 |
^ ''
|
|
271 |
].
|
|
272 |
idx := d lastIndexOf:$..
|
|
273 |
idx ~~ 0 ifTrue:[
|
|
274 |
^ (d copyFrom:idx+1) , '.DIR'
|
|
275 |
].
|
|
276 |
^ d , '.DIR'
|
|
277 |
].
|
|
278 |
^ ''
|
|
279 |
|
|
280 |
"
|
|
281 |
(OpenVMSFilename named:'dka100:[stx.libbasic]Object.st') baseName
|
|
282 |
(OpenVMSFilename named:'stx$root:[stx.libbasic.-]Object.st') baseName
|
|
283 |
(OpenVMSFilename named:'[-]Object.st') baseName
|
|
284 |
(OpenVMSFilename named:'[]Object.st') baseName
|
|
285 |
(OpenVMSFilename named:'Object.st') baseName
|
|
286 |
(OpenVMSFilename named:'[stx.libbasic]') baseName
|
|
287 |
(OpenVMSFilename named:'[stx]') baseName
|
|
288 |
(OpenVMSFilename named:'[]') baseName
|
|
289 |
(OpenVMSFilename named:'[-]') baseName
|
|
290 |
"
|
|
291 |
|
|
292 |
"Created: 9.9.1997 / 09:23:15 / cg"
|
|
293 |
"Modified: 9.9.1997 / 10:52:04 / cg"
|
|
294 |
!
|
|
295 |
|
|
296 |
directoryName
|
|
297 |
"return the directory name part of the file/directory as a string.
|
|
298 |
- thats the name of the directory where the file/dir represented by
|
|
299 |
the receiver is contained in.
|
|
300 |
(this is almost equivalent to #directory, but returns
|
|
301 |
a string instead of a Filename instance).
|
|
302 |
See also: #pathName, #directoryPathName and #baseName.
|
|
303 |
Compatibility note: use #head for ST-80 compatibility."
|
|
304 |
|
|
305 |
|idx d f comps|
|
|
306 |
|
|
307 |
comps := self class parseComponentsFrom:nameString.
|
|
308 |
d := comps directory.
|
|
309 |
(f := comps filename) size > 0 ifTrue:[
|
|
310 |
comps filename:nil.
|
|
311 |
^ self class nameFromComponents:comps
|
|
312 |
].
|
|
313 |
|
|
314 |
"/ path was of the form vol:[d1...dN]
|
|
315 |
"/ cut off the last directory.
|
|
316 |
|
|
317 |
d isNil ifFalse:[
|
|
318 |
d = '' ifTrue:[
|
|
319 |
"/ [] -> [-]
|
|
320 |
] ifFalse:[
|
|
321 |
d = '-' ifTrue:[
|
|
322 |
"/ [-] -> [-.-]
|
|
323 |
d := '-.-'
|
|
324 |
] ifFalse:[
|
|
325 |
(d endsWith:'.-') ifTrue:[
|
|
326 |
"/ [rest.-] -> [rest.-.-]
|
|
327 |
d := d , '.-'
|
|
328 |
] ifFalse:[
|
|
329 |
idx := d lastIndexOf:$..
|
|
330 |
idx ~~ 0 ifTrue:[
|
|
331 |
d := d copyTo:idx-1
|
|
332 |
]
|
|
333 |
]
|
|
334 |
]
|
|
335 |
].
|
|
336 |
comps directory:d.
|
|
337 |
].
|
|
338 |
^ self class nameFromComponents:comps
|
|
339 |
|
|
340 |
"
|
|
341 |
(OpenVMSFilename named:'dka100:[stx.libbasic]Object.st') directoryName
|
|
342 |
(OpenVMSFilename named:'stx$root:[stx.libbasic.-]Object.st') directoryName
|
|
343 |
(OpenVMSFilename named:'[-]Object.st') directoryName
|
|
344 |
(OpenVMSFilename named:'[]Object.st') directoryName
|
|
345 |
(OpenVMSFilename named:'Object.st') directoryName
|
|
346 |
(OpenVMSFilename named:'[stx.libbasic]') directoryName
|
|
347 |
"
|
|
348 |
|
|
349 |
"Created: 9.9.1997 / 09:23:15 / cg"
|
|
350 |
"Modified: 9.9.1997 / 10:36:42 / cg"
|
|
351 |
!
|
|
352 |
|
|
353 |
volume
|
|
354 |
"return the disc volume part of the name or an empty string."
|
|
355 |
|
|
356 |
^ (self class parseComponentsFrom:nameString) volume ? ''
|
|
357 |
|
|
358 |
"
|
|
359 |
(OpenVMSFilename named:'dka100:[stx.libbasic]Object.st') volume
|
|
360 |
(OpenVMSFilename named:'stx$root:[stx.libbasic.-]Object.st') volume
|
|
361 |
(OpenVMSFilename named:'[-]Object.st') volume
|
|
362 |
(OpenVMSFilename named:'[]Object.st') volume
|
|
363 |
(OpenVMSFilename named:'Object.st') volume
|
|
364 |
(OpenVMSFilename named:'[stx.libbasic]') volume
|
|
365 |
"
|
|
366 |
|
|
367 |
"Modified: 9.9.1997 / 08:56:05 / cg"
|
|
368 |
! !
|
|
369 |
|
|
370 |
!OpenVMSFilename::NameComponents methodsFor:'accessing'!
|
|
371 |
|
|
372 |
directory
|
|
373 |
^ directory
|
|
374 |
|
|
375 |
"Created: 9.9.1997 / 05:21:04 / cg"
|
|
376 |
!
|
|
377 |
|
|
378 |
directory:aString
|
|
379 |
directory := aString
|
|
380 |
|
|
381 |
"Created: 9.9.1997 / 05:21:11 / cg"
|
|
382 |
!
|
|
383 |
|
|
384 |
filename
|
|
385 |
^ filename
|
|
386 |
|
|
387 |
"Created: 9.9.1997 / 05:21:23 / cg"
|
|
388 |
!
|
|
389 |
|
|
390 |
filename:aString
|
|
391 |
filename := aString
|
|
392 |
|
|
393 |
"Created: 9.9.1997 / 05:21:28 / cg"
|
|
394 |
!
|
|
395 |
|
|
396 |
volume
|
|
397 |
^ volume
|
|
398 |
|
|
399 |
"Created: 9.9.1997 / 05:20:58 / cg"
|
|
400 |
!
|
|
401 |
|
|
402 |
volume:aString
|
|
403 |
volume := aString
|
|
404 |
|
|
405 |
"Created: 9.9.1997 / 05:21:17 / cg"
|
|
406 |
!
|
|
407 |
|
|
408 |
volume:v directory:d filename:n
|
|
409 |
volume := v.
|
|
410 |
directory := d.
|
|
411 |
filename := n.
|
|
412 |
|
|
413 |
"Created: 9.9.1997 / 05:20:53 / cg"
|
|
414 |
! !
|
|
415 |
|
|
416 |
!OpenVMSFilename class methodsFor:'documentation'!
|
|
417 |
|
|
418 |
version
|
2913
|
419 |
^ '$Header: /cvs/stx/stx/libbasic/OpenVMSFilename.st,v 1.3 1997-09-09 18:39:30 cg Exp $'
|
2911
|
420 |
! !
|