3043
|
1 |
"
|
|
2 |
COPYRIGHT (c) 1997 by eXept Software AG
|
|
3 |
All Rights Reserved
|
|
4 |
|
|
5 |
This software is furnished under a license and may be used
|
|
6 |
only in accordance with the terms of that license and with the
|
|
7 |
inclusion of the above copyright notice. This software may not
|
|
8 |
be provided or otherwise made available to, or used by, any
|
|
9 |
other person. No title to or ownership of the software is
|
|
10 |
hereby transferred.
|
|
11 |
"
|
|
12 |
|
|
13 |
'From Smalltalk/X, Version:3.2.1 on 16-oct-1997 at 1:30:13 pm' !
|
|
14 |
|
|
15 |
Filename subclass:#PCFilename
|
|
16 |
instanceVariableNames:''
|
|
17 |
classVariableNames:'StandardSuffixTable'
|
|
18 |
poolDictionaries:''
|
|
19 |
category:'OS-PC'
|
|
20 |
!
|
|
21 |
|
|
22 |
!PCFilename class methodsFor:'documentation'!
|
|
23 |
|
|
24 |
copyright
|
|
25 |
"
|
|
26 |
COPYRIGHT (c) 1997 by eXept Software AG
|
|
27 |
All Rights Reserved
|
|
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 |
"
|
|
36 |
!
|
|
37 |
|
|
38 |
documentation
|
|
39 |
"
|
|
40 |
Filenames in Windows-NT / Win95.
|
|
41 |
"
|
|
42 |
! !
|
|
43 |
|
|
44 |
!PCFilename class methodsFor:'initialization'!
|
|
45 |
|
|
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 |
#(
|
|
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'
|
|
68 |
) pairWiseDo:[:k :v |
|
|
69 |
StandardSuffixTable at:k put:v
|
|
70 |
]
|
|
71 |
|
|
72 |
"
|
|
73 |
StandardSuffixTable := nil.
|
|
74 |
self initStandardSuffixTable
|
|
75 |
"
|
|
76 |
|
|
77 |
"Modified: 16.10.1997 / 13:12:39 / cg"
|
|
78 |
! !
|
|
79 |
|
|
80 |
!PCFilename class methodsFor:'queries'!
|
|
81 |
|
|
82 |
isBadCharacter:aCharacter
|
|
83 |
"return true, if aCharacter is unallowed in a filename."
|
|
84 |
|
|
85 |
('<>:"/\|' includes:aCharacter) ifTrue:[^ true].
|
|
86 |
^ super isBadCharacter:aCharacter
|
|
87 |
|
|
88 |
"Created: 8.9.1997 / 00:14:06 / cg"
|
|
89 |
!
|
|
90 |
|
|
91 |
isCaseSensitive
|
|
92 |
"return true, if filenames are case sensitive."
|
|
93 |
|
|
94 |
^ false
|
|
95 |
!
|
|
96 |
|
|
97 |
separator
|
|
98 |
"return the file/directory separator."
|
|
99 |
|
|
100 |
^ $\
|
|
101 |
|
|
102 |
"
|
|
103 |
Filename concreteClass separator
|
|
104 |
"
|
|
105 |
|
|
106 |
"Modified: 8.9.1997 / 00:18:03 / cg"
|
|
107 |
! !
|
|
108 |
|
|
109 |
!PCFilename methodsFor:'queries'!
|
|
110 |
|
|
111 |
fileType
|
|
112 |
"this returns a string describing the type of contents of
|
|
113 |
the file. Here, the suffix is examined for a standard
|
|
114 |
suffix and an appropriate string is returned.
|
|
115 |
Poor MSDOS - no file command."
|
|
116 |
|
|
117 |
|suff type info fmt|
|
|
118 |
|
|
119 |
StandardSuffixTable isNil ifTrue:[
|
|
120 |
self class initStandardSuffixTable
|
|
121 |
].
|
|
122 |
|
|
123 |
suff := self suffix asUppercase.
|
|
124 |
type := StandardSuffixTable at:suff ifAbsent:nil.
|
|
125 |
type isNil ifTrue:[
|
|
126 |
type := super fileType.
|
|
127 |
].
|
|
128 |
^ type
|
|
129 |
|
|
130 |
"Created: 16.10.1997 / 13:07:24 / cg"
|
|
131 |
"Modified: 16.10.1997 / 13:10:00 / cg"
|
|
132 |
!
|
|
133 |
|
|
134 |
isExecutableProgram
|
|
135 |
"return true, if such a file exists and is an executable program.
|
|
136 |
(i.e. for directories, false is returned.)"
|
|
137 |
|
|
138 |
(self hasSuffix:'exe') ifTrue:[
|
|
139 |
^ super isExecutableProgram
|
|
140 |
].
|
|
141 |
(self hasSuffix:'com') ifTrue:[
|
|
142 |
^ super isExecutableProgram
|
|
143 |
].
|
|
144 |
^ false
|
|
145 |
|
|
146 |
"Created: 16.10.1997 / 13:19:10 / cg"
|
|
147 |
!
|
|
148 |
|
|
149 |
isExplicitRelative
|
|
150 |
"return true, if this name is an explicit relative name
|
|
151 |
(i.e. starts with './' or '../', to avoid path-prepending)"
|
|
152 |
|
|
153 |
(nameString startsWith:'.\') ifTrue:[
|
|
154 |
^ true
|
|
155 |
].
|
|
156 |
(nameString startsWith:'..\') ifTrue:[
|
|
157 |
^ true
|
|
158 |
].
|
|
159 |
^ false
|
|
160 |
!
|
|
161 |
|
|
162 |
isVolumeAbsolute
|
|
163 |
"return true, if the receiver represents an absolute pathname
|
|
164 |
on some disk volume."
|
|
165 |
|
|
166 |
^ ((nameString size >= 2) and:[(nameString at:2) == $:])
|
|
167 |
|
|
168 |
"Created: 7.9.1997 / 23:54:20 / cg"
|
|
169 |
!
|
|
170 |
|
|
171 |
localNameStringFrom:aString
|
|
172 |
"ST-80 compatibility.
|
|
173 |
what does this do ? (used in FileNavigator-goody).
|
|
174 |
GUESS: does it strip off the voulume-character and initial '\' ?"
|
|
175 |
|
|
176 |
(aString at:2) == $: ifTrue:[
|
|
177 |
(aString at:3) == $\ ifTrue:[
|
|
178 |
^ aString copyFrom:4
|
|
179 |
].
|
|
180 |
^ aString copyFrom:3
|
|
181 |
].
|
|
182 |
(aString at:1) == $\ ifTrue:[
|
|
183 |
^ aString copyFrom:1
|
|
184 |
].
|
|
185 |
^ aString
|
|
186 |
!
|
|
187 |
|
|
188 |
volume
|
|
189 |
"return the disc volume part of the name or an empty string.
|
|
190 |
This is only used with DOS filenames - on unix, an empty string is returned"
|
|
191 |
|
|
192 |
(nameString at:2) == $: ifTrue:[
|
|
193 |
^ nameString copyTo:1
|
|
194 |
].
|
|
195 |
^ ''
|
|
196 |
|
|
197 |
"Created: 7.9.1997 / 23:58:06 / cg"
|
|
198 |
! !
|
|
199 |
|
|
200 |
!PCFilename class methodsFor:'documentation'!
|
|
201 |
|
|
202 |
version
|
|
203 |
^ '$Header: /cvs/stx/stx/libbasic/PCFilename.st,v 1.6 1997-10-16 11:17:03 cg Exp $'
|
|
204 |
! !
|