2911
|
1 |
'From Smalltalk/X, Version:3.1.9 on 9-sep-1997 at 11:55:40 pm' !
|
2907
|
2 |
|
|
3 |
Filename subclass:#OpenVMSFilename
|
2925
|
4 |
instanceVariableNames:'osName'
|
2989
|
5 |
classVariableNames:'StandardSuffixTable PresentAsLowercase'
|
2907
|
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 |
|
2925
|
19 |
copyright
|
|
20 |
"
|
|
21 |
COPYRIGHT (c) 1997 by eXept Software AG
|
2980
|
22 |
All Rights Reserved
|
2925
|
23 |
|
|
24 |
This software is furnished under a license and may be used
|
|
25 |
only in accordance with the terms of that license and with the
|
|
26 |
inclusion of the above copyright notice. This software may not
|
|
27 |
be provided or otherwise made available to, or used by, any
|
|
28 |
other person. No title to or ownership of the software is
|
|
29 |
hereby transferred.
|
|
30 |
"
|
|
31 |
!
|
|
32 |
|
2911
|
33 |
documentation
|
|
34 |
"
|
|
35 |
Filenames in OpenVMS.
|
2925
|
36 |
|
|
37 |
For your convenience, UNIX style filenames are converted
|
|
38 |
to VMS format.
|
2911
|
39 |
"
|
|
40 |
! !
|
|
41 |
|
2925
|
42 |
!OpenVMSFilename class methodsFor:'initialization'!
|
|
43 |
|
|
44 |
initStandardSuffixTable
|
|
45 |
"since there is no 'file' command to extract the type,
|
|
46 |
return a guess based upon the files suffix. The following
|
|
47 |
table defines what is returned."
|
|
48 |
|
|
49 |
StandardSuffixTable := Dictionary new.
|
|
50 |
#(
|
2980
|
51 |
'COM' 'command procedure'
|
|
52 |
'DIR' 'directory'
|
|
53 |
'EXE' 'executable'
|
|
54 |
'LIS' 'listing'
|
|
55 |
'OBJ' 'object file'
|
|
56 |
'TMP' 'temporary'
|
|
57 |
'ADA' 'ADA source'
|
|
58 |
'BAS' 'basic source'
|
|
59 |
'C' 'c source'
|
|
60 |
'COB' 'cobol source'
|
|
61 |
'FOR' 'fortran source'
|
|
62 |
'PAS' 'pascal source'
|
|
63 |
'PL1' 'PL/1 source'
|
|
64 |
'ST' 'smalltalk source'
|
|
65 |
'STH' 'stc generated header'
|
2925
|
66 |
) pairWiseDo:[:k :v |
|
|
67 |
StandardSuffixTable at:k put:v
|
|
68 |
]
|
|
69 |
! !
|
|
70 |
|
2913
|
71 |
!OpenVMSFilename class methodsFor:'instance creation'!
|
|
72 |
|
|
73 |
currentDirectory
|
|
74 |
"return a filename for the current directory"
|
|
75 |
|
|
76 |
^ self named:'[]'
|
|
77 |
|
|
78 |
"
|
|
79 |
Filename currentDirectory
|
|
80 |
"
|
2925
|
81 |
!
|
|
82 |
|
|
83 |
rootDirectory
|
|
84 |
"return a filename for the root directory"
|
|
85 |
|
|
86 |
^ self named:'[000000]'
|
|
87 |
|
|
88 |
"
|
|
89 |
Filename rootDirectory
|
|
90 |
"
|
2913
|
91 |
! !
|
|
92 |
|
2925
|
93 |
!OpenVMSFilename class methodsFor:'parsing'!
|
|
94 |
|
|
95 |
components:aString
|
|
96 |
"break a filenameString into path components.
|
|
97 |
Cannot really do it, since applications assume, they can
|
|
98 |
create a valid path by concatenating a dirName, the separator
|
|
99 |
and a baseName."
|
|
100 |
|
|
101 |
|idx|
|
|
102 |
|
2934
|
103 |
idx := (aString lastIndexOf:$]) max:(aString lastIndexOf:self separator).
|
2925
|
104 |
idx ~~ 0 ifTrue:[
|
|
105 |
^ OrderedCollection
|
2980
|
106 |
with:(aString copyTo:idx)
|
2925
|
107 |
with:(aString copyFrom:idx+1)
|
|
108 |
].
|
|
109 |
^ OrderedCollection with:aString
|
|
110 |
! !
|
|
111 |
|
|
112 |
!OpenVMSFilename methodsFor:'helpers'!
|
2911
|
113 |
|
|
114 |
nameFromComponents:aComponentObject
|
|
115 |
"concatenate the components, return a fileNameString"
|
|
116 |
|
2925
|
117 |
|sv sd sf s sep volume directory filename dcomps idx|
|
2911
|
118 |
|
|
119 |
volume := aComponentObject volume.
|
|
120 |
directory := aComponentObject directory.
|
|
121 |
filename := aComponentObject filename.
|
|
122 |
|
|
123 |
volume notNil ifTrue:[
|
2980
|
124 |
sv := volume , ':'
|
2911
|
125 |
] ifFalse:[
|
2980
|
126 |
sv := ''
|
2925
|
127 |
].
|
|
128 |
directory size > 0 ifTrue:[
|
|
129 |
"/
|
|
130 |
"/ strip of '-''s - if possible
|
|
131 |
"/
|
|
132 |
(directory includes:$-) ifTrue:[
|
|
133 |
dcomps := directory asCollectionOfSubstringsSeparatedBy:$..
|
|
134 |
[(idx := dcomps indexOf:'-') > 1] whileTrue:[
|
|
135 |
((dcomps at:(idx-1)) ~= '-') ifTrue:[
|
|
136 |
dcomps := (dcomps copyTo:(idx-2)) , (dcomps copyFrom:idx+1)
|
|
137 |
]
|
|
138 |
].
|
|
139 |
directory := dcomps asStringWith:$.
|
|
140 |
].
|
2980
|
141 |
sd := '[' , directory , ']'
|
2925
|
142 |
] ifFalse:[
|
|
143 |
sd := ''
|
2911
|
144 |
].
|
2925
|
145 |
filename size > 0 ifTrue:[
|
|
146 |
"/
|
|
147 |
"/ soon no longer needed - I never create UNIX names
|
|
148 |
"/ internally ...
|
|
149 |
"/
|
|
150 |
(filename includesAny:'/\') ifTrue:[
|
|
151 |
(filename includes:$/) ifTrue:[
|
|
152 |
"/ a UNIX component given ...
|
|
153 |
sep := $/
|
|
154 |
] ifFalse:[
|
|
155 |
"/ an MSDOS component given ...
|
|
156 |
sep := $\
|
|
157 |
].
|
|
158 |
"/ special hack - convert UNIX/MSDOS path to VMS conventions
|
|
159 |
(filename startsWith:sep) ifTrue:[
|
|
160 |
"/ mhm that should not happen ...
|
|
161 |
filename := filename copyFrom:2
|
|
162 |
].
|
|
163 |
(filename endsWith:sep) ifTrue:[
|
|
164 |
"/ mhm that should not happen ...
|
|
165 |
filename := filename copyWithoutLast:1
|
|
166 |
].
|
|
167 |
dcomps := filename asCollectionOfSubstringsSeparatedBy:sep.
|
|
168 |
sf := dcomps last.
|
|
169 |
dcomps := dcomps copyWithoutLast:1.
|
|
170 |
dcomps := dcomps
|
|
171 |
collect:[:aDirComponent |
|
|
172 |
aDirComponent = '..' ifTrue:[
|
2980
|
173 |
'-'
|
2925
|
174 |
] ifFalse:[
|
2980
|
175 |
aDirComponent
|
2925
|
176 |
]
|
2980
|
177 |
].
|
|
178 |
directory size > 0 ifTrue:[
|
|
179 |
sd := '[' , directory , '.' , (dcomps asStringWith:$.) , ']'.
|
2925
|
180 |
] ifFalse:[
|
2980
|
181 |
sd := '[' , (dcomps asStringWith:$.) , ']'.
|
2925
|
182 |
]
|
|
183 |
] ifFalse:[
|
2980
|
184 |
sf := filename
|
2925
|
185 |
]
|
|
186 |
] ifFalse:[
|
|
187 |
sf := ''
|
2911
|
188 |
].
|
2925
|
189 |
s := sv, sd, sf.
|
2911
|
190 |
s isEmpty ifTrue:[
|
2980
|
191 |
^ '[]'
|
2911
|
192 |
].
|
2989
|
193 |
PresentAsLowercase == true ifTrue:[
|
|
194 |
^ s asLowercase
|
|
195 |
].
|
2911
|
196 |
^ s
|
|
197 |
|
|
198 |
"Modified: 9.9.1997 / 09:38:41 / cg"
|
|
199 |
!
|
|
200 |
|
2980
|
201 |
parseComponentsFrom:aString makeRelative:makeRelative
|
2911
|
202 |
"given a pathName, decompose into volume, directory & filename.
|
2925
|
203 |
Return the components as a componentObject (which is a dump
|
|
204 |
container for those components).
|
|
205 |
Beside parsing VMS filenames, this also detects UNIX and MSDOS
|
|
206 |
names and tries to convert them into VMS format - however,
|
|
207 |
in your applications you probably should not depend on this
|
|
208 |
to work out correctly every time. To make certain, only
|
|
209 |
provide relative UNIX/MSDOS pathnames (if at all)."
|
|
210 |
|
|
211 |
|nameString v d f idx0 idx idx1 idx2 dcomps sep abs len|
|
|
212 |
|
|
213 |
nameString := aString.
|
2911
|
214 |
|
2925
|
215 |
"/
|
|
216 |
"/ hack - allow Unix names ...
|
|
217 |
"/
|
|
218 |
nameString = '.' ifTrue:[
|
2980
|
219 |
"/ 'OpenVMSFilename [warning]: use of Unix name: ''.''' infoPrintCR.
|
|
220 |
nameString := '[]'.
|
2925
|
221 |
] ifFalse:[
|
2980
|
222 |
nameString = '..' ifTrue:[
|
|
223 |
"/ 'OpenVMSFilename [warning]: use of Unix name: ''..''' infoPrintCR.
|
|
224 |
nameString := '[-]'.
|
|
225 |
] ifFalse:[
|
2925
|
226 |
nameString = '/' ifTrue:[
|
2980
|
227 |
"/ 'OpenVMSFilename [warning]: use of Unix name: ''/''' infoPrintCR.
|
|
228 |
nameString := '[000000]'.
|
2925
|
229 |
]
|
|
230 |
]
|
|
231 |
].
|
|
232 |
|
|
233 |
"/
|
|
234 |
"/ a unix or msdos filename - convert.
|
|
235 |
"/
|
|
236 |
(nameString includesAny:'/\') ifTrue:[
|
|
237 |
(nameString includes:$/) ifTrue:[
|
|
238 |
"/ a UNIX component given ...
|
|
239 |
sep := $/
|
|
240 |
] ifFalse:[
|
|
241 |
"/ an MSDOS component given ...
|
|
242 |
sep := $\
|
|
243 |
].
|
2911
|
244 |
|
2965
|
245 |
"/ although not a legal VMS name,
|
2925
|
246 |
"/ we support the form volume:<unixPath>
|
|
247 |
"/ this makes your life easier in the FileBrowser
|
|
248 |
"/ or FileEntry dialogs. However, you should not
|
|
249 |
"/ place such filenames into your program, since
|
|
250 |
"/ those are not compatible with UNIX/MSDOS conventions
|
2965
|
251 |
"/ i.e. that should be used for user-entered pathNames only.
|
2925
|
252 |
"/
|
|
253 |
idx1 := nameString indexOf:sep.
|
|
254 |
idx2 := nameString indexOf:$:.
|
|
255 |
idx2 ~~ 0 ifTrue:[
|
|
256 |
idx2 < idx1 ifTrue:[
|
2980
|
257 |
"/
|
|
258 |
"/ something like:
|
|
259 |
"/ volume:<unixPath>
|
|
260 |
"/
|
2925
|
261 |
v := nameString copyTo:idx2-1.
|
|
262 |
nameString := nameString copyFrom:idx2+1.
|
|
263 |
idx1 := nameString indexOf:$/.
|
|
264 |
]
|
|
265 |
].
|
|
266 |
abs := false.
|
|
267 |
(nameString startsWith:sep) ifTrue:[
|
|
268 |
abs := true.
|
|
269 |
nameString := nameString copyFrom:2.
|
|
270 |
[nameString startsWith:sep] whileTrue:[
|
2980
|
271 |
nameString := nameString copyFrom:2.
|
2925
|
272 |
]
|
|
273 |
].
|
|
274 |
|
2980
|
275 |
[nameString size > 2
|
2974
|
276 |
and:[(nameString at:1) == $.
|
|
277 |
and:[(nameString at:2) == sep]]] whileTrue:[
|
|
278 |
nameString := nameString copyFrom:3.
|
2980
|
279 |
].
|
2974
|
280 |
|
2925
|
281 |
dcomps := nameString asCollectionOfSubstringsSeparatedBy:$/.
|
|
282 |
|
|
283 |
"/
|
|
284 |
"/ replace '..' by '-'
|
|
285 |
"/
|
|
286 |
f := dcomps last.
|
2974
|
287 |
dcomps := dcomps copyWithoutLast:1.
|
|
288 |
dcomps size > 0 ifTrue:[
|
|
289 |
dcomps replaceAll:'..' with:'-'.
|
|
290 |
d := dcomps asStringWith:$..
|
|
291 |
abs ifFalse:[
|
2980
|
292 |
makeRelative ifTrue:[
|
|
293 |
d := '.' , d
|
|
294 |
]
|
2974
|
295 |
].
|
|
296 |
nameString := '[' , d , ']' , f
|
|
297 |
] ifFalse:[
|
|
298 |
nameString := f
|
|
299 |
]
|
2925
|
300 |
].
|
|
301 |
|
|
302 |
nameString = '[]' ifTrue:[
|
|
303 |
"/ replace by currentDirectory
|
|
304 |
nameString := OperatingSystem pathNameOf:'[]'
|
|
305 |
].
|
|
306 |
|
|
307 |
len := nameString size.
|
|
308 |
|
|
309 |
"/
|
|
310 |
"/ is there a volume ?
|
|
311 |
"/
|
|
312 |
idx := nameString indexOf:$:.
|
2911
|
313 |
idx ~~ 0 ifTrue:[
|
2980
|
314 |
v := nameString copyTo:idx - 1.
|
2925
|
315 |
"/ eat up any additional colons
|
|
316 |
[(idx < len) and:[(nameString at:idx+1)==$:]] whileTrue:[
|
|
317 |
idx := idx + 1
|
|
318 |
]
|
2911
|
319 |
].
|
|
320 |
idx := idx + 1.
|
2925
|
321 |
idx > len ifTrue:[
|
|
322 |
"/
|
|
323 |
"/ a volume alone; i.e.
|
|
324 |
"/ something like: 'volume:'
|
|
325 |
"/
|
|
326 |
] ifFalse:[
|
|
327 |
d := ''.
|
2980
|
328 |
[(idx < len)
|
2925
|
329 |
and:[(nameString at:idx) == $[ ]] whileTrue:[
|
2980
|
330 |
idx0 := idx + 1.
|
|
331 |
idx := nameString indexOf:$] startingAt:idx0.
|
|
332 |
idx == 0 ifTrue:[
|
|
333 |
"/ mhmh - malformed. what should we do here ?
|
|
334 |
self error:'malformed filename'
|
|
335 |
].
|
2925
|
336 |
d isEmpty ifTrue:[
|
2980
|
337 |
d := nameString copyFrom:idx0 to:(idx-1).
|
2925
|
338 |
] ifFalse:[
|
2965
|
339 |
(d endsWith:$.) ifTrue:[
|
|
340 |
d := d , (nameString copyFrom:idx0 to:(idx-1)).
|
|
341 |
] ifFalse:[
|
|
342 |
d := d , '.' , (nameString copyFrom:idx0 to:(idx-1)).
|
|
343 |
]
|
2925
|
344 |
].
|
2980
|
345 |
idx := idx + 1.
|
2925
|
346 |
|
|
347 |
"/ eat up any additional colons
|
|
348 |
[(idx <= len) and:[(nameString at:idx)==$:]] whileTrue:[
|
2980
|
349 |
idx := idx + 1
|
2925
|
350 |
]
|
2980
|
351 |
].
|
|
352 |
f := nameString copyFrom:idx.
|
2925
|
353 |
"/ if the directory starts with '000000.', cut it off
|
|
354 |
(d startsWith:'000000.') ifTrue:[
|
|
355 |
d := d copyFrom:8
|
|
356 |
].
|
|
357 |
|
|
358 |
"/ check if the filename component has multiple '.'
|
|
359 |
"/ characters in it; if so, translate them into
|
|
360 |
"/ underscore characters (except for the last one).
|
|
361 |
f size > 0 ifTrue:[
|
|
362 |
(f occurrencesOf:$.) > 1 ifTrue:[
|
|
363 |
f replaceAll:$. with:$_ from:1 to:(f lastIndexOf:$.)-1.
|
|
364 |
]
|
|
365 |
].
|
2911
|
366 |
].
|
|
367 |
^ NameComponents basicNew volume:v directory:d filename:f
|
|
368 |
|
|
369 |
"Modified: 9.9.1997 / 08:50:04 / cg"
|
2980
|
370 |
!
|
|
371 |
|
|
372 |
parseComponentsFrom:aString
|
|
373 |
"given a pathName, decompose into volume, directory & filename.
|
|
374 |
Return the components as a componentObject (which is a dump
|
|
375 |
container for those components).
|
|
376 |
Beside parsing VMS filenames, this also detects UNIX and MSDOS
|
|
377 |
names and tries to convert them into VMS format - however,
|
|
378 |
in your applications you probably should not depend on this
|
|
379 |
to work out correctly every time. To make certain, only
|
|
380 |
provide relative UNIX/MSDOS pathnames (if at all)."
|
|
381 |
|
|
382 |
^ self
|
|
383 |
parseComponentsFrom:aString
|
|
384 |
makeRelative:true
|
2911
|
385 |
! !
|
|
386 |
|
2907
|
387 |
!OpenVMSFilename class methodsFor:'queries'!
|
|
388 |
|
2948
|
389 |
defaultTempDirectoryName
|
|
390 |
"return the default temp directory as a filename.
|
|
391 |
Here, the presence of a sys$tmp: or sys$scratch: volume
|
|
392 |
is checked, and if so, returned. Otherwise, the current directory
|
|
393 |
is returned.
|
|
394 |
This is used, if no special preferences were defined in
|
|
395 |
any of the TEMP-environment variables (see tempDirectory)."
|
|
396 |
|
|
397 |
#( 'sys$tmp:[000000]' 'sys$scratch:[000000]')
|
|
398 |
do:[:try |
|
|
399 |
|fn|
|
|
400 |
|
|
401 |
fn := try asFilename.
|
2980
|
402 |
(fn isDirectory
|
2960
|
403 |
and:[fn canBeWritten
|
|
404 |
and:[fn isReadable]]) ifTrue:[
|
2948
|
405 |
^ try
|
|
406 |
]
|
|
407 |
].
|
|
408 |
|
|
409 |
"/ fallBack - use current.
|
|
410 |
^ '.'
|
|
411 |
|
|
412 |
"
|
|
413 |
OpenVMSFilename defaultTempDirectoryName
|
|
414 |
"
|
|
415 |
!
|
|
416 |
|
2911
|
417 |
directorySuffix
|
2965
|
418 |
"Return the suffix for directories.
|
|
419 |
In VMS, all directories have a '.dir' extension."
|
|
420 |
|
|
421 |
^ 'DIR'
|
2911
|
422 |
!
|
|
423 |
|
2907
|
424 |
isBadCharacter:aCharacter
|
|
425 |
"return true, if aCharacter is unallowed in a filename."
|
|
426 |
|
|
427 |
('/\' includes:aCharacter) ifTrue:[^ true].
|
|
428 |
^ super isBadCharacter:aCharacter
|
|
429 |
|
|
430 |
"Created: 8.9.1997 / 00:14:47 / cg"
|
|
431 |
!
|
|
432 |
|
2911
|
433 |
isCaseSensitive
|
|
434 |
"return true, if filenames are case sensitive.return true, if filenames are case sensitive."
|
|
435 |
|
|
436 |
^ false
|
|
437 |
!
|
|
438 |
|
|
439 |
maxComponentLength
|
|
440 |
"return the maximum number of characters a filename component
|
|
441 |
may have in VMS"
|
|
442 |
|
|
443 |
^ 39
|
|
444 |
!
|
|
445 |
|
|
446 |
maxLength
|
|
447 |
"return the maximum number of characters a filename may have in VMS"
|
|
448 |
|
|
449 |
^ 1024
|
|
450 |
!
|
|
451 |
|
2907
|
452 |
separator
|
|
453 |
"return the file/directory separator.
|
|
454 |
For openVMS, the separator concept does not really fit,
|
2911
|
455 |
since names are composed as 'volume:[dir.dir.dir]file.ext'."
|
2907
|
456 |
|
|
457 |
^ $.
|
|
458 |
|
|
459 |
"
|
|
460 |
Filename concreteClass separator
|
|
461 |
"
|
|
462 |
|
|
463 |
"Created: 8.9.1997 / 00:17:28 / cg"
|
2911
|
464 |
"Modified: 9.9.1997 / 08:51:01 / cg"
|
2907
|
465 |
!
|
|
466 |
|
|
467 |
tempFileNameTemplate
|
|
468 |
"return a template for temporary files.
|
|
469 |
This is expanded with the current processID and a sequenceNumber
|
|
470 |
to generate a unique filename."
|
|
471 |
|
2974
|
472 |
^ 'AAA_%1_%2.DIR'
|
2907
|
473 |
|
|
474 |
"Created: 8.9.1997 / 00:01:46 / cg"
|
|
475 |
"Modified: 8.9.1997 / 00:29:23 / cg"
|
|
476 |
! !
|
|
477 |
|
2925
|
478 |
!OpenVMSFilename methodsFor:'file queries'!
|
|
479 |
|
|
480 |
fileType
|
|
481 |
"this returns a string describing the type of contents of
|
|
482 |
the file. Here, the suffix is examined for a standard
|
|
483 |
suffix and an appropriate string is returned.
|
|
484 |
Poor VMS - no file command."
|
|
485 |
|
|
486 |
|suff type info fmt|
|
|
487 |
|
|
488 |
StandardSuffixTable isNil ifTrue:[
|
|
489 |
self class initStandardSuffixTable
|
|
490 |
].
|
|
491 |
|
|
492 |
suff := self suffix asUppercase.
|
|
493 |
type := StandardSuffixTable at:suff ifAbsent:nil.
|
|
494 |
type isNil ifTrue:[
|
2937
|
495 |
type := super fileType.
|
2925
|
496 |
type = 'file' ifTrue:[
|
|
497 |
"/ look at its record format
|
|
498 |
info := self info.
|
|
499 |
fmt := info recordFormat ? ''.
|
|
500 |
fmt size > 0 ifTrue:[
|
2980
|
501 |
type := type , ' (' , fmt ,')'
|
2925
|
502 |
]
|
|
503 |
]
|
|
504 |
].
|
|
505 |
^ type
|
3042
|
506 |
! !
|
2948
|
507 |
|
|
508 |
!OpenVMSFilename methodsFor:'queries'!
|
|
509 |
|
|
510 |
isExecutableProgram
|
|
511 |
"return true, if such a file exists and is an executable program.
|
|
512 |
(i.e. for directories, false is returned.)"
|
|
513 |
|
|
514 |
(self hasSuffix:'exe') ifTrue:[
|
|
515 |
^ super isExecutableProgram
|
|
516 |
].
|
|
517 |
^ false
|
2925
|
518 |
! !
|
|
519 |
|
2989
|
520 |
!OpenVMSFilename methodsFor:'queries - contents'!
|
|
521 |
|
|
522 |
directoryContents
|
|
523 |
|cont|
|
|
524 |
|
|
525 |
cont := super directoryContents.
|
|
526 |
PresentAsLowercase == true ifTrue:[
|
|
527 |
cont := cont collect:[:nm | nm asLowercase]
|
|
528 |
].
|
|
529 |
^ cont
|
|
530 |
|
|
531 |
"
|
|
532 |
PresentAsLowercase := true
|
|
533 |
PresentAsLowercase := false
|
|
534 |
"
|
|
535 |
!
|
|
536 |
|
|
537 |
fullDirectoryContents
|
|
538 |
|cont|
|
|
539 |
|
|
540 |
cont := super fullDirectoryContents.
|
|
541 |
PresentAsLowercase == true ifTrue:[
|
|
542 |
cont := cont collect:[:nm | nm asLowercase]
|
|
543 |
].
|
|
544 |
^ cont
|
|
545 |
! !
|
|
546 |
|
2925
|
547 |
!OpenVMSFilename methodsFor:'private accessing'!
|
|
548 |
|
|
549 |
osNameForDirectory
|
|
550 |
"internal - return the OS's name for the receiver when
|
|
551 |
used as a directory.
|
|
552 |
On VMS, a path like '[dir1]dir2' must be converted to
|
|
553 |
'[dir1.dir2]' in order for the OS calls to retrieve
|
|
554 |
correct information."
|
|
555 |
|
|
556 |
|comps f d|
|
|
557 |
|
|
558 |
comps := self parseComponentsFrom:nameString.
|
|
559 |
d := comps directory.
|
|
560 |
|
|
561 |
(f := comps filename) size > 0 ifTrue:[
|
|
562 |
(f asUppercase endsWith:'.DIR') ifTrue:[
|
|
563 |
f := f copyWithoutLast:4
|
|
564 |
].
|
|
565 |
|
|
566 |
"/ something like v:file or v:[dir]file
|
|
567 |
"/ make it: v:[.file] or v:[dir.file]
|
|
568 |
|
|
569 |
d isNil ifTrue:[
|
|
570 |
d := ''
|
|
571 |
].
|
2980
|
572 |
(comps volume size ~~ 0
|
|
573 |
and:[d size == 0]) ifTrue:[
|
|
574 |
comps directory:f
|
|
575 |
] ifFalse:[
|
|
576 |
comps directory:(d , '.' , f).
|
|
577 |
].
|
2925
|
578 |
comps filename:''.
|
|
579 |
^ self nameFromComponents:comps
|
|
580 |
].
|
|
581 |
|
|
582 |
"/ ok, an empty fileName
|
|
583 |
d size == 0 ifTrue:[
|
|
584 |
"/ v: -> v:[000000]
|
2980
|
585 |
|
2925
|
586 |
comps directory:'000000'.
|
|
587 |
^ self nameFromComponents:comps
|
|
588 |
].
|
|
589 |
|
|
590 |
"/ v:[d1.d2] -> remains
|
|
591 |
^ nameString
|
|
592 |
!
|
|
593 |
|
|
594 |
osNameForFile
|
|
595 |
"internal - return the OS's name for the receiver.
|
|
596 |
On VMS, a path like '[dir1.dir2]' must be converted to
|
|
597 |
'[dir1]dir2.dir' in order for the OS calls to retrieve
|
|
598 |
correct information."
|
|
599 |
|
|
600 |
|comps f d v idx|
|
|
601 |
|
|
602 |
osName notNil ifTrue:[^ osName].
|
|
603 |
|
|
604 |
comps := self parseComponentsFrom:nameString.
|
|
605 |
d := comps directory.
|
|
606 |
|
|
607 |
(f := comps filename) size > 0 ifTrue:[
|
|
608 |
d size == 0 ifTrue:[
|
|
609 |
v := comps volume.
|
|
610 |
v size > 0 ifTrue:[
|
2980
|
611 |
"/ something like v:file
|
|
612 |
"/ make it: v:[000000]file
|
|
613 |
comps directory:'000000'.
|
2925
|
614 |
].
|
|
615 |
].
|
2932
|
616 |
"/
|
|
617 |
"/ if it has no suffix, at least append a suffix character
|
|
618 |
"/
|
|
619 |
(f includes:$.) ifFalse:[
|
2937
|
620 |
f := f , '.'.
|
|
621 |
comps filename:f.
|
|
622 |
].
|
|
623 |
(f endsWith:'.') ifTrue:[
|
|
624 |
"/ no suffix -> make it '.dir'
|
|
625 |
f := f , 'DIR'.
|
|
626 |
comps filename:f.
|
2932
|
627 |
].
|
2925
|
628 |
osName := self nameFromComponents:comps.
|
|
629 |
^ osName
|
|
630 |
].
|
|
631 |
|
|
632 |
"/ ok, an empty fileName
|
|
633 |
d size > 0 ifTrue:[
|
2980
|
634 |
idx := d lastIndexOf:$..
|
|
635 |
idx ~~ 0 ifTrue:[
|
2925
|
636 |
"/
|
|
637 |
"/ something like: '[d1.d2]' -> '[d1]d2.DIR'
|
|
638 |
"/
|
|
639 |
comps directory:(d copyTo:(idx-1)).
|
|
640 |
comps filename:((d copyFrom:idx+1) , '.DIR').
|
2980
|
641 |
osName := self nameFromComponents:comps.
|
2925
|
642 |
^ osName
|
2980
|
643 |
].
|
2925
|
644 |
"/
|
|
645 |
"/ something like: '[d]' -> '[000000]d.DIR'
|
|
646 |
"/
|
|
647 |
comps directory:'000000'.
|
|
648 |
comps filename:(d , '.DIR').
|
|
649 |
osName := self nameFromComponents:comps.
|
|
650 |
^ osName
|
|
651 |
].
|
|
652 |
|
|
653 |
"/ mhmh - an empty directory and empty file
|
|
654 |
"/ i.e. something like v:
|
|
655 |
"/ make it: v:000000.dir
|
|
656 |
|
|
657 |
osName := nameString , '[000000]'.
|
|
658 |
^ osName
|
2948
|
659 |
!
|
|
660 |
|
|
661 |
osNameForAccess
|
|
662 |
"internal - return the OS's name for the receiver,
|
|
663 |
when asking for (stat-) info or to open the file.
|
|
664 |
This returns the files name unchanged, but translates
|
|
665 |
special directory names."
|
|
666 |
|
|
667 |
|comps f d v idx|
|
|
668 |
|
|
669 |
comps := self parseComponentsFrom:nameString.
|
|
670 |
d := comps directory.
|
|
671 |
|
|
672 |
(f := comps filename) size > 0 ifTrue:[
|
|
673 |
d size == 0 ifTrue:[
|
|
674 |
v := comps volume.
|
|
675 |
v size > 0 ifTrue:[
|
2980
|
676 |
"/ something like v:file
|
|
677 |
"/ make it: v:[000000]file
|
|
678 |
comps directory:'000000'.
|
2948
|
679 |
].
|
|
680 |
].
|
|
681 |
"/
|
|
682 |
"/ if it has no suffix, at least append a suffix character
|
|
683 |
"/
|
|
684 |
(f includes:$.) ifFalse:[
|
|
685 |
f := f , '.'.
|
|
686 |
comps filename:f.
|
|
687 |
].
|
|
688 |
osName := self nameFromComponents:comps.
|
|
689 |
^ osName
|
|
690 |
].
|
|
691 |
|
|
692 |
"/ ok, an empty fileName
|
|
693 |
d size > 0 ifTrue:[
|
2980
|
694 |
idx := d lastIndexOf:$..
|
|
695 |
idx ~~ 0 ifTrue:[
|
2948
|
696 |
"/
|
|
697 |
"/ something like: '[d1.d2]' -> '[d1]d2.DIR'
|
|
698 |
"/
|
|
699 |
comps directory:(d copyTo:(idx-1)).
|
|
700 |
comps filename:((d copyFrom:idx+1) , '.DIR').
|
2980
|
701 |
osName := self nameFromComponents:comps.
|
2948
|
702 |
^ osName
|
2980
|
703 |
].
|
2948
|
704 |
"/
|
|
705 |
"/ something like: '[d]' -> '[000000]d.DIR'
|
|
706 |
"/
|
|
707 |
comps directory:'000000'.
|
|
708 |
comps filename:(d , '.DIR').
|
|
709 |
osName := self nameFromComponents:comps.
|
|
710 |
^ osName
|
|
711 |
].
|
|
712 |
|
|
713 |
"/ mhmh - an empty directory and empty file
|
|
714 |
"/ i.e. something like v:
|
|
715 |
"/ make it: v:000000.dir
|
|
716 |
|
|
717 |
osName := nameString , '[000000]'.
|
|
718 |
^ osName
|
|
719 |
!
|
|
720 |
|
2925
|
721 |
! !
|
|
722 |
|
2911
|
723 |
!OpenVMSFilename methodsFor:'instance creation'!
|
|
724 |
|
|
725 |
constructString:subname
|
|
726 |
"taking the receiver as a directory name, construct a new
|
|
727 |
filename-string for an entry within this directory
|
|
728 |
(i.e. for a file or a subdirectory in that directory)."
|
|
729 |
|
2925
|
730 |
|d f comps dcomps sub subcomps subD|
|
2911
|
731 |
|
2925
|
732 |
comps := self parseComponentsFrom:nameString.
|
|
733 |
d := comps directory.
|
|
734 |
|
|
735 |
(f := comps filename) size > 0 ifTrue:[
|
2980
|
736 |
"/ path was of the form vol:[d1...dN]foo
|
|
737 |
"/ assume foo is a directory and append it to directory path.
|
2925
|
738 |
"/ effectively clearing the filename part.
|
|
739 |
|
|
740 |
"/ cut off .DIR ending
|
2911
|
741 |
|
2980
|
742 |
(f asUppercase endsWith:'.DIR') ifTrue:[
|
|
743 |
f := f copyWithoutLast:4
|
|
744 |
].
|
2925
|
745 |
(d size == 0 or:[d = '000000']) ifTrue:[
|
2913
|
746 |
d := f.
|
|
747 |
] ifFalse:[
|
2925
|
748 |
d := d , '.' , f
|
2913
|
749 |
].
|
2925
|
750 |
].
|
|
751 |
|
|
752 |
"/ UNIX compatibility
|
2960
|
753 |
sub := subname asString.
|
2925
|
754 |
(sub = '..') ifTrue:[
|
2980
|
755 |
sub := '-'
|
2911
|
756 |
].
|
2925
|
757 |
|
|
758 |
sub = '-' ifTrue:[
|
2980
|
759 |
"/ try to cut it off here ...
|
|
760 |
dcomps := d asCollectionOfSubstringsSeparatedBy:$..
|
|
761 |
dcomps size > 1 ifTrue:[
|
2925
|
762 |
"/ 'foo.bar.baz.-' -> 'foo.bar'
|
2980
|
763 |
dcomps := dcomps copyWithoutLast:1.
|
|
764 |
d := (dcomps asStringWith:$.).
|
|
765 |
] ifFalse:[
|
2925
|
766 |
dcomps size == 1 ifTrue:[
|
2980
|
767 |
"/ 'foo.-' -> '000000'
|
|
768 |
d := '000000'.
|
2925
|
769 |
] ifFalse:[
|
2980
|
770 |
"/ 'any.-'
|
|
771 |
d := d , '.' , sub.
|
2925
|
772 |
]
|
2980
|
773 |
].
|
2925
|
774 |
sub := ''
|
|
775 |
] ifFalse:[
|
2980
|
776 |
"/ get subnames components
|
|
777 |
subcomps := self parseComponentsFrom:sub.
|
2925
|
778 |
|
|
779 |
"/ concatenate
|
2934
|
780 |
d size == 0 ifTrue:[
|
2925
|
781 |
d := ''.
|
|
782 |
].
|
|
783 |
subD := subcomps directory.
|
|
784 |
subD size > 0 ifTrue:[
|
|
785 |
(subD startsWith:$.) ifTrue:[
|
2934
|
786 |
(d = '' and:[comps volume size > 0]) ifTrue:[
|
|
787 |
"/ I am a volume only; no initial '.' in dir.
|
|
788 |
d := subD copyFrom:2
|
|
789 |
] ifFalse:[
|
|
790 |
d := d , subD
|
|
791 |
]
|
2925
|
792 |
] ifFalse:[
|
2934
|
793 |
(d = '' and:[comps volume size > 0]) ifTrue:[
|
|
794 |
"/ I am a volume only; no initial '.' in dir.
|
|
795 |
d := subD
|
|
796 |
] ifFalse:[
|
|
797 |
d := d , '.' , subD
|
|
798 |
]
|
2925
|
799 |
].
|
|
800 |
].
|
|
801 |
sub := subcomps filename.
|
|
802 |
].
|
|
803 |
|
|
804 |
comps directory:d.
|
|
805 |
comps filename:sub.
|
|
806 |
^ self nameFromComponents:comps
|
2911
|
807 |
|
|
808 |
"
|
|
809 |
(OpenVMSFilename named:'sys$root:[foo.bar]') construct:'baz'
|
|
810 |
(OpenVMSFilename named:'sys$root:[foo.bar]baz') construct:'foo'
|
|
811 |
"
|
|
812 |
|
|
813 |
"Modified: 9.9.1997 / 05:26:04 / cg"
|
|
814 |
! !
|
|
815 |
|
|
816 |
!OpenVMSFilename methodsFor:'queries'!
|
|
817 |
|
|
818 |
isAbsolute
|
|
819 |
"return true, if the receiver represents an absolute pathname
|
|
820 |
(in contrast to one relative to the current directory)."
|
|
821 |
|
2925
|
822 |
|comps d|
|
2911
|
823 |
|
2925
|
824 |
comps := self parseComponentsFrom:nameString.
|
|
825 |
(d := comps directory) isNil ifTrue:[
|
2980
|
826 |
"/ mhmh ...
|
2925
|
827 |
comps volume size > 0 ifTrue:[
|
|
828 |
"/ something like v:file
|
|
829 |
"/ (assumed in v's root dir)
|
|
830 |
^ true
|
|
831 |
].
|
2980
|
832 |
^ false
|
2911
|
833 |
].
|
2925
|
834 |
d size == 0 ifTrue:[
|
2980
|
835 |
"/ [] - the current directory is relative
|
|
836 |
^ false
|
2911
|
837 |
].
|
2925
|
838 |
d = '-' ifTrue:[
|
2980
|
839 |
"/ [-] - the parent directory is relative
|
|
840 |
^ false
|
2911
|
841 |
].
|
2925
|
842 |
(d startsWith:'-.') ifTrue:[
|
2980
|
843 |
"/ [-.] - some parent directory is relative
|
|
844 |
^ false
|
2911
|
845 |
].
|
2925
|
846 |
^ (d startsWith:'.') not
|
2911
|
847 |
|
|
848 |
"
|
|
849 |
(OpenVMSFilename named:'dka:[foo.bar]baz.st') isAbsolute
|
|
850 |
(OpenVMSFilename named:'[foo.bar]baz.st') isAbsolute
|
|
851 |
(OpenVMSFilename named:'[.foo.bar]baz.st') isAbsolute
|
|
852 |
(OpenVMSFilename named:'[]baz.st') isAbsolute
|
|
853 |
(OpenVMSFilename named:'[-]baz.st') isAbsolute
|
|
854 |
(OpenVMSFilename named:'[-.-]baz.st') isAbsolute
|
|
855 |
"
|
|
856 |
|
|
857 |
"Modified: 9.9.1997 / 09:03:42 / cg"
|
2925
|
858 |
!
|
|
859 |
|
|
860 |
isExplicitRelative
|
|
861 |
"return true, if this name is an explicit relative name
|
|
862 |
(i.e. dir starts with '[.name]' or '[-.]', to avoid path-prepending)"
|
|
863 |
|
|
864 |
|comps d|
|
|
865 |
|
2980
|
866 |
comps := self parseComponentsFrom:nameString makeRelative:false.
|
2925
|
867 |
d := comps directory.
|
|
868 |
d size > 0 ifTrue:[
|
|
869 |
(d startsWith:'.') ifTrue:[
|
|
870 |
^ true
|
|
871 |
].
|
|
872 |
(d startsWith:'-.') ifTrue:[
|
|
873 |
^ true
|
|
874 |
]
|
|
875 |
].
|
|
876 |
^ false
|
2980
|
877 |
|
|
878 |
"
|
|
879 |
'xpmBitmaps/minus.xpm' asFilename isExplicitRelative
|
|
880 |
"
|
2939
|
881 |
!
|
|
882 |
|
|
883 |
isSymbolicLink
|
|
884 |
"return true, if the file represented by the receiver
|
|
885 |
is a symbolic link. Since VMS does not support these,
|
|
886 |
always return false here."
|
|
887 |
|
|
888 |
^ false
|
|
889 |
!
|
|
890 |
|
|
891 |
linkInfo
|
|
892 |
"return information on a symbolic link.
|
|
893 |
Since VMS does not support these, always return nil here."
|
|
894 |
|
|
895 |
^ nil
|
2911
|
896 |
! !
|
|
897 |
|
|
898 |
!OpenVMSFilename methodsFor:'queries-path & name'!
|
|
899 |
|
|
900 |
baseName
|
|
901 |
"return my baseName as a string.
|
|
902 |
- thats the file/directory name without leading parent-dirs.
|
|
903 |
See also: #pathName, #directoryName and #directoryPathName.
|
|
904 |
Compatibility note: use #tail for ST-80 compatibility."
|
|
905 |
|
|
906 |
|idx d f comps|
|
|
907 |
|
2925
|
908 |
comps := self parseComponentsFrom:nameString.
|
2911
|
909 |
(f := comps filename) size > 0 ifTrue:[
|
2980
|
910 |
^ f
|
2911
|
911 |
].
|
|
912 |
|
|
913 |
"/ path was of the form vol:[d1...dN]
|
|
914 |
"/ cut off the last directory.
|
|
915 |
d := comps directory.
|
|
916 |
d notNil ifTrue:[
|
2980
|
917 |
d = '' ifTrue:[
|
|
918 |
"/ []
|
|
919 |
"/ ought to get the current directory ...
|
|
920 |
^ ''
|
|
921 |
].
|
|
922 |
d = '-' ifTrue:[
|
|
923 |
"/ [-]
|
|
924 |
"/ ought to get the current directory ...
|
|
925 |
^ ''
|
|
926 |
].
|
|
927 |
(d endsWith:'.-') ifTrue:[
|
|
928 |
"/ [rest.-]
|
|
929 |
"/ ought to expand and get final directory ...
|
|
930 |
^ ''
|
|
931 |
].
|
|
932 |
idx := d lastIndexOf:$..
|
|
933 |
idx ~~ 0 ifTrue:[
|
|
934 |
^ (d copyFrom:idx+1) , '.DIR'
|
|
935 |
].
|
|
936 |
^ d , '.DIR'
|
2911
|
937 |
].
|
|
938 |
^ ''
|
|
939 |
|
|
940 |
"
|
|
941 |
(OpenVMSFilename named:'dka100:[stx.libbasic]Object.st') baseName
|
|
942 |
(OpenVMSFilename named:'stx$root:[stx.libbasic.-]Object.st') baseName
|
|
943 |
(OpenVMSFilename named:'[-]Object.st') baseName
|
|
944 |
(OpenVMSFilename named:'[]Object.st') baseName
|
|
945 |
(OpenVMSFilename named:'Object.st') baseName
|
|
946 |
(OpenVMSFilename named:'[stx.libbasic]') baseName
|
|
947 |
(OpenVMSFilename named:'[stx]') baseName
|
|
948 |
(OpenVMSFilename named:'[]') baseName
|
|
949 |
(OpenVMSFilename named:'[-]') baseName
|
|
950 |
"
|
|
951 |
|
|
952 |
"Created: 9.9.1997 / 09:23:15 / cg"
|
|
953 |
"Modified: 9.9.1997 / 10:52:04 / cg"
|
|
954 |
!
|
|
955 |
|
|
956 |
directoryName
|
|
957 |
"return the directory name part of the file/directory as a string.
|
|
958 |
- thats the name of the directory where the file/dir represented by
|
|
959 |
the receiver is contained in.
|
|
960 |
(this is almost equivalent to #directory, but returns
|
|
961 |
a string instead of a Filename instance).
|
|
962 |
See also: #pathName, #directoryPathName and #baseName.
|
|
963 |
Compatibility note: use #head for ST-80 compatibility."
|
|
964 |
|
|
965 |
|idx d f comps|
|
|
966 |
|
2925
|
967 |
comps := self parseComponentsFrom:nameString.
|
2911
|
968 |
d := comps directory.
|
|
969 |
(f := comps filename) size > 0 ifTrue:[
|
2980
|
970 |
comps filename:nil.
|
|
971 |
^ self nameFromComponents:comps
|
2911
|
972 |
].
|
|
973 |
|
|
974 |
"/ path was of the form vol:[d1...dN]
|
|
975 |
"/ cut off the last directory.
|
|
976 |
|
|
977 |
d isNil ifFalse:[
|
2980
|
978 |
d = '' ifTrue:[
|
|
979 |
"/ [] -> [-]
|
|
980 |
] ifFalse:[
|
|
981 |
d = '-' ifTrue:[
|
|
982 |
"/ [-] -> [-.-]
|
|
983 |
d := '-.-'
|
|
984 |
] ifFalse:[
|
|
985 |
(d endsWith:'.-') ifTrue:[
|
|
986 |
"/ [rest.-] -> [rest.-.-]
|
|
987 |
d := d , '.-'
|
|
988 |
] ifFalse:[
|
|
989 |
idx := d lastIndexOf:$..
|
|
990 |
idx ~~ 0 ifTrue:[
|
|
991 |
d := d copyTo:idx-1
|
|
992 |
]
|
|
993 |
]
|
|
994 |
]
|
|
995 |
].
|
|
996 |
comps directory:d.
|
2911
|
997 |
].
|
2925
|
998 |
^ self nameFromComponents:comps
|
2911
|
999 |
|
|
1000 |
"
|
|
1001 |
(OpenVMSFilename named:'dka100:[stx.libbasic]Object.st') directoryName
|
|
1002 |
(OpenVMSFilename named:'stx$root:[stx.libbasic.-]Object.st') directoryName
|
|
1003 |
(OpenVMSFilename named:'[-]Object.st') directoryName
|
|
1004 |
(OpenVMSFilename named:'[]Object.st') directoryName
|
|
1005 |
(OpenVMSFilename named:'Object.st') directoryName
|
|
1006 |
(OpenVMSFilename named:'[stx.libbasic]') directoryName
|
|
1007 |
"
|
|
1008 |
|
|
1009 |
"Created: 9.9.1997 / 09:23:15 / cg"
|
|
1010 |
"Modified: 9.9.1997 / 10:36:42 / cg"
|
|
1011 |
!
|
|
1012 |
|
2925
|
1013 |
isVolumeOnly
|
|
1014 |
"temporary kludge - return true, if the receiver consists of
|
|
1015 |
a volume name only"
|
|
1016 |
|
|
1017 |
|comps|
|
|
1018 |
|
|
1019 |
comps := self parseComponentsFrom:nameString.
|
|
1020 |
comps directory size > 0 ifTrue:[^ false].
|
|
1021 |
comps filename size >0 ifTrue:[^ false].
|
|
1022 |
^ true
|
|
1023 |
!
|
|
1024 |
|
2977
|
1025 |
localPathName
|
|
1026 |
"return the directory & name, but without any volume prefix."
|
|
1027 |
|
|
1028 |
|comps|
|
|
1029 |
|
|
1030 |
comps := self parseComponentsFrom:nameString.
|
|
1031 |
comps volume:nil.
|
|
1032 |
^ self nameFromComponents:comps
|
|
1033 |
|
|
1034 |
"
|
|
1035 |
(OpenVMSFilename named:'dka100:[stx.libbasic]Object.st') localPathName
|
|
1036 |
"
|
|
1037 |
!
|
|
1038 |
|
2911
|
1039 |
volume
|
|
1040 |
"return the disc volume part of the name or an empty string."
|
|
1041 |
|
2925
|
1042 |
^ (self parseComponentsFrom:nameString) volume ? ''
|
2911
|
1043 |
|
|
1044 |
"
|
|
1045 |
(OpenVMSFilename named:'dka100:[stx.libbasic]Object.st') volume
|
|
1046 |
(OpenVMSFilename named:'stx$root:[stx.libbasic.-]Object.st') volume
|
|
1047 |
(OpenVMSFilename named:'[-]Object.st') volume
|
|
1048 |
(OpenVMSFilename named:'[]Object.st') volume
|
|
1049 |
(OpenVMSFilename named:'Object.st') volume
|
|
1050 |
(OpenVMSFilename named:'[stx.libbasic]') volume
|
|
1051 |
"
|
|
1052 |
|
|
1053 |
"Modified: 9.9.1997 / 08:56:05 / cg"
|
|
1054 |
! !
|
|
1055 |
|
|
1056 |
!OpenVMSFilename::NameComponents methodsFor:'accessing'!
|
|
1057 |
|
|
1058 |
directory
|
|
1059 |
^ directory
|
|
1060 |
|
|
1061 |
"Created: 9.9.1997 / 05:21:04 / cg"
|
|
1062 |
!
|
|
1063 |
|
|
1064 |
directory:aString
|
|
1065 |
directory := aString
|
|
1066 |
|
|
1067 |
"Created: 9.9.1997 / 05:21:11 / cg"
|
|
1068 |
!
|
|
1069 |
|
|
1070 |
filename
|
|
1071 |
^ filename
|
|
1072 |
|
|
1073 |
"Created: 9.9.1997 / 05:21:23 / cg"
|
|
1074 |
!
|
|
1075 |
|
|
1076 |
filename:aString
|
|
1077 |
filename := aString
|
|
1078 |
|
|
1079 |
"Created: 9.9.1997 / 05:21:28 / cg"
|
|
1080 |
!
|
|
1081 |
|
|
1082 |
volume
|
|
1083 |
^ volume
|
|
1084 |
|
|
1085 |
"Created: 9.9.1997 / 05:20:58 / cg"
|
|
1086 |
!
|
|
1087 |
|
|
1088 |
volume:aString
|
|
1089 |
volume := aString
|
|
1090 |
|
|
1091 |
"Created: 9.9.1997 / 05:21:17 / cg"
|
|
1092 |
!
|
|
1093 |
|
|
1094 |
volume:v directory:d filename:n
|
|
1095 |
volume := v.
|
|
1096 |
directory := d.
|
|
1097 |
filename := n.
|
|
1098 |
|
|
1099 |
"Created: 9.9.1997 / 05:20:53 / cg"
|
|
1100 |
! !
|
|
1101 |
|
2925
|
1102 |
!OpenVMSFilename methodsFor:'file operations'!
|
|
1103 |
|
2982
|
1104 |
basicMakeDirectory
|
|
1105 |
"create a directory with the receivers name.
|
|
1106 |
Return true if successful, false if not."
|
|
1107 |
|
2984
|
1108 |
|nm|
|
|
1109 |
|
|
1110 |
(OperatingSystem executeCommand:('cre/dir ' , self osNameForDirectory))
|
|
1111 |
ifFalse:[^ false].
|
|
1112 |
|
|
1113 |
"/ make it deletable ...
|
|
1114 |
|
|
1115 |
nm := self osNameForFile.
|
|
1116 |
(nm endsWith:'.') ifTrue:[
|
|
1117 |
nm := nm , 'DIR'
|
|
1118 |
].
|
|
1119 |
OperatingSystem executeCommand:('set sec/prot=o:RWED ' , nm).
|
|
1120 |
^ true
|
2982
|
1121 |
!
|
|
1122 |
|
2980
|
1123 |
recursiveRemove
|
|
1124 |
"remove the directory and all of its subfiles/subdirectories.
|
|
1125 |
Raise an error if not successful."
|
|
1126 |
|
|
1127 |
self directoryContents do:[:aFile |
|
|
1128 |
(self construct:aFile) recursiveRemove.
|
|
1129 |
].
|
|
1130 |
self remove
|
|
1131 |
!
|
|
1132 |
|
2925
|
1133 |
remove
|
|
1134 |
"remove the file/directory.
|
|
1135 |
Raise an error if not successful.
|
2960
|
1136 |
Use #recursiveRemove in order to (recursively) remove non empty
|
|
1137 |
directories.
|
|
1138 |
This has been redefined, to add ';*' to the filename,
|
|
1139 |
unless an explicit version number has been provided.
|
|
1140 |
If no explicit version has been specified, all versions are removed."
|
2925
|
1141 |
|
|
1142 |
|ok baseName osName|
|
|
1143 |
|
|
1144 |
self exists ifFalse:[^ self].
|
|
1145 |
|
|
1146 |
osName := self osNameForFile.
|
|
1147 |
self isDirectory ifTrue:[
|
|
1148 |
ok := OperatingSystem removeDirectory:osName
|
|
1149 |
] ifFalse:[
|
2980
|
1150 |
baseName := self baseName.
|
|
1151 |
(baseName includes:$;) ifFalse:[
|
2960
|
1152 |
osName := osName , ';0'
|
2980
|
1153 |
].
|
2960
|
1154 |
ok := OperatingSystem removeFile:osName.
|
|
1155 |
ok ifTrue:[
|
|
1156 |
"/ get rid of the other versions ...
|
|
1157 |
[OperatingSystem removeFile:osName] whileTrue.
|
|
1158 |
]
|
2925
|
1159 |
].
|
|
1160 |
ok ifFalse:[
|
2980
|
1161 |
self removeError:self
|
2925
|
1162 |
].
|
|
1163 |
|
|
1164 |
"
|
|
1165 |
(FileStream newFileNamed:'foo') close.
|
|
1166 |
'foo' asFilename remove
|
|
1167 |
"
|
|
1168 |
! !
|
|
1169 |
|
2911
|
1170 |
!OpenVMSFilename class methodsFor:'documentation'!
|
|
1171 |
|
|
1172 |
version
|
3042
|
1173 |
^ '$Header: /cvs/stx/stx/libbasic/OpenVMSFilename.st,v 1.18 1997-10-16 10:41:25 cg Exp $'
|
2911
|
1174 |
! !
|