author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Sat, 14 May 2016 09:34:43 +0200 | |
branch | jv |
changeset 19861 | 95c7068e30ba |
parent 19811 | 65fec19facb0 |
parent 19821 | 1d873302be8b |
child 19967 | 9b1443c2aab1 |
permissions | -rw-r--r-- |
18272 | 1 |
"{ Encoding: utf8 }" |
2 |
||
1 | 3 |
" |
5 | 4 |
COPYRIGHT (c) 1992 by Claus Gittinger |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5 |
All Rights Reserved |
1 | 6 |
|
7 |
This software is furnished under a license and may be used |
|
8 |
only in accordance with the terms of that license and with the |
|
9 |
inclusion of the above copyright notice. This software may not |
|
10 |
be provided or otherwise made available to, or used by, any |
|
11 |
other person. No title to or ownership of the software is |
|
12 |
hereby transferred. |
|
13 |
" |
|
5507
e8c61b1741c6
in #moveTo: - try a link first, then do a copy-remove.
Claus Gittinger <cg@exept.de>
parents:
5303
diff
changeset
|
14 |
"{ Package: 'stx:libbasic' }" |
e8c61b1741c6
in #moveTo: - try a link first, then do a copy-remove.
Claus Gittinger <cg@exept.de>
parents:
5303
diff
changeset
|
15 |
|
17310 | 16 |
"{ NameSpace: Smalltalk }" |
17 |
||
1 | 18 |
Object subclass:#Filename |
14567 | 19 |
instanceVariableNames:'nameString' |
15459 | 20 |
classVariableNames:'TempDirectory DefaultTempDirectory ConcreteClass' |
14567 | 21 |
poolDictionaries:'' |
22 |
category:'System-Support' |
|
615 | 23 |
! |
1 | 24 |
|
1859
7f6040320daf
changes for new return from OS>>infoOf:
Claus Gittinger <cg@exept.de>
parents:
1614
diff
changeset
|
25 |
!Filename class methodsFor:'documentation'! |
88 | 26 |
|
27 |
copyright |
|
28 |
" |
|
29 |
COPYRIGHT (c) 1992 by Claus Gittinger |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
30 |
All Rights Reserved |
1 | 31 |
|
88 | 32 |
This software is furnished under a license and may be used |
33 |
only in accordance with the terms of that license and with the |
|
34 |
inclusion of the above copyright notice. This software may not |
|
35 |
be provided or otherwise made available to, or used by, any |
|
36 |
other person. No title to or ownership of the software is |
|
37 |
hereby transferred. |
|
38 |
" |
|
39 |
! |
|
40 |
||
41 |
documentation |
|
42 |
" |
|
43 |
Filenames; originally added for ST-80 compatibility, is |
|
44 |
taking over functionality from other classes (FileDirectory). |
|
92 | 45 |
|
46 |
Instances of Filename do not nescessarily represent valid or existing |
|
47 |
files - i.e. it is possible (and useful) to have instances for non-existing |
|
48 |
files around. In other words: the name-string is not checked automatically |
|
49 |
for being correct or existing. |
|
50 |
Thus, it is possible to do queries such as: |
|
51 |
||
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
52 |
'/fee/foo/foe' asFilename exists |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
53 |
'/not_existing' asFilename isDirectory |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
54 |
'/foo/bar' asFilename isReadable |
92 | 55 |
|
195 | 56 |
(all of the above examples will probably return false on your machine ;-). |
276 | 57 |
|
58 |
examples: |
|
59 |
||
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
60 |
'Makefile' asFilename readStream |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
61 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
62 |
'newFile' asFilename writeStream |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
63 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
64 |
Filename newTemporary writeStream |
276 | 65 |
|
1318 | 66 |
Beside lots of protocol to query for a files attributes, the class |
67 |
protocol offers methods for filename completion, to construct pathes |
|
68 |
(in an OS-independent way) and to create temporary files. |
|
2911 | 69 |
Especially the path-construction methods (i.e. #construct:) are highly |
1318 | 70 |
recommended in order to avoid having OS details (like directory separators |
71 |
being slash or backslash) spreaded in your application. |
|
72 |
||
8738 | 73 |
Since Filenames have different semantics under different operating systems, |
74 |
class methods are delegated to concrete implementations in various subclasses like |
|
75 |
UnixFilename, PCFilename, ... |
|
76 |
The delegation is implemented in a way, so that some methods of |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
77 |
specific OS Filenames might be used, even if ST/X is currently running |
8738 | 78 |
on a different OS (as long as the method does not depend on the OperatingSystem class). |
79 |
||
1286 | 80 |
[author:] |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
81 |
Claus Gittinger |
276 | 82 |
|
1286 | 83 |
[see also:] |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
84 |
String |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
85 |
FileStream DirectoryStream PipeStream Socket |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
86 |
OperatingSystem |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
87 |
Date Time |
88 | 88 |
" |
360 | 89 |
! |
90 |
||
91 |
examples |
|
92 |
" |
|
93 |
does a file/directory exist ?: |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
94 |
[exBegin] |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
95 |
|f| |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
96 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
97 |
f := 'foobar' asFilename. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
98 |
^ f exists |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
99 |
[exEnd] |
360 | 100 |
|
101 |
||
102 |
is it a directory ?: |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
103 |
[exBegin] |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
104 |
|f| |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
105 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
106 |
f := '/tmp' asFilename. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
107 |
^ f isDirectory. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
108 |
[exEnd] |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
109 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
110 |
|
360 | 111 |
get the working directory: |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
112 |
[exBegin] |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
113 |
^ Filename defaultDirectory |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
114 |
[exEnd] |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
115 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
116 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
117 |
get a files full pathname |
360 | 118 |
(caring for relative names or symbolic links): |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
119 |
[exBegin] |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
120 |
|f| |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
121 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
122 |
f := '..' asFilename. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
123 |
^ f pathName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
124 |
[exEnd] |
360 | 125 |
|
126 |
||
127 |
get a directories directory: |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
128 |
[exBegin] |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
129 |
|f| |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
130 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
131 |
f := Filename defaultDirectory. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
132 |
^ f directory |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
133 |
[exEnd] |
360 | 134 |
|
135 |
||
136 |
get a files directory: |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
137 |
[exBegin] |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
138 |
|f| |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
139 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
140 |
f := './smalltalk' asFilename. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
141 |
^ f directory |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
142 |
[exEnd] |
360 | 143 |
|
144 |
||
145 |
getting access & modification times: |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
146 |
[exBegin] |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
147 |
|f| |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
148 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
149 |
f := '/tmp' asFilename. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
150 |
^ f dates |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
151 |
[exEnd] |
360 | 152 |
|
153 |
access time only: |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
154 |
[exBegin] |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
155 |
|f| |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
156 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
157 |
f := '/tmp' asFilename. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
158 |
^ f dates at:#accessed |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
159 |
[exEnd] |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
160 |
|
360 | 161 |
|
162 |
getting all information on a file/directory: |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
163 |
[exBegin] |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
164 |
|f| |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
165 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
166 |
f := '/tmp' asFilename. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
167 |
^ f info |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
168 |
[exEnd] |
360 | 169 |
|
170 |
||
171 |
getting a temporary file (unique name): |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
172 |
[exBegin] |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
173 |
|f| |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
174 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
175 |
f := Filename newTemporary. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
176 |
^ f |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
177 |
[exEnd] |
360 | 178 |
|
179 |
creating, writing, reading and removing a temporary file: |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
180 |
[exBegin] |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
181 |
|f writeStream readStream| |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
182 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
183 |
f := Filename newTemporary. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
184 |
writeStream := f writeStream. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
185 |
writeStream nextPutAll:'hello world'. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
186 |
writeStream cr. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
187 |
writeStream close. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
188 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
189 |
'contents (as seen by unix''s cat command:' printNL. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
190 |
OperatingSystem executeCommand:('cat ' , f pathName). |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
191 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
192 |
readStream := f readStream. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
193 |
Transcript showCR:'contents as seen by smalltalk:'. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
194 |
Transcript showCR:(readStream upToEnd). |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
195 |
readStream close. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
196 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
197 |
f delete. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
198 |
[exEnd] |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
199 |
|
360 | 200 |
|
201 |
getting a directories contents: |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
202 |
[exBegin] |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
203 |
|f files| |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
204 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
205 |
f := Filename currentDirectory. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
206 |
files := f directoryContents. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
207 |
Transcript showCR:'the files are:'. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
208 |
Transcript showCR:(files printString). |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
209 |
[exEnd] |
360 | 210 |
|
211 |
||
212 |
editing a file: |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
213 |
[exBegin] |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
214 |
|f| |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
215 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
216 |
f := Filename newTemporary. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
217 |
(f writeStream) nextPutAll:'hello world'; close. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
218 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
219 |
f edit |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
220 |
[exEnd] |
360 | 221 |
" |
88 | 222 |
! ! |
1 | 223 |
|
2906 | 224 |
!Filename class methodsFor:'initialization'! |
225 |
||
226 |
initialize |
|
227 |
"initialize for the OS we are running on" |
|
228 |
||
8754 | 229 |
ConcreteClass isNil ifTrue:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
230 |
self initializeConcreteClass |
7702 | 231 |
]. |
2906 | 232 |
|
233 |
" |
|
234 |
self initialize |
|
235 |
" |
|
236 |
||
237 |
"Created: 7.9.1997 / 23:32:55 / cg" |
|
238 |
! |
|
239 |
||
240 |
initializeConcreteClass |
|
241 |
"initialize for the OS we are running on" |
|
242 |
||
8754 | 243 |
OperatingSystem isUNIXlike ifTrue:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
244 |
ConcreteClass := UnixFilename |
8754 | 245 |
] ifFalse:[OperatingSystem isMSDOSlike ifTrue:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
246 |
ConcreteClass := PCFilename |
8754 | 247 |
] ifFalse:[OperatingSystem isVMSlike ifTrue:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
248 |
ConcreteClass := OpenVMSFilename |
2906 | 249 |
] ifFalse:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
250 |
self error:'Filename: unknown OperatingSystem when initializing concrete Filename class'. |
8754 | 251 |
]]]. |
252 |
||
253 |
ConcreteClass isNil ifTrue:[ |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
254 |
self error:'Filename: Missing concrete Filename class'. |
8754 | 255 |
]. |
256 |
||
257 |
" |
|
258 |
self initializeConcreteClass |
|
2906 | 259 |
" |
260 |
||
261 |
"Modified: 7.9.1997 / 23:32:37 / cg" |
|
262 |
! |
|
263 |
||
264 |
reinitialize |
|
8738 | 265 |
"initialize for the OS we are running on (after a restart)" |
2906 | 266 |
|
9806 | 267 |
TempDirectory := nil. |
268 |
self initializeConcreteClass. |
|
2906 | 269 |
|
270 |
" |
|
8754 | 271 |
self reinitialize |
2906 | 272 |
" |
273 |
||
9806 | 274 |
"Created: / 07-09-1997 / 23:33:02 / cg" |
275 |
"Modified: / 29-08-2006 / 12:40:28 / cg" |
|
2906 | 276 |
! ! |
277 |
||
3959 | 278 |
!Filename class methodsFor:'instance creation'! |
279 |
||
17227 | 280 |
applicationDataDirectory |
281 |
"return the directory, where user-and-application-specific private files are to be |
|
282 |
located (ini-files, preferences etc.). |
|
283 |
Under windows, something like 'C:\Users\Administrator\AppData\Roaming\<appName>' |
|
284 |
is returned, under unix, we use ~/.<appName> (but see details in UnixOS). |
|
285 |
For smalltalk itself (the IDE), 'smalltalk' is used as appName. |
|
286 |
If the directory does not exist, it is created" |
|
287 |
||
288 |
|exeName| |
|
289 |
||
290 |
Smalltalk isStandAloneApp ifTrue:[ |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
291 |
exeName := OperatingSystem nameOfSTXExecutable. |
17227 | 292 |
] ifFalse:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
293 |
exeName := 'smalltalk' |
17227 | 294 |
]. |
295 |
^ self applicationDataDirectoryFor:exeName |
|
296 |
||
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
297 |
" |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
298 |
Filename applicationDataDirectory |
17227 | 299 |
" |
300 |
! |
|
301 |
||
12972 | 302 |
applicationDataDirectoryFor:appName |
303 |
"return the directory, where user-and-application-specific private files are to be |
|
304 |
located (ini-files, preferences etc.). |
|
305 |
Under windows, something like 'C:\Users\Administrator\AppData\Roaming\<appName>' |
|
12973 | 306 |
is returned, under unix, we use ~/.<appName> (but see details in UnixOS). |
12974 | 307 |
If the directory does not exist, it is created" |
308 |
||
309 |
|s dir| |
|
12972 | 310 |
|
311 |
s := OperatingSystem getApplicationDataDirectoryFor:appName. |
|
312 |
s isNil ifTrue:[ |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
313 |
^ self homeDirectory |
12972 | 314 |
]. |
12974 | 315 |
dir := self named:s. |
316 |
dir exists ifFalse:[ |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
317 |
dir makeDirectory |
12974 | 318 |
]. |
319 |
^ dir |
|
12972 | 320 |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
321 |
" |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
322 |
Filename applicationDataDirectoryFor:'smalltalk' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
323 |
Filename applicationDataDirectoryFor:'expecco' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
324 |
applicationDataDirectoryFor:'expecco' |
12972 | 325 |
" |
326 |
||
327 |
"Created: / 29-07-2010 / 12:05:35 / sr" |
|
328 |
! |
|
329 |
||
3959 | 330 |
currentDirectory |
331 |
"return a filename for the current directory" |
|
332 |
||
13109 | 333 |
^ self named:(OperatingSystem getCurrentDirectory). |
3959 | 334 |
|
335 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
336 |
Filename currentDirectory |
3959 | 337 |
" |
338 |
! |
|
339 |
||
340 |
defaultDirectory |
|
341 |
"ST80 compatibility: same as currentDirectory" |
|
342 |
||
343 |
^ self currentDirectory |
|
344 |
||
345 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
346 |
Filename defaultDirectory |
3959 | 347 |
" |
348 |
! |
|
349 |
||
12336
7610de9a7e4b
provide access to the default (original, unchanged) tempDirectory
Claus Gittinger <cg@exept.de>
parents:
12318
diff
changeset
|
350 |
defaultTempDirectory |
7610de9a7e4b
provide access to the default (original, unchanged) tempDirectory
Claus Gittinger <cg@exept.de>
parents:
12318
diff
changeset
|
351 |
"return the default temp directory as a filename. |
7610de9a7e4b
provide access to the default (original, unchanged) tempDirectory
Claus Gittinger <cg@exept.de>
parents:
12318
diff
changeset
|
352 |
That is the same as TempDirectory, except that TempDirectory can be changed |
17048 | 353 |
from the outside (via tempDirectory:) whereas this is the OS's original default. |
12336
7610de9a7e4b
provide access to the default (original, unchanged) tempDirectory
Claus Gittinger <cg@exept.de>
parents:
12318
diff
changeset
|
354 |
Use this for files which MUST remain the same (stx_sourceCache)" |
7610de9a7e4b
provide access to the default (original, unchanged) tempDirectory
Claus Gittinger <cg@exept.de>
parents:
12318
diff
changeset
|
355 |
|
7610de9a7e4b
provide access to the default (original, unchanged) tempDirectory
Claus Gittinger <cg@exept.de>
parents:
12318
diff
changeset
|
356 |
DefaultTempDirectory isNil ifTrue:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
357 |
self tempDirectory. "/ actually sets DefaultTempDirectory as side effect |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
358 |
DefaultTempDirectory isNil ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
359 |
DefaultTempDirectory := TempDirectory |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
360 |
]. |
12336
7610de9a7e4b
provide access to the default (original, unchanged) tempDirectory
Claus Gittinger <cg@exept.de>
parents:
12318
diff
changeset
|
361 |
]. |
7610de9a7e4b
provide access to the default (original, unchanged) tempDirectory
Claus Gittinger <cg@exept.de>
parents:
12318
diff
changeset
|
362 |
|
7610de9a7e4b
provide access to the default (original, unchanged) tempDirectory
Claus Gittinger <cg@exept.de>
parents:
12318
diff
changeset
|
363 |
DefaultTempDirectory exists ifFalse:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
364 |
DefaultTempDirectory |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
365 |
makeDirectory; |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
366 |
addAccessRights:#(readUser readGroup readOthers |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
367 |
writeUser writeGroup writeOthers |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
368 |
executeUser executeGroup executeOthers |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
369 |
removeOnlyByOwner). |
12336
7610de9a7e4b
provide access to the default (original, unchanged) tempDirectory
Claus Gittinger <cg@exept.de>
parents:
12318
diff
changeset
|
370 |
]. |
7610de9a7e4b
provide access to the default (original, unchanged) tempDirectory
Claus Gittinger <cg@exept.de>
parents:
12318
diff
changeset
|
371 |
^ DefaultTempDirectory |
7610de9a7e4b
provide access to the default (original, unchanged) tempDirectory
Claus Gittinger <cg@exept.de>
parents:
12318
diff
changeset
|
372 |
|
7610de9a7e4b
provide access to the default (original, unchanged) tempDirectory
Claus Gittinger <cg@exept.de>
parents:
12318
diff
changeset
|
373 |
" |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
374 |
Filename tempDirectory |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
375 |
Filename defaultTempDirectory |
12336
7610de9a7e4b
provide access to the default (original, unchanged) tempDirectory
Claus Gittinger <cg@exept.de>
parents:
12318
diff
changeset
|
376 |
" |
7610de9a7e4b
provide access to the default (original, unchanged) tempDirectory
Claus Gittinger <cg@exept.de>
parents:
12318
diff
changeset
|
377 |
|
7610de9a7e4b
provide access to the default (original, unchanged) tempDirectory
Claus Gittinger <cg@exept.de>
parents:
12318
diff
changeset
|
378 |
"Created: / 07-03-1996 / 14:51:18 / cg" |
7610de9a7e4b
provide access to the default (original, unchanged) tempDirectory
Claus Gittinger <cg@exept.de>
parents:
12318
diff
changeset
|
379 |
"Modified: / 29-08-2006 / 12:57:16 / cg" |
7610de9a7e4b
provide access to the default (original, unchanged) tempDirectory
Claus Gittinger <cg@exept.de>
parents:
12318
diff
changeset
|
380 |
! |
7610de9a7e4b
provide access to the default (original, unchanged) tempDirectory
Claus Gittinger <cg@exept.de>
parents:
12318
diff
changeset
|
381 |
|
10546 | 382 |
desktopDirectory |
383 |
"return your desktop directory. |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
384 |
Under windows, thats the real desktop directory; |
10546 | 385 |
under other OperatingSystems, the home directory is returned." |
386 |
||
387 |
|s| |
|
388 |
||
389 |
s := OperatingSystem getDesktopDirectory. |
|
390 |
s isNil ifTrue:[ |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
391 |
^ self homeDirectory |
10546 | 392 |
]. |
393 |
^ self named:s |
|
394 |
||
395 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
396 |
Filename desktopDirectory |
10546 | 397 |
" |
398 |
||
399 |
"Created: / 16-05-2007 / 13:18:34 / cg" |
|
400 |
! |
|
401 |
||
11763 | 402 |
documentsDirectory |
403 |
"return your documents directory. |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
404 |
Under windows, thats the real 'Documents' or 'My Documents'; |
11763 | 405 |
under other OperatingSystems, the home directory is returned." |
406 |
||
407 |
|s| |
|
408 |
||
409 |
s := OperatingSystem getDocumentsDirectory. |
|
410 |
s isNil ifTrue:[ |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
411 |
^ self homeDirectory |
11763 | 412 |
]. |
413 |
^ self named:s |
|
414 |
||
415 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
416 |
Filename documentsDirectory |
11763 | 417 |
" |
418 |
||
419 |
"Created: / 16-05-2007 / 13:18:34 / cg" |
|
420 |
! |
|
421 |
||
3959 | 422 |
findDefaultDirectory |
423 |
"same as #defaultDirectory for ST80 compatibility" |
|
424 |
||
425 |
^ self defaultDirectory |
|
426 |
||
427 |
"Created: 20.6.1997 / 17:00:29 / cg" |
|
428 |
! |
|
429 |
||
430 |
fromComponents:aCollectionOfDirectoryNames |
|
431 |
"create & return a new filename from components given in |
|
432 |
aCollectionOfDirectoryNames. If the first component is the name of the |
|
433 |
root directory (i.e. '/') an absolute path-filename is returned." |
|
434 |
||
11781
6488fd6cc498
Make AutoDeletedFilename work like Filename
Stefan Vogel <sv@exept.de>
parents:
11763
diff
changeset
|
435 |
self isAbstract ifTrue:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
436 |
^ ConcreteClass fromComponents:aCollectionOfDirectoryNames |
3959 | 437 |
]. |
438 |
||
6802 | 439 |
^ self named:(self nameFromComponents:aCollectionOfDirectoryNames) |
3959 | 440 |
|
441 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
442 |
Filename fromComponents:#('/' 'foo' 'bar' 'baz') |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
443 |
PCFilename fromComponents:#('/' 'foo' 'bar' 'baz') |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
444 |
UnixFilename fromComponents:#('/' 'foo' 'bar' 'baz') |
8754 | 445 |
OpenVMSFilename fromComponents:#('foo' 'bar' 'baz') |
446 |
||
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
447 |
Filename fromComponents:#('foo' 'bar' 'baz') |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
448 |
Filename fromComponents:#('/') |
3959 | 449 |
|
450 |
Filename fromComponents: |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
451 |
(Filename components:('.' asFilename pathName)) |
3959 | 452 |
|
453 |
Filename fromComponents: |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
454 |
(Filename components:('.' asFilename name)) |
3959 | 455 |
" |
456 |
||
457 |
"Modified: 8.9.1997 / 00:23:16 / cg" |
|
458 |
! |
|
459 |
||
460 |
fromUser |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
461 |
"show a box to enter a filename. |
3959 | 462 |
Return a filename instance or nil (if cancel was pressed)." |
463 |
||
464 |
|name| |
|
465 |
||
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
466 |
name := Dialog |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
467 |
requestFileName:'filename:' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
468 |
default:nil |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
469 |
fromDirectory:(FileSelectionBox lastFileSelectionDirectory). |
8738 | 470 |
|
471 |
name notEmptyOrNil ifTrue:[ |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
472 |
^ self named:name |
3978
b2babde0857b
use remembered last filenames directory (in #fromUser)
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
473 |
]. |
3959 | 474 |
^ nil |
475 |
||
476 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
477 |
Filename fromUser |
3959 | 478 |
" |
479 |
||
480 |
"Modified: 19.4.1996 / 13:57:44 / cg" |
|
481 |
! |
|
482 |
||
483 |
homeDirectory |
|
484 |
"return your homeDirectory. |
|
485 |
Some OperatingSystems do not support this - on those, the defaultDirectory |
|
17113 | 486 |
(which is the currentDirectory) is returned. |
487 |
Notice: services under windows also do not have a home directory." |
|
3959 | 488 |
|
489 |
|s| |
|
490 |
||
491 |
s := OperatingSystem getHomeDirectory. |
|
492 |
s isNil ifTrue:[ |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
493 |
^ self defaultDirectory |
3959 | 494 |
]. |
495 |
^ self named:s |
|
496 |
||
497 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
498 |
Filename homeDirectory |
3959 | 499 |
" |
500 |
||
501 |
"Modified: 8.9.1997 / 00:25:23 / cg" |
|
502 |
! |
|
503 |
||
504 |
named:aString |
|
505 |
"return a filename for a directory named aString. |
|
506 |
This is the same as 'aString asFilename'." |
|
507 |
||
11781
6488fd6cc498
Make AutoDeletedFilename work like Filename
Stefan Vogel <sv@exept.de>
parents:
11763
diff
changeset
|
508 |
self isAbstract ifTrue:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
509 |
^ ConcreteClass named:aString |
3959 | 510 |
]. |
8738 | 511 |
^ self basicNew setName:aString |
3959 | 512 |
|
513 |
" |
|
514 |
Filename named:'/tmp/fooBar' |
|
515 |
" |
|
516 |
||
517 |
"Modified: 7.9.1997 / 23:30:06 / cg" |
|
518 |
! |
|
519 |
||
520 |
newTemporary |
|
521 |
"return a new unique filename - use this for temporary files. |
|
522 |
The filenames returned are '/tmp/stxtmp_xx_nn' where xx is our |
|
523 |
unix process id, and nn is a unique number, incremented with every |
|
524 |
call to this method. |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
525 |
If any of the environment variables ST_TMPDIR or TMPDIR is set, |
4757 | 526 |
its value defines the temp directory. |
527 |
Notice, that no file is created by this - only a unique name |
|
15459 | 528 |
is generated. |
529 |
||
16787 | 530 |
DO NOT USE THIS FOR PLAIN FILES - IT IS UNSECURE use FileStream>>#newTemporary |
531 |
(the insecurity is due to a small chance for some other program to open/create |
|
532 |
the file, as only a name is generated here. However, chances are small as the name |
|
533 |
is reasonably random - but for security relevant applications, this may be relevant) |
|
534 |
" |
|
3959 | 535 |
|
9912 | 536 |
^ self newTemporaryIn:(self tempDirectory) |
3959 | 537 |
|
538 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
539 |
Filename newTemporary |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
540 |
Filename newTemporary |
3959 | 541 |
" |
542 |
||
543 |
"Modified: 7.9.1995 / 10:48:31 / claus" |
|
544 |
"Modified: 7.3.1996 / 14:51:33 / cg" |
|
545 |
! |
|
546 |
||
9912 | 547 |
newTemporaryDirectory |
548 |
"return a new unique temporary directory - use this for temporary files. |
|
549 |
The directories returned are '/tmp/stxtmp_xx_nn' where xx is our |
|
550 |
unix process id, and nn is a unique number, incremented with every |
|
551 |
call to this method. |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
552 |
If any of the environment variables ST_TMPDIR or TMPDIR is set, |
9912 | 553 |
its value defines the temp directory." |
554 |
||
555 |
^ self newTemporaryDirectoryIn:(self tempDirectory) |
|
556 |
! |
|
557 |
||
558 |
newTemporaryDirectoryIn:aDirectoryOrNil |
|
559 |
"return a new unique temporary directory in another directory, or the current dir. |
|
560 |
Use this for temporary files. |
|
561 |
The directories returned are '/tmp/stxtmp_xx_nn' where xx is our |
|
562 |
unix process id, and nn is a unique number, incremented with every |
|
563 |
call to this method. |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
564 |
If any of the environment variables ST_TMPDIR or TMPDIR is set, |
9912 | 565 |
its value defines the temp directory." |
566 |
||
567 |
|tempdir| |
|
568 |
||
15811 | 569 |
tempdir := self newTemporaryIn:aDirectoryOrNil. |
9912 | 570 |
tempdir exists ifTrue:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
571 |
tempdir recursiveRemove. |
9912 | 572 |
]. |
573 |
tempdir makeDirectory. |
|
574 |
^ tempdir |
|
575 |
! |
|
576 |
||
577 |
newTemporaryIn:aDirectoryOrNil |
|
3959 | 578 |
"return a new unique filename - use this for temporary files. |
579 |
The filenames returned are in aDirectoryPrefix and named 'stxtmp_xx_nn', |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
580 |
where xx is our unix process id, and nn is a unique number, incremented |
3959 | 581 |
with every call to this method. |
582 |
Notice: only a unique filename object is created and returned - no physical |
|
583 |
file is created by this method (i.e. you have to send #writeStream or |
|
584 |
whatever to it in order to really create something). |
|
15459 | 585 |
See also: #newTemporary which looks for a good temp directory. |
586 |
||
587 |
DO NOT USE THIS FOR PLAIN FILES - IT IS UNSECURE use FileStream>>#newTemporaryIn:" |
|
3959 | 588 |
|
12617 | 589 |
^ self newTemporaryIn:aDirectoryOrNil nameTemplate:(self tempFileNameTemplate) |
3959 | 590 |
|
591 |
"temp files in '/tmp': |
|
592 |
||
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
593 |
Filename newTemporary |
19665 | 594 |
Filename newTemporaryIn:(Filename tempDirectory) |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
595 |
" |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
596 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
597 |
"temp files somewhere |
3959 | 598 |
(not recommended - use above since it can be controlled via shell variables): |
599 |
||
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
600 |
UnixFilename newTemporaryIn:'/tmp' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
601 |
UnixFilename newTemporaryIn:'/tmp' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
602 |
UnixFilename newTemporaryIn:'/usr/tmp' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
603 |
UnixFilename newTemporaryIn:'/' |
3959 | 604 |
" |
605 |
||
606 |
"a local temp file: |
|
607 |
||
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
608 |
Filename newTemporaryIn:'' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
609 |
Filename newTemporaryIn:nil |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
610 |
Filename newTemporaryIn:'.' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
611 |
Filename newTemporaryIn:('source' asFilename) |
3959 | 612 |
" |
613 |
||
614 |
"Modified: / 7.9.1995 / 10:48:31 / claus" |
|
615 |
"Modified: / 11.8.1998 / 22:51:43 / cg" |
|
616 |
! |
|
617 |
||
9912 | 618 |
newTemporaryIn:aDirectoryOrNil nameTemplate:template |
6893
9aa286d3a644
added newTemporary with template
Claus Gittinger <cg@exept.de>
parents:
6839
diff
changeset
|
619 |
"return a new unique filename - use this for temporary files. |
9912 | 620 |
The filenames returned are in aDirectoryOrNil and named after the given template, |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
621 |
in which %1 and %2 are expanded to the unix process id, and a unique number, incremented |
6893
9aa286d3a644
added newTemporary with template
Claus Gittinger <cg@exept.de>
parents:
6839
diff
changeset
|
622 |
with every call to this method respectively. |
19665 | 623 |
If the template does not contain %-meta characters, and the file already exists, |
624 |
a sequence of _1, _2,... is appended to the name. This is dangerous, as it does not prevent race |
|
625 |
conditions (if two such files are created at the same time). |
|
626 |
||
6893
9aa286d3a644
added newTemporary with template
Claus Gittinger <cg@exept.de>
parents:
6839
diff
changeset
|
627 |
Notice: only a unique filename object is created and returned - no physical |
9aa286d3a644
added newTemporary with template
Claus Gittinger <cg@exept.de>
parents:
6839
diff
changeset
|
628 |
file is created by this method (i.e. you have to send #writeStream or |
9aa286d3a644
added newTemporary with template
Claus Gittinger <cg@exept.de>
parents:
6839
diff
changeset
|
629 |
whatever to it in order to really create something). |
15459 | 630 |
See also: #newTemporary which looks for a good temp directory. |
631 |
||
632 |
DO NOT USE THIS FOR PLAIN FILES - IT IS UNSECURE use FileStream>>#newTemporaryIn:nameTemplate:" |
|
6893
9aa286d3a644
added newTemporary with template
Claus Gittinger <cg@exept.de>
parents:
6839
diff
changeset
|
633 |
|
19665 | 634 |
|newTempFilename oldNameString nextSeqNr| |
8738 | 635 |
|
11781
6488fd6cc498
Make AutoDeletedFilename work like Filename
Stefan Vogel <sv@exept.de>
parents:
11763
diff
changeset
|
636 |
self isAbstract ifTrue:[ |
19665 | 637 |
^ ConcreteClass newTemporaryIn:aDirectoryOrNil nameTemplate:template |
6893
9aa286d3a644
added newTemporary with template
Claus Gittinger <cg@exept.de>
parents:
6839
diff
changeset
|
638 |
]. |
9aa286d3a644
added newTemporary with template
Claus Gittinger <cg@exept.de>
parents:
6839
diff
changeset
|
639 |
|
8738 | 640 |
"although the above allows things to be redefined in concrete classes, |
641 |
the following should work on all systems ..." |
|
642 |
||
643 |
[ |
|
19665 | 644 |
|nameString fn| |
645 |
||
646 |
"Use random numbers in order to improve the security |
|
647 |
by making the generated names less predictable" |
|
648 |
nameString := template bindWith:(OperatingSystem getProcessId) with:(RandomGenerator nextLettersOrDigits:4). |
|
649 |
(oldNameString = nameString) ifTrue:[ |
|
650 |
"/ ouch - the given template seems to not generate unique file names. |
|
651 |
"/ append a sequence number |
|
652 |
nextSeqNr := (nextSeqNr ? 0) + 1. |
|
653 |
fn := nameString asFilename. |
|
654 |
nameString := fn withoutSuffix name,'_',nextSeqNr asString,'.' , fn suffix. |
|
655 |
]. |
|
656 |
||
657 |
aDirectoryOrNil isNil ifTrue:[ |
|
658 |
newTempFilename := self named:nameString |
|
659 |
] ifFalse:[ |
|
660 |
newTempFilename := aDirectoryOrNil asFilename construct:nameString |
|
661 |
]. |
|
662 |
oldNameString := nameString. |
|
8738 | 663 |
] doWhile:[ |
19665 | 664 |
"care for existing leftOver tempFiles |
665 |
from a previous boot of the OS |
|
666 |
i.e. my pid could be the same as when executed |
|
667 |
the last time before system reboot ...)" |
|
668 |
||
669 |
newTempFilename exists |
|
6893
9aa286d3a644
added newTemporary with template
Claus Gittinger <cg@exept.de>
parents:
6839
diff
changeset
|
670 |
]. |
8738 | 671 |
^ newTempFilename |
6893
9aa286d3a644
added newTemporary with template
Claus Gittinger <cg@exept.de>
parents:
6839
diff
changeset
|
672 |
|
9aa286d3a644
added newTemporary with template
Claus Gittinger <cg@exept.de>
parents:
6839
diff
changeset
|
673 |
"temp files in '/tmp': |
9aa286d3a644
added newTemporary with template
Claus Gittinger <cg@exept.de>
parents:
6839
diff
changeset
|
674 |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
675 |
Filename newTemporary |
19665 | 676 |
Filename newTemporaryIn:nil nameTemplate:'out_%1_%2.txt' |
677 |
Filename newTemporaryIn:(Filename tempDirectory) nameTemplate:'out_%1_%2.txt' |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
678 |
" |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
679 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
680 |
"temp files somewhere |
6893
9aa286d3a644
added newTemporary with template
Claus Gittinger <cg@exept.de>
parents:
6839
diff
changeset
|
681 |
(not recommended - use above since it can be controlled via shell variables): |
9aa286d3a644
added newTemporary with template
Claus Gittinger <cg@exept.de>
parents:
6839
diff
changeset
|
682 |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
683 |
UnixFilename newTemporaryIn:'/tmp' nameTemplate:'foo%1_%2' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
684 |
UnixFilename newTemporaryIn:'/tmp' nameTemplate:'foo%1_%2' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
685 |
UnixFilename newTemporaryIn:'/usr/tmp' nameTemplate:'foo%1_%2' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
686 |
UnixFilename newTemporaryIn:'/' nameTemplate:'foo%1_%2' |
6893
9aa286d3a644
added newTemporary with template
Claus Gittinger <cg@exept.de>
parents:
6839
diff
changeset
|
687 |
" |
9aa286d3a644
added newTemporary with template
Claus Gittinger <cg@exept.de>
parents:
6839
diff
changeset
|
688 |
|
9aa286d3a644
added newTemporary with template
Claus Gittinger <cg@exept.de>
parents:
6839
diff
changeset
|
689 |
"a local temp file: |
9aa286d3a644
added newTemporary with template
Claus Gittinger <cg@exept.de>
parents:
6839
diff
changeset
|
690 |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
691 |
Filename newTemporaryIn:'' nameTemplate:'foo%1_%2' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
692 |
Filename newTemporaryIn:nil nameTemplate:'foo%1_%2' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
693 |
Filename newTemporaryIn:'.' nameTemplate:'foo%1_%2' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
694 |
Filename newTemporaryIn:('source' asFilename) nameTemplate:'foo%1_%2' |
6893
9aa286d3a644
added newTemporary with template
Claus Gittinger <cg@exept.de>
parents:
6839
diff
changeset
|
695 |
" |
9aa286d3a644
added newTemporary with template
Claus Gittinger <cg@exept.de>
parents:
6839
diff
changeset
|
696 |
|
12918
a9de9243a951
changed: #newTemporaryIn:nameTemplate:
Claus Gittinger <cg@exept.de>
parents:
12910
diff
changeset
|
697 |
"Modified: / 07-09-1995 / 10:48:31 / claus" |
a9de9243a951
changed: #newTemporaryIn:nameTemplate:
Claus Gittinger <cg@exept.de>
parents:
12910
diff
changeset
|
698 |
"Modified: / 07-05-2010 / 11:46:05 / cg" |
6893
9aa286d3a644
added newTemporary with template
Claus Gittinger <cg@exept.de>
parents:
6839
diff
changeset
|
699 |
! |
9aa286d3a644
added newTemporary with template
Claus Gittinger <cg@exept.de>
parents:
6839
diff
changeset
|
700 |
|
4199 | 701 |
nullDevice |
702 |
"return the filename of the nullDevice (if available). |
|
703 |
returns nil, if the OperatingSystem does not support this." |
|
704 |
||
705 |
|s| |
|
706 |
||
8754 | 707 |
s := self nullFilename. |
4199 | 708 |
s isNil ifTrue:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
709 |
^ nil |
4199 | 710 |
]. |
711 |
^ self named:s |
|
712 |
||
713 |
" |
|
8754 | 714 |
Filename nullDevice |
715 |
UnixFilename nullDevice |
|
716 |
PCFilename nullDevice |
|
4199 | 717 |
" |
718 |
||
719 |
"Created: / 19.5.1999 / 12:24:26 / cg" |
|
720 |
! |
|
721 |
||
6256 | 722 |
remoteHost:remoteHostString rootComponents:aCollectionOfDirectoryNames |
723 |
"create & return a new filename from components given in |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
724 |
aCollectionOfDirectoryNames on a host named remoteHostString. |
6256 | 725 |
An absolute network-filename is returned." |
726 |
||
11781
6488fd6cc498
Make AutoDeletedFilename work like Filename
Stefan Vogel <sv@exept.de>
parents:
11763
diff
changeset
|
727 |
self isAbstract ifTrue:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
728 |
^ ConcreteClass remoteHost:remoteHostString |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
729 |
rootComponents:aCollectionOfDirectoryNames |
6256 | 730 |
]. |
731 |
||
10390 | 732 |
remoteHostString notEmptyOrNil ifTrue:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
733 |
self error:'remote hosts are not supported by OS' |
10390 | 734 |
]. |
735 |
||
736 |
^ self rootComponents:aCollectionOfDirectoryNames |
|
737 |
||
738 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
739 |
'file:///tmp/test' asURI asFilename |
10390 | 740 |
" |
6256 | 741 |
! |
742 |
||
743 |
rootComponents:aCollectionOfDirectoryNames |
|
744 |
"create & return a new filename from components given in |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
745 |
aCollectionOfDirectoryNames. |
6256 | 746 |
An absolute path-filename is returned." |
747 |
||
748 |
|sep s| |
|
749 |
||
11781
6488fd6cc498
Make AutoDeletedFilename work like Filename
Stefan Vogel <sv@exept.de>
parents:
11763
diff
changeset
|
750 |
self isAbstract ifTrue:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
751 |
^ ConcreteClass rootComponents:aCollectionOfDirectoryNames |
6256 | 752 |
]. |
753 |
||
754 |
"/ fallBack - works on Unix & MSDOS |
|
755 |
||
8243 | 756 |
sep := self separatorString. |
18272 | 757 |
s := CharacterWriteStream new. |
6256 | 758 |
aCollectionOfDirectoryNames do:[:component | |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
759 |
component ~= sep ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
760 |
s nextPutAll:sep; nextPutAll:component |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
761 |
] |
6256 | 762 |
]. |
763 |
s := s contents. |
|
764 |
s size == 0 ifTrue:[s := sep]. |
|
765 |
^ self named:s |
|
766 |
||
767 |
" |
|
8754 | 768 |
Filename rootComponents:#('/' 'foo' 'bar' 'baz') |
769 |
||
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
770 |
Filename rootComponents:#('foo' 'bar' 'baz') |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
771 |
PCFilename rootComponents:#('foo' 'bar' 'baz') |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
772 |
UnixFilename rootComponents:#('foo' 'bar' 'baz') |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
773 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
774 |
Filename rootComponents:#('/') |
6256 | 775 |
|
776 |
Filename rootComponents: |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
777 |
(Filename components:('.' asFilename pathName)) |
6256 | 778 |
|
779 |
Filename rootComponents: |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
780 |
(Filename components:('.' asFilename name)) |
6256 | 781 |
" |
782 |
||
783 |
"Modified: 8.9.1997 / 00:23:16 / cg" |
|
784 |
! |
|
785 |
||
3959 | 786 |
rootDirectory |
787 |
"return a filename for the root directory" |
|
788 |
||
11781
6488fd6cc498
Make AutoDeletedFilename work like Filename
Stefan Vogel <sv@exept.de>
parents:
11763
diff
changeset
|
789 |
self isAbstract ifTrue:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
790 |
^ ConcreteClass rootDirectory |
3959 | 791 |
]. |
792 |
||
793 |
"/ fallBack - works on Unix & MSDOS (but not on VMS) |
|
794 |
||
8243 | 795 |
^ self named:(self separatorString) |
3959 | 796 |
|
797 |
" |
|
798 |
Filename rootDirectory |
|
799 |
" |
|
800 |
||
801 |
"Modified: 8.9.1997 / 00:24:15 / cg" |
|
802 |
! |
|
803 |
||
804 |
rootDirectoryOnVolume:aVolumeName |
|
805 |
"return a filename for the root directory on some volume" |
|
806 |
||
11781
6488fd6cc498
Make AutoDeletedFilename work like Filename
Stefan Vogel <sv@exept.de>
parents:
11763
diff
changeset
|
807 |
self isAbstract ifTrue:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
808 |
^ ConcreteClass rootDirectoryOnVolume:aVolumeName |
3959 | 809 |
]. |
810 |
||
811 |
"/ fallBack - works on Unix (not on MSDOS or VMS) |
|
812 |
||
813 |
^ self rootDirectory |
|
814 |
||
815 |
" |
|
816 |
Filename rootDirectoryOnVolume:'/phys/idefix' |
|
817 |
Filename rootDirectoryOnVolume:'d:' |
|
818 |
" |
|
819 |
||
820 |
"Modified: / 5.10.1998 / 12:45:39 / cg" |
|
821 |
! |
|
822 |
||
823 |
tempDirectory |
|
824 |
"return the temp directory as a filename. |
|
825 |
If any of the environment variables STX_TMPDIR, ST_TMPDIR, |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
826 |
TMPDIR or TEMPDIR is set, its value defines the name, |
3959 | 827 |
otherwise, '/tmp' is used. (at least on unix ...). |
828 |
||
829 |
Notice: do not hardcode '/tmp' into your programs - things may be |
|
19599 | 830 |
different on other operating systems. Also, the user may want to set the |
831 |
TMPDIR environment variable to have her temp files somewhere else." |
|
3959 | 832 |
|
833 |
|tempDir| |
|
834 |
||
9806 | 835 |
TempDirectory isNil ifTrue:[ |
19599 | 836 |
tempDir := self named:(self defaultTempDirectoryName pathName). |
837 |
tempDir exists ifFalse:[ |
|
838 |
tempDir |
|
839 |
makeDirectory; |
|
840 |
addAccessRights:#(readUser readGroup readOthers |
|
841 |
writeUser writeGroup writeOthers |
|
842 |
executeUser executeGroup executeOthers |
|
843 |
removeOnlyByOwner). |
|
844 |
]. |
|
845 |
TempDirectory := DefaultTempDirectory := tempDir construct:'stx_tmp'. |
|
3959 | 846 |
]. |
10551
4924bf1ce2e3
#tempDirectory - make sure, that it exists
Stefan Vogel <sv@exept.de>
parents:
10546
diff
changeset
|
847 |
|
4924bf1ce2e3
#tempDirectory - make sure, that it exists
Stefan Vogel <sv@exept.de>
parents:
10546
diff
changeset
|
848 |
"Make sure, that the TempDirectory exists - it might have been removed |
10663
b95f903be43e
Make temp dir accessible to all users
Stefan Vogel <sv@exept.de>
parents:
10583
diff
changeset
|
849 |
by a cleanup (cron) job. |
19114 | 850 |
Since it is shared between users, it must be accessible by all users." |
10551
4924bf1ce2e3
#tempDirectory - make sure, that it exists
Stefan Vogel <sv@exept.de>
parents:
10546
diff
changeset
|
851 |
|
4924bf1ce2e3
#tempDirectory - make sure, that it exists
Stefan Vogel <sv@exept.de>
parents:
10546
diff
changeset
|
852 |
TempDirectory exists ifFalse:[ |
19599 | 853 |
TempDirectory |
854 |
makeDirectory; |
|
855 |
addAccessRights:#(readUser readGroup readOthers |
|
856 |
writeUser writeGroup writeOthers |
|
857 |
executeUser executeGroup executeOthers |
|
858 |
removeOnlyByOwner). |
|
10551
4924bf1ce2e3
#tempDirectory - make sure, that it exists
Stefan Vogel <sv@exept.de>
parents:
10546
diff
changeset
|
859 |
]. |
9806 | 860 |
^ TempDirectory |
3959 | 861 |
|
862 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
863 |
Filename tempDirectory |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
864 |
Filename tempDirectory pathName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
865 |
Filename tempDirectory exists |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
866 |
Filename tempDirectory isWritable |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
867 |
(Filename tempDirectory construct:'foo') makeDirectory |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
868 |
(Filename tempDirectory construct:'foo') remove |
3959 | 869 |
" |
870 |
||
9806 | 871 |
"Created: / 07-03-1996 / 14:51:18 / cg" |
13781 | 872 |
"Modified: / 07-10-2011 / 18:39:25 / cg" |
11757
a2ce2d0ab680
new Filename class>>#tempFilename
Stefan Vogel <sv@exept.de>
parents:
11748
diff
changeset
|
873 |
! |
a2ce2d0ab680
new Filename class>>#tempFilename
Stefan Vogel <sv@exept.de>
parents:
11748
diff
changeset
|
874 |
|
a2ce2d0ab680
new Filename class>>#tempFilename
Stefan Vogel <sv@exept.de>
parents:
11748
diff
changeset
|
875 |
tempDirectory:aFilename |
17048 | 876 |
"set the default temporary directory. |
877 |
This allows overwriting the automatically determined tmpDirectory |
|
878 |
by a knowledgable stand alone startup program. |
|
19114 | 879 |
Do not use elsewhere (and only if absolutely required)" |
11757
a2ce2d0ab680
new Filename class>>#tempFilename
Stefan Vogel <sv@exept.de>
parents:
11748
diff
changeset
|
880 |
|
a2ce2d0ab680
new Filename class>>#tempFilename
Stefan Vogel <sv@exept.de>
parents:
11748
diff
changeset
|
881 |
|temp| |
a2ce2d0ab680
new Filename class>>#tempFilename
Stefan Vogel <sv@exept.de>
parents:
11748
diff
changeset
|
882 |
|
a2ce2d0ab680
new Filename class>>#tempFilename
Stefan Vogel <sv@exept.de>
parents:
11748
diff
changeset
|
883 |
aFilename isNil ifTrue:[ |
19599 | 884 |
TempDirectory := nil. |
885 |
^ self. |
|
11757
a2ce2d0ab680
new Filename class>>#tempFilename
Stefan Vogel <sv@exept.de>
parents:
11748
diff
changeset
|
886 |
]. |
a2ce2d0ab680
new Filename class>>#tempFilename
Stefan Vogel <sv@exept.de>
parents:
11748
diff
changeset
|
887 |
|
a2ce2d0ab680
new Filename class>>#tempFilename
Stefan Vogel <sv@exept.de>
parents:
11748
diff
changeset
|
888 |
temp := aFilename asFilename. |
a2ce2d0ab680
new Filename class>>#tempFilename
Stefan Vogel <sv@exept.de>
parents:
11748
diff
changeset
|
889 |
self assert:temp isDirectory. |
a2ce2d0ab680
new Filename class>>#tempFilename
Stefan Vogel <sv@exept.de>
parents:
11748
diff
changeset
|
890 |
TempDirectory := temp. |
16382 | 891 |
! |
892 |
||
893 |
trashDirectoryOrNil |
|
894 |
"if the underlying OS uses/supports a trash folder, |
|
895 |
return it. Otherwise return nil. |
|
896 |
Asks the OS for the pathname; for example, on OSX, '~/.Trash' is returned." |
|
897 |
||
898 |
|s| |
|
899 |
||
900 |
s := OperatingSystem getTrashDirectory. |
|
901 |
s isNil ifTrue:[ |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
902 |
^ nil |
16382 | 903 |
]. |
904 |
^ self named:s |
|
905 |
||
906 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
907 |
Filename desktopDirectory |
16382 | 908 |
" |
909 |
||
910 |
"Created: / 16-05-2007 / 13:18:34 / cg" |
|
16648 | 911 |
! |
912 |
||
913 |
usersPrivateSmalltalkDirectory |
|
914 |
^ Filename homeDirectory / '.smalltalk' |
|
915 |
||
916 |
" |
|
917 |
Filename usersPrivateSmalltalkDirectory |
|
918 |
" |
|
3959 | 919 |
! ! |
920 |
||
2168
649e90de1312
added filesMatching: in class protocol;
Claus Gittinger <cg@exept.de>
parents:
2013
diff
changeset
|
921 |
!Filename class methodsFor:'defaults'! |
649e90de1312
added filesMatching: in class protocol;
Claus Gittinger <cg@exept.de>
parents:
2013
diff
changeset
|
922 |
|
649e90de1312
added filesMatching: in class protocol;
Claus Gittinger <cg@exept.de>
parents:
2013
diff
changeset
|
923 |
concreteClass |
6256 | 924 |
"different subclasses of Filename are used for different |
925 |
OperatingSystems; concreteClass is supposed to return an appropriate class." |
|
2168
649e90de1312
added filesMatching: in class protocol;
Claus Gittinger <cg@exept.de>
parents:
2013
diff
changeset
|
926 |
|
2906 | 927 |
^ ConcreteClass ? self |
2168
649e90de1312
added filesMatching: in class protocol;
Claus Gittinger <cg@exept.de>
parents:
2013
diff
changeset
|
928 |
|
649e90de1312
added filesMatching: in class protocol;
Claus Gittinger <cg@exept.de>
parents:
2013
diff
changeset
|
929 |
"Created: 14.2.1997 / 16:36:13 / cg" |
2906 | 930 |
"Modified: 7.9.1997 / 23:29:20 / cg" |
2168
649e90de1312
added filesMatching: in class protocol;
Claus Gittinger <cg@exept.de>
parents:
2013
diff
changeset
|
931 |
! |
649e90de1312
added filesMatching: in class protocol;
Claus Gittinger <cg@exept.de>
parents:
2013
diff
changeset
|
932 |
|
649e90de1312
added filesMatching: in class protocol;
Claus Gittinger <cg@exept.de>
parents:
2013
diff
changeset
|
933 |
defaultClass |
6256 | 934 |
"different subclasses of Filename are used for different |
935 |
OperatingSystems; defaultClass is supposed to return an appropriate class" |
|
2168
649e90de1312
added filesMatching: in class protocol;
Claus Gittinger <cg@exept.de>
parents:
2013
diff
changeset
|
936 |
|
2906 | 937 |
^ ConcreteClass |
938 |
||
939 |
"Modified: 8.9.1997 / 00:36:01 / cg" |
|
7836 | 940 |
! |
941 |
||
942 |
defaultTempDirectoryName |
|
943 |
"return the default temp directory as a filename. |
|
944 |
This is used, if no special preferences were defined in |
|
945 |
any of the TEMP-environment variables (see tempDirectory)." |
|
946 |
||
11781
6488fd6cc498
Make AutoDeletedFilename work like Filename
Stefan Vogel <sv@exept.de>
parents:
11763
diff
changeset
|
947 |
self isAbstract ifTrue:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
948 |
^ ConcreteClass defaultTempDirectoryName |
7836 | 949 |
]. |
950 |
||
10994
1a3776d0b845
always return a fileName from defaultTempDirectoryName
fm
parents:
10969
diff
changeset
|
951 |
^ '/tmp' asFilename |
7836 | 952 |
|
953 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
954 |
Filename defaultTempDirectoryName |
7836 | 955 |
" |
956 |
||
957 |
"Modified: 7.9.1995 / 10:48:31 / claus" |
|
958 |
"Created: 7.3.1996 / 14:51:18 / cg" |
|
959 |
"Modified: 8.9.1997 / 00:24:53 / cg" |
|
19599 | 960 |
! |
961 |
||
962 |
defaultVolumeName |
|
963 |
^ '/' |
|
2168
649e90de1312
added filesMatching: in class protocol;
Claus Gittinger <cg@exept.de>
parents:
2013
diff
changeset
|
964 |
! ! |
649e90de1312
added filesMatching: in class protocol;
Claus Gittinger <cg@exept.de>
parents:
2013
diff
changeset
|
965 |
|
2922 | 966 |
!Filename class methodsFor:'misc'! |
967 |
||
3077 | 968 |
filterSeps:aFilenameString |
969 |
"ST80 compatibility: |
|
970 |
filter out (invalid) separators in aFilenameString. |
|
971 |
We recommend using #makeLegalFilename" |
|
972 |
||
16762 | 973 |
^ aFilenameString copyReplaceAll:(Character space) with:$_ ifNone:aFilenameString. |
3077 | 974 |
|
975 |
"Created: / 1.11.1997 / 12:39:50 / cg" |
|
3658 | 976 |
"Modified: / 18.7.1998 / 22:53:24 / cg" |
3077 | 977 |
! |
978 |
||
14220
2a3457b016be
Fix the '~/dir/name' resolution fow windows
Stefan Vogel <sv@exept.de>
parents:
14218
diff
changeset
|
979 |
nameWithSpecialExpansions:aString |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
980 |
"return the nameString, expanding any OS specific macros. |
14220
2a3457b016be
Fix the '~/dir/name' resolution fow windows
Stefan Vogel <sv@exept.de>
parents:
14218
diff
changeset
|
981 |
Here, a ~/ or ~user/ prefix is expanded to the users home dir (as in csh)" |
2a3457b016be
Fix the '~/dir/name' resolution fow windows
Stefan Vogel <sv@exept.de>
parents:
14218
diff
changeset
|
982 |
|
2a3457b016be
Fix the '~/dir/name' resolution fow windows
Stefan Vogel <sv@exept.de>
parents:
14218
diff
changeset
|
983 |
|dir user cutIdx idx userInfo| |
2a3457b016be
Fix the '~/dir/name' resolution fow windows
Stefan Vogel <sv@exept.de>
parents:
14218
diff
changeset
|
984 |
|
19670 | 985 |
(aString startsWith:$~) ifFalse:[ |
986 |
^ aString. |
|
14220
2a3457b016be
Fix the '~/dir/name' resolution fow windows
Stefan Vogel <sv@exept.de>
parents:
14218
diff
changeset
|
987 |
]. |
2a3457b016be
Fix the '~/dir/name' resolution fow windows
Stefan Vogel <sv@exept.de>
parents:
14218
diff
changeset
|
988 |
|
2a3457b016be
Fix the '~/dir/name' resolution fow windows
Stefan Vogel <sv@exept.de>
parents:
14218
diff
changeset
|
989 |
aString size > 1 ifTrue:[ |
19670 | 990 |
idx := aString indexOf:self separator. |
991 |
idx == 0 ifTrue:[ |
|
992 |
"aString is '~user'" |
|
993 |
user := aString copyFrom:2. |
|
994 |
cutIdx := aString size + 1. |
|
995 |
] ifFalse:[ |
|
996 |
"aString is '~user/something'" |
|
997 |
user := aString copyFrom:2 to:(idx - 1). |
|
998 |
cutIdx := idx. |
|
999 |
]. |
|
1000 |
user notEmpty ifTrue:[ |
|
1001 |
userInfo := OperatingSystem userInfoOf:user. |
|
1002 |
userInfo notNil ifTrue:[ |
|
1003 |
dir := userInfo at:#dir ifAbsent:nil. |
|
1004 |
]. |
|
1005 |
dir isNil ifTrue:[ |
|
14220
2a3457b016be
Fix the '~/dir/name' resolution fow windows
Stefan Vogel <sv@exept.de>
parents:
14218
diff
changeset
|
1006 |
"/ ('Filename [info]: unknown user: ' , user) infoPrintCR. |
19670 | 1007 |
^ aString |
1008 |
]. |
|
1009 |
]. |
|
14220
2a3457b016be
Fix the '~/dir/name' resolution fow windows
Stefan Vogel <sv@exept.de>
parents:
14218
diff
changeset
|
1010 |
]. |
2a3457b016be
Fix the '~/dir/name' resolution fow windows
Stefan Vogel <sv@exept.de>
parents:
14218
diff
changeset
|
1011 |
dir isNil ifTrue:[ |
19670 | 1012 |
"aString is '~' or '~/'" |
1013 |
dir := OperatingSystem getHomeDirectory. |
|
1014 |
cutIdx := 2. |
|
14220
2a3457b016be
Fix the '~/dir/name' resolution fow windows
Stefan Vogel <sv@exept.de>
parents:
14218
diff
changeset
|
1015 |
]. |
2a3457b016be
Fix the '~/dir/name' resolution fow windows
Stefan Vogel <sv@exept.de>
parents:
14218
diff
changeset
|
1016 |
|
2a3457b016be
Fix the '~/dir/name' resolution fow windows
Stefan Vogel <sv@exept.de>
parents:
14218
diff
changeset
|
1017 |
^ dir , (aString copyFrom:cutIdx) |
2a3457b016be
Fix the '~/dir/name' resolution fow windows
Stefan Vogel <sv@exept.de>
parents:
14218
diff
changeset
|
1018 |
|
2a3457b016be
Fix the '~/dir/name' resolution fow windows
Stefan Vogel <sv@exept.de>
parents:
14218
diff
changeset
|
1019 |
" |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1020 |
Filename new nameWithSpecialExpansions:'~' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1021 |
Filename new nameWithSpecialExpansions:'~\work' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1022 |
Filename new nameWithSpecialExpansions:'~stefan' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1023 |
Filename new nameWithSpecialExpansions:'~stefan\work' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1024 |
Filename new nameWithSpecialExpansions:'~foo' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1025 |
Filename new nameWithSpecialExpansions:'~foo\bar' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1026 |
" |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1027 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1028 |
" |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1029 |
UnixFilename new nameWithSpecialExpansions:'~' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1030 |
UnixFilename new nameWithSpecialExpansions:'~/work' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1031 |
UnixFilename new nameWithSpecialExpansions:'~stefan' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1032 |
UnixFilename new nameWithSpecialExpansions:'~stefan/work' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1033 |
UnixFilename new nameWithSpecialExpansions:'~foo' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1034 |
UnixFilename new nameWithSpecialExpansions:'~foo/bar' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1035 |
" |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1036 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1037 |
" |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1038 |
PCFilename new nameWithSpecialExpansions:'~' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1039 |
PCFilename new nameWithSpecialExpansions:'~\work' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1040 |
PCFilename new nameWithSpecialExpansions:'~stefan' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1041 |
PCFilename new nameWithSpecialExpansions:'~stefan\work' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1042 |
PCFilename new nameWithSpecialExpansions:'~foo' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1043 |
PCFilename new nameWithSpecialExpansions:'~foo\bar' |
14220
2a3457b016be
Fix the '~/dir/name' resolution fow windows
Stefan Vogel <sv@exept.de>
parents:
14218
diff
changeset
|
1044 |
" |
2a3457b016be
Fix the '~/dir/name' resolution fow windows
Stefan Vogel <sv@exept.de>
parents:
14218
diff
changeset
|
1045 |
! |
2a3457b016be
Fix the '~/dir/name' resolution fow windows
Stefan Vogel <sv@exept.de>
parents:
14218
diff
changeset
|
1046 |
|
16999 | 1047 |
possiblyQuotedPathname:aPath |
1048 |
"return a filename path usable as command line argument, |
|
1049 |
by quoting in double quotes if there are any embedded special characters. |
|
1050 |
On Unix systems, special characters might also be prefixed by a backslash character." |
|
1051 |
||
19670 | 1052 |
(aPath startsWith:$") ifFalse:[ |
1053 |
(aPath includes:Character space) ifTrue:[ |
|
1054 |
^ '"',aPath,'"' |
|
1055 |
]. |
|
16999 | 1056 |
]. |
1057 |
^ aPath |
|
1058 |
||
1059 |
||
1060 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1061 |
Filename possiblyQuotedPathname:'/tmp/bla' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1062 |
Filename possiblyQuotedPathname:'/tmp directory/bla' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1063 |
Filename possiblyQuotedPathname:'/tmp directory/bla file' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1064 |
" |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1065 |
! |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1066 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1067 |
suggest:aFilenameString |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1068 |
"return a fileNamestring based on the argument, |
3077 | 1069 |
which is legal on the current platform." |
1070 |
||
1071 |
^ self canonicalize:aFilenameString |
|
1072 |
||
1073 |
"Created: / 1.11.1997 / 12:42:39 / cg" |
|
2922 | 1074 |
! ! |
1075 |
||
1859
7f6040320daf
changes for new return from OS>>infoOf:
Claus Gittinger <cg@exept.de>
parents:
1614
diff
changeset
|
1076 |
!Filename class methodsFor:'queries'! |
2 | 1077 |
|
10663
b95f903be43e
Make temp dir accessible to all users
Stefan Vogel <sv@exept.de>
parents:
10583
diff
changeset
|
1078 |
currentDirectoryName |
b95f903be43e
Make temp dir accessible to all users
Stefan Vogel <sv@exept.de>
parents:
10583
diff
changeset
|
1079 |
"return a filename for the current directory" |
b95f903be43e
Make temp dir accessible to all users
Stefan Vogel <sv@exept.de>
parents:
10583
diff
changeset
|
1080 |
|
11781
6488fd6cc498
Make AutoDeletedFilename work like Filename
Stefan Vogel <sv@exept.de>
parents:
11763
diff
changeset
|
1081 |
self isAbstract ifTrue:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1082 |
^ ConcreteClass currentDirectoryName |
10663
b95f903be43e
Make temp dir accessible to all users
Stefan Vogel <sv@exept.de>
parents:
10583
diff
changeset
|
1083 |
]. |
b95f903be43e
Make temp dir accessible to all users
Stefan Vogel <sv@exept.de>
parents:
10583
diff
changeset
|
1084 |
|
b95f903be43e
Make temp dir accessible to all users
Stefan Vogel <sv@exept.de>
parents:
10583
diff
changeset
|
1085 |
"/ fallBack - works on Unix & MSDOS (but not on VMS) |
b95f903be43e
Make temp dir accessible to all users
Stefan Vogel <sv@exept.de>
parents:
10583
diff
changeset
|
1086 |
|
b95f903be43e
Make temp dir accessible to all users
Stefan Vogel <sv@exept.de>
parents:
10583
diff
changeset
|
1087 |
^ '.' |
b95f903be43e
Make temp dir accessible to all users
Stefan Vogel <sv@exept.de>
parents:
10583
diff
changeset
|
1088 |
|
b95f903be43e
Make temp dir accessible to all users
Stefan Vogel <sv@exept.de>
parents:
10583
diff
changeset
|
1089 |
" |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1090 |
Filename currentDirectoryName |
10663
b95f903be43e
Make temp dir accessible to all users
Stefan Vogel <sv@exept.de>
parents:
10583
diff
changeset
|
1091 |
" |
b95f903be43e
Make temp dir accessible to all users
Stefan Vogel <sv@exept.de>
parents:
10583
diff
changeset
|
1092 |
|
b95f903be43e
Make temp dir accessible to all users
Stefan Vogel <sv@exept.de>
parents:
10583
diff
changeset
|
1093 |
"Modified: / 8.9.1997 / 00:24:15 / cg" |
b95f903be43e
Make temp dir accessible to all users
Stefan Vogel <sv@exept.de>
parents:
10583
diff
changeset
|
1094 |
"Created: / 21.10.1998 / 17:49:57 / cg" |
b95f903be43e
Make temp dir accessible to all users
Stefan Vogel <sv@exept.de>
parents:
10583
diff
changeset
|
1095 |
! |
b95f903be43e
Make temp dir accessible to all users
Stefan Vogel <sv@exept.de>
parents:
10583
diff
changeset
|
1096 |
|
b95f903be43e
Make temp dir accessible to all users
Stefan Vogel <sv@exept.de>
parents:
10583
diff
changeset
|
1097 |
defaultDirectoryName |
b95f903be43e
Make temp dir accessible to all users
Stefan Vogel <sv@exept.de>
parents:
10583
diff
changeset
|
1098 |
"ST80 compatibility: return the defaultDirectories name (as a string)" |
b95f903be43e
Make temp dir accessible to all users
Stefan Vogel <sv@exept.de>
parents:
10583
diff
changeset
|
1099 |
|
b95f903be43e
Make temp dir accessible to all users
Stefan Vogel <sv@exept.de>
parents:
10583
diff
changeset
|
1100 |
^ self defaultDirectory name |
b95f903be43e
Make temp dir accessible to all users
Stefan Vogel <sv@exept.de>
parents:
10583
diff
changeset
|
1101 |
|
b95f903be43e
Make temp dir accessible to all users
Stefan Vogel <sv@exept.de>
parents:
10583
diff
changeset
|
1102 |
" |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1103 |
Filename defaultDirectoryName |
10663
b95f903be43e
Make temp dir accessible to all users
Stefan Vogel <sv@exept.de>
parents:
10583
diff
changeset
|
1104 |
" |
b95f903be43e
Make temp dir accessible to all users
Stefan Vogel <sv@exept.de>
parents:
10583
diff
changeset
|
1105 |
! |
b95f903be43e
Make temp dir accessible to all users
Stefan Vogel <sv@exept.de>
parents:
10583
diff
changeset
|
1106 |
|
2963 | 1107 |
directorySuffix |
1108 |
"Return the OS dependent directory suffix string, or nil if there is none. |
|
1109 |
The default is nil here, redefined for VMS" |
|
1110 |
||
11781
6488fd6cc498
Make AutoDeletedFilename work like Filename
Stefan Vogel <sv@exept.de>
parents:
11763
diff
changeset
|
1111 |
self isAbstract ifTrue:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1112 |
^ ConcreteClass directorySuffix |
2963 | 1113 |
]. |
1114 |
||
1115 |
^ nil |
|
1116 |
! |
|
1117 |
||
1523 | 1118 |
errorReporter |
1119 |
"who knows the signals to report errors?" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1120 |
|
1523 | 1121 |
^ FileStream |
1122 |
||
1123 |
"Created: 2.7.1996 / 12:30:25 / stefan" |
|
1124 |
! |
|
1125 |
||
440 | 1126 |
filenameCompletionFor:aString directory:inDirectory directoriesOnly:directoriesOnly filesOnly:filesOnly ifMultiple:aBlock |
1127 |
"perform filename completion on aString in some directory; |
|
1128 |
return the longest matching filename prefix as a string. |
|
1318 | 1129 |
The boolean directoriesOnly and filesOnly control respectively, |
1130 |
if only directories or only regular files are to be considered for completion. |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1131 |
If multiple files match, the exception block aBlock is evaluated with a |
1318 | 1132 |
filename representing the directory (where the match was done) as argument. |
440 | 1133 |
(this may be different from the inDirectory argument, if aString is absolute |
1134 |
or starts with ../)" |
|
1135 |
||
11781
6488fd6cc498
Make AutoDeletedFilename work like Filename
Stefan Vogel <sv@exept.de>
parents:
11763
diff
changeset
|
1136 |
self isAbstract ifTrue:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1137 |
^ ConcreteClass |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1138 |
filenameCompletionFor:aString |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1139 |
directory:inDirectory |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1140 |
directoriesOnly:directoriesOnly |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1141 |
filesOnly:filesOnly |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1142 |
ifMultiple:aBlock |
2906 | 1143 |
]. |
6839
d5bc53f68bab
can evaluate block for matchList on filename completition
penk
parents:
6826
diff
changeset
|
1144 |
^ self filenameCompletionFor:aString directory:inDirectory directoriesOnly:directoriesOnly filesOnly:filesOnly ifMultiple:aBlock forMultipleDo:nil |
d5bc53f68bab
can evaluate block for matchList on filename completition
penk
parents:
6826
diff
changeset
|
1145 |
! |
d5bc53f68bab
can evaluate block for matchList on filename completition
penk
parents:
6826
diff
changeset
|
1146 |
|
d5bc53f68bab
can evaluate block for matchList on filename completition
penk
parents:
6826
diff
changeset
|
1147 |
filenameCompletionFor:aString directory:inDirectory directoriesOnly:directoriesOnly filesOnly:filesOnly ifMultiple:aBlock forMultipleDo:aMultipleBlock |
d5bc53f68bab
can evaluate block for matchList on filename completition
penk
parents:
6826
diff
changeset
|
1148 |
"perform filename completion on aString in some directory; |
d5bc53f68bab
can evaluate block for matchList on filename completition
penk
parents:
6826
diff
changeset
|
1149 |
return the longest matching filename prefix as a string. |
d5bc53f68bab
can evaluate block for matchList on filename completition
penk
parents:
6826
diff
changeset
|
1150 |
The boolean directoriesOnly and filesOnly control respectively, |
d5bc53f68bab
can evaluate block for matchList on filename completition
penk
parents:
6826
diff
changeset
|
1151 |
if only directories or only regular files are to be considered for completion. |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1152 |
If multiple files match, the exception block aBlock is evaluated with a |
6839
d5bc53f68bab
can evaluate block for matchList on filename completition
penk
parents:
6826
diff
changeset
|
1153 |
filename representing the directory (where the match was done) as argument and the aMultipleBlock |
d5bc53f68bab
can evaluate block for matchList on filename completition
penk
parents:
6826
diff
changeset
|
1154 |
is evaluated with both the directory (where the match was done) and the matchSet |
d5bc53f68bab
can evaluate block for matchList on filename completition
penk
parents:
6826
diff
changeset
|
1155 |
(list of matched filenames) as arguments. |
d5bc53f68bab
can evaluate block for matchList on filename completition
penk
parents:
6826
diff
changeset
|
1156 |
(this may be different from the inDirectory argument, if aString is absolute |
d5bc53f68bab
can evaluate block for matchList on filename completition
penk
parents:
6826
diff
changeset
|
1157 |
or starts with ../)" |
d5bc53f68bab
can evaluate block for matchList on filename completition
penk
parents:
6826
diff
changeset
|
1158 |
|
d5bc53f68bab
can evaluate block for matchList on filename completition
penk
parents:
6826
diff
changeset
|
1159 |
|s f matchSet nMatch name dir isAbsolute sep| |
2906 | 1160 |
|
5642
87ad71e66acb
fileNameCompletion now does exactly that;
Claus Gittinger <cg@exept.de>
parents:
5602
diff
changeset
|
1161 |
aString size == 0 ifTrue:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1162 |
aBlock value:(self named:'.'). |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1163 |
^ '' |
440 | 1164 |
]. |
1165 |
||
5642
87ad71e66acb
fileNameCompletion now does exactly that;
Claus Gittinger <cg@exept.de>
parents:
5602
diff
changeset
|
1166 |
sep := self separator. |
87ad71e66acb
fileNameCompletion now does exactly that;
Claus Gittinger <cg@exept.de>
parents:
5602
diff
changeset
|
1167 |
|
87ad71e66acb
fileNameCompletion now does exactly that;
Claus Gittinger <cg@exept.de>
parents:
5602
diff
changeset
|
1168 |
"/ the following works on Unix & MSDOS (but not on openVMS) |
87ad71e66acb
fileNameCompletion now does exactly that;
Claus Gittinger <cg@exept.de>
parents:
5602
diff
changeset
|
1169 |
|
87ad71e66acb
fileNameCompletion now does exactly that;
Claus Gittinger <cg@exept.de>
parents:
5602
diff
changeset
|
1170 |
f := self named:aString. |
3854
a13d0d489365
care for absolute fileNames in fileNameCompletion.
Claus Gittinger <cg@exept.de>
parents:
3852
diff
changeset
|
1171 |
isAbsolute := f isAbsolute. |
6556
367bc84f51fc
filename completion better if an empty basename is shown
Claus Gittinger <cg@exept.de>
parents:
6529
diff
changeset
|
1172 |
matchSet := f filenameCompletionIn:inDirectory. "/ BAD DESIGN: has side effect on f |
440 | 1173 |
dir := f directory. |
1174 |
||
4131
f370ebc75bf9
fixed filenameCompletion for caseless systems (win32)
Claus Gittinger <cg@exept.de>
parents:
3978
diff
changeset
|
1175 |
matchSet := matchSet select:[:aFilename | |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1176 |
|f isDir| |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1177 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1178 |
isAbsolute ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1179 |
f := aFilename asFilename |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1180 |
] ifFalse:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1181 |
f := (dir construct:aFilename). |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1182 |
]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1183 |
isDir := f isDirectory. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1184 |
directoriesOnly ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1185 |
isDir |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1186 |
] ifFalse:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1187 |
filesOnly ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1188 |
isDir not |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1189 |
] ifFalse:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1190 |
true |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1191 |
] |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1192 |
] |
440 | 1193 |
]. |
1194 |
||
6803 | 1195 |
f := f asCanonicalizedFilename. |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1196 |
(nMatch := matchSet size) ~~ 1 ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1197 |
" |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1198 |
more than one possible completion - |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1199 |
" |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1200 |
aMultipleBlock notNil ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1201 |
aMultipleBlock value:f value:matchSet. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1202 |
]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1203 |
aBlock value:f |
440 | 1204 |
]. |
4131
f370ebc75bf9
fixed filenameCompletion for caseless systems (win32)
Claus Gittinger <cg@exept.de>
parents:
3978
diff
changeset
|
1205 |
|
440 | 1206 |
" |
1207 |
even with more than one possible completion, |
|
1208 |
f's name is now the common prefix |
|
1209 |
" |
|
1210 |
name := f asString. |
|
4323
8b3752e1b060
add trailing filename separator if match is a directory
Claus Gittinger <cg@exept.de>
parents:
4246
diff
changeset
|
1211 |
|
8b3752e1b060
add trailing filename separator if match is a directory
Claus Gittinger <cg@exept.de>
parents:
4246
diff
changeset
|
1212 |
nMatch <= 1 ifTrue:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1213 |
" |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1214 |
exactly one possible completion - |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1215 |
" |
3752 | 1216 |
"/ f := dir construct:matchSet first. |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1217 |
false "directoriesOnly" ifFalse:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1218 |
(f exists and:[f isDirectory]) ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1219 |
(name endsWith:sep) ifFalse:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1220 |
name := name , sep asString |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1221 |
]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1222 |
]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1223 |
] |
440 | 1224 |
]. |
1225 |
||
5642
87ad71e66acb
fileNameCompletion now does exactly that;
Claus Gittinger <cg@exept.de>
parents:
5602
diff
changeset
|
1226 |
s := name. |
440 | 1227 |
|
1228 |
"/ special: if there was no change, and the string represented |
|
1229 |
"/ is a directories name, add a directory separator |
|
3503
0734014ecea8
apped '/' if there is exactly one match and its a directory
Claus Gittinger <cg@exept.de>
parents:
3373
diff
changeset
|
1230 |
((nMatch == 1) or:[s = aString]) ifTrue:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1231 |
(s endsWith:sep) ifFalse:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1232 |
(self named:s) isDirectory ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1233 |
^ s , sep asString |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1234 |
] |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1235 |
]. |
440 | 1236 |
]. |
1237 |
||
1238 |
^ s |
|
1318 | 1239 |
|
4131
f370ebc75bf9
fixed filenameCompletion for caseless systems (win32)
Claus Gittinger <cg@exept.de>
parents:
3978
diff
changeset
|
1240 |
"Modified: / 30.4.1999 / 09:40:13 / cg" |
615 | 1241 |
! |
1242 |
||
2168
649e90de1312
added filesMatching: in class protocol;
Claus Gittinger <cg@exept.de>
parents:
2013
diff
changeset
|
1243 |
filesMatching:aPattern |
649e90de1312
added filesMatching: in class protocol;
Claus Gittinger <cg@exept.de>
parents:
2013
diff
changeset
|
1244 |
"return a collection of strings, representing the names |
649e90de1312
added filesMatching: in class protocol;
Claus Gittinger <cg@exept.de>
parents:
2013
diff
changeset
|
1245 |
of files matching aPattern. |
2547
4467d25fe057
filesMatching class method returns names as given
Claus Gittinger <cg@exept.de>
parents:
2503
diff
changeset
|
1246 |
If aPattern contains a directory path, files are tried there; |
2168
649e90de1312
added filesMatching: in class protocol;
Claus Gittinger <cg@exept.de>
parents:
2013
diff
changeset
|
1247 |
otherwise, files from the currentDirectory are tried. |
2547
4467d25fe057
filesMatching class method returns names as given
Claus Gittinger <cg@exept.de>
parents:
2503
diff
changeset
|
1248 |
The returned strings are the expanded names, in the same form |
2550 | 1249 |
as given in pattern. |
1250 |
The pattern should be a simple pattern." |
|
2547
4467d25fe057
filesMatching class method returns names as given
Claus Gittinger <cg@exept.de>
parents:
2503
diff
changeset
|
1251 |
|
4467d25fe057
filesMatching class method returns names as given
Claus Gittinger <cg@exept.de>
parents:
2503
diff
changeset
|
1252 |
|basePattern dir d files| |
2168
649e90de1312
added filesMatching: in class protocol;
Claus Gittinger <cg@exept.de>
parents:
2013
diff
changeset
|
1253 |
|
11781
6488fd6cc498
Make AutoDeletedFilename work like Filename
Stefan Vogel <sv@exept.de>
parents:
11763
diff
changeset
|
1254 |
self isAbstract ifTrue:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1255 |
^ ConcreteClass filesMatching:aPattern |
2906 | 1256 |
]. |
1257 |
||
1258 |
"/ the following works on Unix & MSDOS (but not on openVMS) |
|
1259 |
||
2168
649e90de1312
added filesMatching: in class protocol;
Claus Gittinger <cg@exept.de>
parents:
2013
diff
changeset
|
1260 |
dir := aPattern asFilename directoryName. |
2547
4467d25fe057
filesMatching class method returns names as given
Claus Gittinger <cg@exept.de>
parents:
2503
diff
changeset
|
1261 |
basePattern := aPattern asFilename baseName. |
4467d25fe057
filesMatching class method returns names as given
Claus Gittinger <cg@exept.de>
parents:
2503
diff
changeset
|
1262 |
d := dir asFilename. |
2548
b6182b559ea2
made filesMatching ST-80 compatible.
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
1263 |
files := dir asFilename filesMatchingWithoutDotDirs:basePattern. |
2547
4467d25fe057
filesMatching class method returns names as given
Claus Gittinger <cg@exept.de>
parents:
2503
diff
changeset
|
1264 |
dir = '.' ifTrue:[^ files]. |
4467d25fe057
filesMatching class method returns names as given
Claus Gittinger <cg@exept.de>
parents:
2503
diff
changeset
|
1265 |
^ files collect:[:base | d constructString:base]. |
2168
649e90de1312
added filesMatching: in class protocol;
Claus Gittinger <cg@exept.de>
parents:
2013
diff
changeset
|
1266 |
|
649e90de1312
added filesMatching: in class protocol;
Claus Gittinger <cg@exept.de>
parents:
2013
diff
changeset
|
1267 |
" |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1268 |
Filename filesMatching:'*' |
2168
649e90de1312
added filesMatching: in class protocol;
Claus Gittinger <cg@exept.de>
parents:
2013
diff
changeset
|
1269 |
Filename filesMatching:'/*' |
2547
4467d25fe057
filesMatching class method returns names as given
Claus Gittinger <cg@exept.de>
parents:
2503
diff
changeset
|
1270 |
Filename filesMatching:'/usr/local/*' |
2168
649e90de1312
added filesMatching: in class protocol;
Claus Gittinger <cg@exept.de>
parents:
2013
diff
changeset
|
1271 |
" |
649e90de1312
added filesMatching: in class protocol;
Claus Gittinger <cg@exept.de>
parents:
2013
diff
changeset
|
1272 |
|
2906 | 1273 |
"Modified: 8.9.1997 / 00:32:31 / cg" |
615 | 1274 |
! |
1275 |
||
11781
6488fd6cc498
Make AutoDeletedFilename work like Filename
Stefan Vogel <sv@exept.de>
parents:
11763
diff
changeset
|
1276 |
isAbstract |
6488fd6cc498
Make AutoDeletedFilename work like Filename
Stefan Vogel <sv@exept.de>
parents:
11763
diff
changeset
|
1277 |
"return true, if this is not a concrete class" |
6488fd6cc498
Make AutoDeletedFilename work like Filename
Stefan Vogel <sv@exept.de>
parents:
11763
diff
changeset
|
1278 |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1279 |
^ self == Filename |
11781
6488fd6cc498
Make AutoDeletedFilename work like Filename
Stefan Vogel <sv@exept.de>
parents:
11763
diff
changeset
|
1280 |
! |
6488fd6cc498
Make AutoDeletedFilename work like Filename
Stefan Vogel <sv@exept.de>
parents:
11763
diff
changeset
|
1281 |
|
2903 | 1282 |
isBadCharacter:aCharacter |
1283 |
"return true, if aCharacter is unallowed in a filename." |
|
1284 |
||
11781
6488fd6cc498
Make AutoDeletedFilename work like Filename
Stefan Vogel <sv@exept.de>
parents:
11763
diff
changeset
|
1285 |
self isAbstract ifTrue:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1286 |
^ ConcreteClass isBadCharacter:aCharacter |
2906 | 1287 |
]. |
1288 |
||
8095
bfbd1309a4a6
Use #codePoint instead of deprecated #asciiValue
Stefan Vogel <sv@exept.de>
parents:
8036
diff
changeset
|
1289 |
^ aCharacter isControlCharacter |
2903 | 1290 |
! |
1291 |
||
1292 |
isCaseSensitive |
|
1293 |
"return true, if filenames are case sensitive. |
|
19821 | 1294 |
We ask the OS about this, to be independent here. |
1295 |
This is not really correct, as the sensitivity may depend on |
|
1296 |
the paricular mounted file system (NFS, for example). |
|
1297 |
So we need a query on the instance side" |
|
2903 | 1298 |
|
11781
6488fd6cc498
Make AutoDeletedFilename work like Filename
Stefan Vogel <sv@exept.de>
parents:
11763
diff
changeset
|
1299 |
self isAbstract ifTrue:[ |
19821 | 1300 |
^ ConcreteClass isCaseSensitive |
2906 | 1301 |
]. |
1302 |
||
2903 | 1303 |
^ OperatingSystem caseSensitiveFilenames |
2906 | 1304 |
|
1305 |
"Modified: 8.9.1997 / 00:33:32 / cg" |
|
2903 | 1306 |
! |
1307 |
||
615 | 1308 |
localNameStringFrom:aString |
1309 |
"ST-80 compatibility. |
|
1310 |
what does this do ? (used in FileNavigator-goody). |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1311 |
GUESS: |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1312 |
does it strip off any volume characters and make a path relative ?" |
2922 | 1313 |
|
11781
6488fd6cc498
Make AutoDeletedFilename work like Filename
Stefan Vogel <sv@exept.de>
parents:
11763
diff
changeset
|
1314 |
self isAbstract ifTrue:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1315 |
^ ConcreteClass localNameStringFrom:aString |
2906 | 1316 |
]. |
1317 |
||
15227 | 1318 |
^ aString withoutPrefix:self separatorString |
615 | 1319 |
|
1320 |
"Modified: 7.9.1995 / 10:44:56 / claus" |
|
2906 | 1321 |
"Modified: 8.9.1997 / 00:33:51 / cg" |
615 | 1322 |
! |
1323 |
||
2908 | 1324 |
maxComponentLength |
1325 |
"return the maximum number of characters a filename component may |
|
1326 |
be in size. This depends on the OperatingSystem." |
|
1327 |
||
11781
6488fd6cc498
Make AutoDeletedFilename work like Filename
Stefan Vogel <sv@exept.de>
parents:
11763
diff
changeset
|
1328 |
self isAbstract ifTrue:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1329 |
^ ConcreteClass maxComponentLength |
2908 | 1330 |
]. |
1331 |
^ OperatingSystem maxFileNameLength |
|
1332 |
! |
|
1333 |
||
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1334 |
maxLength |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1335 |
"return the maximum number of characters a filename may be in size. |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1336 |
This depends on the OperatingSystem." |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1337 |
|
11781
6488fd6cc498
Make AutoDeletedFilename work like Filename
Stefan Vogel <sv@exept.de>
parents:
11763
diff
changeset
|
1338 |
self isAbstract ifTrue:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1339 |
^ ConcreteClass maxLength |
2908 | 1340 |
]. |
1341 |
^ OperatingSystem maxPathLength |
|
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1342 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1343 |
"Created: 29.2.1996 / 20:57:11 / cg" |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1344 |
"Modified: 29.2.1996 / 20:57:46 / cg" |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1345 |
! |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1346 |
|
3171 | 1347 |
nullFilename |
1348 |
"Return the OS dependent filename for /dev/null, or nil if there is none. |
|
1349 |
The default is nil here" |
|
1350 |
||
11781
6488fd6cc498
Make AutoDeletedFilename work like Filename
Stefan Vogel <sv@exept.de>
parents:
11763
diff
changeset
|
1351 |
self isAbstract ifTrue:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1352 |
^ ConcreteClass nullFilename |
3171 | 1353 |
]. |
1354 |
||
8754 | 1355 |
^ OperatingSystem getNullDevice |
3171 | 1356 |
|
1357 |
"Created: / 12.1.1998 / 12:15:30 / stefan" |
|
1358 |
! |
|
1359 |
||
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1360 |
parentDirectoryName |
615 | 1361 |
"return the name used for the parent directory. |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1362 |
This is '..' for unix and dos-like systems. |
615 | 1363 |
(there may be more in the future." |
1364 |
||
11781
6488fd6cc498
Make AutoDeletedFilename work like Filename
Stefan Vogel <sv@exept.de>
parents:
11763
diff
changeset
|
1365 |
self isAbstract ifTrue:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1366 |
^ ConcreteClass parentDirectoryName |
2906 | 1367 |
]. |
1368 |
||
1369 |
^ OperatingSystem parentDirectoryName |
|
1370 |
||
1371 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1372 |
Filename parentDirectoryName |
2906 | 1373 |
" |
1374 |
||
1375 |
"Modified: 8.9.1997 / 00:34:39 / cg" |
|
615 | 1376 |
! |
1377 |
||
1378 |
separator |
|
1379 |
"return the file/directory separator. |
|
15246 | 1380 |
This is to be redefined in concrete classes." |
1381 |
||
1382 |
^ ConcreteClass separator |
|
8243 | 1383 |
|
1384 |
" |
|
8754 | 1385 |
Filename separator |
1386 |
PCFilename separator |
|
8243 | 1387 |
" |
2906 | 1388 |
|
1389 |
"Modified: 8.9.1997 / 00:20:28 / cg" |
|
615 | 1390 |
! |
1391 |
||
8243 | 1392 |
separatorString |
1393 |
"return the file/directory separator as a string." |
|
1394 |
||
1395 |
^ self separator asString |
|
1396 |
||
1397 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1398 |
Filename separatorString |
8243 | 1399 |
" |
1400 |
! |
|
1401 |
||
615 | 1402 |
suffixSeparator |
1403 |
"return the filename suffix separator. |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1404 |
Usually, this is $. for unix-like and msdos systems |
1318 | 1405 |
(there is currently no known system, where this differs)" |
615 | 1406 |
|
1407 |
^ $. |
|
1408 |
||
1409 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1410 |
Filename suffixSeparator |
615 | 1411 |
" |
1412 |
||
1413 |
"Modified: 7.9.1995 / 11:10:43 / claus" |
|
1318 | 1414 |
"Modified: 30.4.1996 / 12:14:25 / cg" |
615 | 1415 |
! |
1416 |
||
2906 | 1417 |
tempFileNameTemplate |
1418 |
"return a template for temporary files. |
|
1419 |
This is expanded with the current processID and a sequenceNumber |
|
1420 |
to generate a unique filename." |
|
1421 |
||
11781
6488fd6cc498
Make AutoDeletedFilename work like Filename
Stefan Vogel <sv@exept.de>
parents:
11763
diff
changeset
|
1422 |
self isAbstract ifTrue:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1423 |
^ ConcreteClass tempFileNameTemplate |
2906 | 1424 |
]. |
1425 |
||
1426 |
^ 'stxtmp_%1_%2' |
|
1427 |
||
1428 |
"Created: 8.9.1997 / 00:01:46 / cg" |
|
1429 |
"Modified: 8.9.1997 / 00:35:02 / cg" |
|
1430 |
! |
|
1431 |
||
615 | 1432 |
volumes |
1433 |
"ST-80 compatibility. |
|
2896 | 1434 |
GUESS: does it return the available drives on MSDOS systems ? |
1435 |
Q: what does this do on Unix systems ? (used in FileNavigator-goody)." |
|
1436 |
||
11781
6488fd6cc498
Make AutoDeletedFilename work like Filename
Stefan Vogel <sv@exept.de>
parents:
11763
diff
changeset
|
1437 |
self isAbstract ifTrue:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1438 |
^ ConcreteClass volumes |
2906 | 1439 |
]. |
1440 |
||
2896 | 1441 |
^ OperatingSystem getDriveList |
615 | 1442 |
|
8679 | 1443 |
" |
1444 |
Filename volumes |
|
1445 |
" |
|
615 | 1446 |
! ! |
1447 |
||
6383 | 1448 |
!Filename class methodsFor:'utilities'! |
1449 |
||
16389 | 1450 |
canonicalize:aPathString |
1451 |
"convert the argument, aPathString to a good format. |
|
1452 |
This should eliminate useless directory components (i.e. '././') |
|
1453 |
and useless tree walks (i.e. '../foo/..')." |
|
1454 |
||
1455 |
^ self nameFromComponents:(self canonicalizedNameComponents:aPathString) |
|
1456 |
||
1457 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1458 |
Filename canonicalize:'/etc/../etc' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1459 |
Filename canonicalize:'/home/cg/../' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1460 |
Filename canonicalize:'/home/cg/../././' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1461 |
Filename canonicalize:'./home/cg/../././' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1462 |
Filename canonicalize:'/home/././cg/../././' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1463 |
Filename canonicalize:'/home/././cg/././' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1464 |
Filename canonicalize:'/home/cg/../../..' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1465 |
Filename canonicalize:'cg/../../..' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1466 |
Filename canonicalize:'./' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1467 |
Filename canonicalize:'/home/.' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1468 |
Filename canonicalize:'/home/../..' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1469 |
Filename canonicalize:'//foo' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1470 |
Filename canonicalize:'///foo' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1471 |
Filename canonicalize:'//foo//bar' |
16389 | 1472 |
" |
1473 |
! |
|
1474 |
||
1475 |
canonicalizedNameComponents:aPathString |
|
1476 |
"convert the argument, aPathString to a good format. |
|
1477 |
This should eliminate useless directory components (i.e. '././') |
|
1478 |
and useless tree walks (i.e. '../foo/..'). |
|
1479 |
||
1480 |
Answer a sequenceable collection of name components." |
|
1481 |
||
1482 |
|comps newComps rootName dotDot dot| |
|
1483 |
||
1484 |
dotDot := self parentDirectoryName. |
|
1485 |
dot := self currentDirectoryName. |
|
1486 |
rootName := self separatorString. |
|
1487 |
||
1488 |
comps := self components:aPathString. |
|
1489 |
newComps := OrderedCollection new:comps size. |
|
1490 |
comps do:[:eachComponent | |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1491 |
eachComponent ~= dot ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1492 |
eachComponent = dotDot ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1493 |
(newComps isEmpty |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1494 |
or:[(newComps size == 1 and:[newComps first startsWith:rootName]) |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1495 |
or:[newComps last = dotDot]]) ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1496 |
newComps add:eachComponent |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1497 |
] ifFalse:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1498 |
newComps removeLast |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1499 |
]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1500 |
] ifFalse:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1501 |
newComps add:eachComponent |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1502 |
]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1503 |
] |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1504 |
]. |
16389 | 1505 |
"/ add current Directory if empty |
1506 |
newComps isEmpty ifTrue:[ |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1507 |
newComps add:dot. |
16389 | 1508 |
]. |
1509 |
^ newComps |
|
1510 |
||
1511 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1512 |
Filename canonicalizedNameComponents:'/etc/../etc' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1513 |
Filename canonicalizedNameComponents:'/home/cg/../' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1514 |
Filename canonicalizedNameComponents:'/home/cg/../././' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1515 |
Filename canonicalizedNameComponents:'./home/cg/../././' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1516 |
Filename canonicalizedNameComponents:'/home/././cg/../././' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1517 |
Filename canonicalizedNameComponents:'/home/././cg/././' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1518 |
Filename canonicalizedNameComponents:'/home/cg/../../..' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1519 |
Filename canonicalizedNameComponents:'cg/../../..' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1520 |
Filename canonicalizedNameComponents:'/' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1521 |
Filename canonicalizedNameComponents:'./' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1522 |
Filename canonicalizedNameComponents:'/.' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1523 |
Filename canonicalizedNameComponents:'/home/.' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1524 |
Filename canonicalizedNameComponents:'/home' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1525 |
Filename canonicalizedNameComponents:'/home/../..' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1526 |
Filename canonicalizedNameComponents:'//foo' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1527 |
Filename canonicalizedNameComponents:'///foo' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1528 |
Filename canonicalizedNameComponents:'//foo//bar' |
16389 | 1529 |
" |
1530 |
! |
|
1531 |
||
1532 |
components:aString |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1533 |
"separate the pathName given by aString into |
16578 | 1534 |
a collection containing the directory components and the file's name as |
16389 | 1535 |
the final component. |
1536 |
If the argument names an absolute path, the first component will be the |
|
1537 |
name of the root directory (i.e. '/')." |
|
1538 |
||
1539 |
|sep f vol rest components| |
|
1540 |
||
1541 |
self isAbstract ifTrue:[ |
|
19821 | 1542 |
^ ConcreteClass components:aString |
16389 | 1543 |
]. |
1544 |
||
1545 |
"/ the following works on Unix & MSDOS (but not on openVMS) |
|
1546 |
"/ However, MSDOS drive-letters and network drives are |
|
1547 |
"/ not correctly handled here. |
|
1548 |
||
1549 |
sep := self separator. |
|
1550 |
f := aString asFilename. |
|
1551 |
vol := f volume. |
|
1552 |
vol size ~~ 0 ifTrue:[ |
|
19821 | 1553 |
rest := f localPathName. |
16389 | 1554 |
] ifFalse:[ |
19821 | 1555 |
rest := aString |
16389 | 1556 |
]. |
1557 |
||
1558 |
components := rest asCollectionOfSubstringsSeparatedBy:sep. |
|
1559 |
(rest startsWith:sep) ifTrue:[ |
|
19821 | 1560 |
"first was a separator - root directory - restore" |
1561 |
(rest size > 1 and:[rest second = sep and:[vol isEmptyOrNil]]) ifTrue:[ |
|
1562 |
"keep \\ for windows network paths" |
|
1563 |
components at:1 put:(String with:sep with:sep). |
|
1564 |
] ifFalse:[ |
|
1565 |
components at:1 put:sep asString. |
|
1566 |
]. |
|
16389 | 1567 |
]. |
1568 |
components := components select:[:each| each notEmpty]. |
|
1569 |
||
1570 |
"/ prepend volume to first component (the root directory) |
|
1571 |
vol size ~~ 0 ifTrue:[ |
|
19821 | 1572 |
components at:1 put:(vol , (components at:1)). |
16389 | 1573 |
]. |
1574 |
^ components |
|
1575 |
||
1576 |
" |
|
19821 | 1577 |
Unix: |
1578 |
UnixFilename components:'/foo/bar/baz' |
|
1579 |
UnixFilename components:'/' |
|
1580 |
UnixFilename components:'//' |
|
1581 |
UnixFilename components:'foo/bar/baz' |
|
1582 |
UnixFilename components:'foo/bar' |
|
1583 |
UnixFilename components:'foo' |
|
1584 |
UnixFilename components:'/foo' |
|
1585 |
UnixFilename components:'//foo' |
|
1586 |
UnixFilename components:'' |
|
1587 |
||
1588 |
Windows: |
|
1589 |
PCFilename components:'\' |
|
1590 |
PCFilename components:'\foo' |
|
1591 |
PCFilename components:'\foo\' |
|
1592 |
PCFilename components:'\foo\bar' |
|
1593 |
PCFilename components:'\foo\bar\' |
|
1594 |
PCFilename components:'c:' |
|
1595 |
PCFilename components:'c:\' |
|
1596 |
PCFilename components:'c:\foo' |
|
1597 |
PCFilename components:'c:\foo\' |
|
1598 |
PCFilename components:'c:\foo\bar' |
|
1599 |
PCFilename components:'c:\foo\bar\' |
|
1600 |
PCFilename components:'\\idefix' |
|
1601 |
PCFilename components:'\\idefix\home' |
|
1602 |
PCFilename components:'\\idefix\home\bar' |
|
16389 | 1603 |
" |
1604 |
||
1605 |
"Modified: / 24.9.1998 / 19:10:52 / cg" |
|
1606 |
! |
|
1607 |
||
19821 | 1608 |
filesMatchingGLOB:pattern |
1609 |
"does a GLOB filename expansion. |
|
1610 |
Generates and returns a possibly empty list of files which match |
|
1611 |
the given glob pattern" |
|
1612 |
||
1613 |
^ OrderedCollection withCollectedContents:[:coll | |
|
1614 |
pattern asFilename filesMatchingGLOBDo:[:each | coll add:each] |
|
1615 |
] |
|
1616 |
||
1617 |
" |
|
1618 |
Filename filesMatchingGLOB:'./A*' |
|
1619 |
Filename filesMatchingGLOB:'/etc/A*' |
|
1620 |
Filename filesMatchingGLOB:'/*/A*' |
|
1621 |
'.' asFilename filesMatchingGLOB:'A*' |
|
1622 |
" |
|
1623 |
! |
|
1624 |
||
6802 | 1625 |
nameFromComponents:aCollectionOfDirectoryNames |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1626 |
"return a filenameString from components given in aCollectionOfDirectoryNames. |
6802 | 1627 |
If the first component is the name of the root directory (i.e. '/'), |
1628 |
an absolute path-string is returned." |
|
1629 |
||
1630 |
|sep s| |
|
1631 |
||
11781
6488fd6cc498
Make AutoDeletedFilename work like Filename
Stefan Vogel <sv@exept.de>
parents:
11763
diff
changeset
|
1632 |
self isAbstract ifTrue:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1633 |
^ ConcreteClass nameFromComponents:aCollectionOfDirectoryNames |
6802 | 1634 |
]. |
1635 |
||
1636 |
"/ fallBack - works on Unix & MSDOS |
|
1637 |
||
8243 | 1638 |
sep := self separatorString. |
6802 | 1639 |
s := ''. |
1640 |
aCollectionOfDirectoryNames keysAndValuesDo:[:index :component | |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1641 |
index == 1 ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1642 |
s := component. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1643 |
] ifFalse:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1644 |
(index == 2 and:[ (s endsWith:sep) ]) ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1645 |
s := s , component |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1646 |
] ifFalse:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1647 |
s := s , sep , component |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1648 |
] |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1649 |
]. |
6802 | 1650 |
]. |
1651 |
^ s |
|
1652 |
||
1653 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1654 |
Filename nameFromComponents:#('/' 'foo' 'bar' 'baz') |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1655 |
Filename nameFromComponents:#('foo' 'bar' 'baz') |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1656 |
Filename nameFromComponents:#('/') |
7074 | 1657 |
|
1658 |
|comps| |
|
1659 |
comps := Filename components:'/foo/bar/baz'. |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1660 |
Filename nameFromComponents:comps |
7074 | 1661 |
|
1662 |
|comps| |
|
1663 |
comps := Filename components:'\foo\bar\baz'. |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1664 |
Filename nameFromComponents:comps |
7074 | 1665 |
|
1666 |
|comps| |
|
1667 |
comps := Filename components:'c:\foo\bar\baz'. |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1668 |
Filename nameFromComponents:comps |
7074 | 1669 |
|
1670 |
|comps| |
|
1671 |
comps := Filename components:'foo\bar\baz'. |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1672 |
Filename nameFromComponents:comps |
7074 | 1673 |
|
1674 |
|comps| |
|
1675 |
comps := Filename components:'foo'. |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1676 |
Filename nameFromComponents:comps |
7074 | 1677 |
|
1678 |
|comps| |
|
1679 |
comps := Filename components:'\'. |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1680 |
Filename nameFromComponents:comps |
7074 | 1681 |
|
1682 |
|comps| |
|
1683 |
comps := Filename components:'c:\'. |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1684 |
Filename nameFromComponents:comps |
6802 | 1685 |
" |
1686 |
||
1687 |
"Modified: 8.9.1997 / 00:23:16 / cg" |
|
1688 |
! |
|
1689 |
||
6383 | 1690 |
readingFile:aPathName do:aBlock |
1691 |
"create a read-stream on a file, evaluate aBlock, passing that stream, |
|
1692 |
and return the blocks value. |
|
1693 |
Ensures that the stream is closed." |
|
1694 |
||
6529 | 1695 |
^ aPathName asFilename readingFileDo:aBlock. |
1696 |
||
1697 |
" |
|
1698 |
read the first line from some file: |
|
1699 |
||
1700 |
|rslt| |
|
1701 |
||
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1702 |
rslt := |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1703 |
Filename |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1704 |
readingFile:'/etc/passwd' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1705 |
do:[:s | |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1706 |
s nextLine |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1707 |
]. |
6529 | 1708 |
Transcript showCR:rslt. |
1709 |
" |
|
1710 |
||
1711 |
" |
|
1712 |
find all used shells in /etc/passwd and count their usage: |
|
1713 |
||
6383 | 1714 |
|rslt| |
1715 |
||
6529 | 1716 |
rslt := |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1717 |
Filename |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1718 |
readingFile:'/etc/passwd' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1719 |
do: |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1720 |
[:s | |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1721 |
|shells| |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1722 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1723 |
shells := Bag new. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1724 |
s linesDo: |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1725 |
[:line | |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1726 |
|parts| |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1727 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1728 |
parts := line asCollectionOfSubstringsSeparatedBy:$:. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1729 |
shells add:(parts seventh). |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1730 |
]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1731 |
shells contents |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1732 |
]. |
6529 | 1733 |
Transcript showCR:rslt. |
1734 |
" |
|
6383 | 1735 |
! ! |
1736 |
||
7261 | 1737 |
!Filename methodsFor:'Compatibility-VW5.4'! |
6139 | 1738 |
|
1739 |
asLogicalFileSpecification |
|
1740 |
^ self |
|
1741 |
||
1742 |
"Created: / 30.10.2001 / 17:31:10 / cg" |
|
6447 | 1743 |
! |
1744 |
||
10583 | 1745 |
canBeWritten |
1746 |
"same as isWritable - for ST-80 compatibility" |
|
1747 |
||
1748 |
^ self isWritable |
|
1749 |
||
1750 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1751 |
'/foo/bar' asFilename canBeWritten |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1752 |
'/tmp' asFilename canBeWritten |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1753 |
'Makefile' asFilename canBeWritten |
10583 | 1754 |
" |
1755 |
! |
|
1756 |
||
7596 | 1757 |
definitelyExists |
1758 |
"for now - a kludge" |
|
1759 |
||
1760 |
^ self exists |
|
1761 |
! |
|
1762 |
||
6447 | 1763 |
extension |
6454 | 1764 |
"return the receiver's extension; |
1765 |
that is the characters from and including |
|
1766 |
the last period or nil, if there is none." |
|
1767 |
||
1768 |
|string idx| |
|
1769 |
||
1770 |
string := self asString. |
|
1771 |
idx := string lastIndexOf:$.. |
|
1772 |
idx > 1 ifTrue:[ |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1773 |
^ string copyFrom:idx |
6454 | 1774 |
]. |
1775 |
^ nil |
|
1776 |
||
1777 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1778 |
'foo.html' asFilename extension |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1779 |
'foo.bar' asFilename extension |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1780 |
'foo.bar.baz' asFilename extension |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1781 |
'foo.' asFilename extension |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1782 |
'foo' asFilename extension |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1783 |
'.login' asFilename extension |
6454 | 1784 |
" |
6139 | 1785 |
! ! |
1786 |
||
615 | 1787 |
!Filename methodsFor:'comparing'! |
1788 |
||
16255 | 1789 |
< aFilename |
1790 |
"compare file names - used for sorting" |
|
1791 |
||
1792 |
^ self asString < aFilename asString |
|
1793 |
! |
|
1794 |
||
615 | 1795 |
= aFilename |
1796 |
"return true, if the argument represents the same filename" |
|
1797 |
||
1798 |
|str| |
|
1799 |
||
1800 |
self species == aFilename species ifTrue:[ |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1801 |
str := aFilename asString. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1802 |
self species isCaseSensitive ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1803 |
^ nameString = str |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1804 |
]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1805 |
^ nameString sameAs:str |
615 | 1806 |
]. |
1807 |
^ false |
|
1808 |
! |
|
1809 |
||
5877 | 1810 |
contentsIsPrefixOf:aFilename |
5876
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1811 |
"return true if the contents of the file represented by the receiver |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1812 |
is the same as or a prefix of the contents of the file represented by the argument, aFilename. |
16578 | 1813 |
This compares the files' actual contents; not the filenames." |
3868 | 1814 |
|
8771 | 1815 |
|f2 s1 s2 bufferSize buffer1 buffer2 n| |
1816 |
||
1817 |
bufferSize := 8192 * 4. |
|
4979 | 1818 |
|
1819 |
f2 := aFilename asFilename. |
|
5876
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1820 |
self fileSize > f2 fileSize ifTrue:[^ false]. |
3868 | 1821 |
|
7088
cc3233554827
Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents:
7075
diff
changeset
|
1822 |
[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1823 |
s1 := self readStream. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1824 |
s2 := f2 readStream. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1825 |
s1 binary. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1826 |
s2 binary. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1827 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1828 |
buffer1 := ByteArray new:bufferSize. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1829 |
buffer2 := ByteArray new:bufferSize. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1830 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1831 |
[s1 atEnd] whileFalse:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1832 |
n := s1 nextBytes:bufferSize into:buffer1 startingAt:1. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1833 |
n == 0 ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1834 |
"/ receiver shorter. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1835 |
^ true |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1836 |
]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1837 |
(s2 nextBytes:n into:buffer2 startingAt:1) ~~ n ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1838 |
"/ aFilename shorter |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1839 |
^ false |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1840 |
]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1841 |
buffer1 ~= buffer2 ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1842 |
^ false |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1843 |
] |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1844 |
]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1845 |
"/ receiver shorter or same size. |
7088
cc3233554827
Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents:
7075
diff
changeset
|
1846 |
] ensure:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1847 |
s1 notNil ifTrue:[s1 close]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1848 |
s2 notNil ifTrue:[s2 close]. |
3868 | 1849 |
]. |
5876
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1850 |
^ true |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1851 |
|
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1852 |
" |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1853 |
|s| |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1854 |
|
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1855 |
s := 'testFile1' asFilename writeStream. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1856 |
s nextPutAll:'11111'. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1857 |
s nextPutAll:'22222'. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1858 |
s nextPutAll:'33333'. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1859 |
s close. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1860 |
|
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1861 |
s := 'testFile2' asFilename writeStream. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1862 |
s nextPutAll:'11111'. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1863 |
s nextPutAll:'22222'. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1864 |
s nextPutAll:'33333'. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1865 |
s close. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1866 |
|
5877 | 1867 |
('testFile1' asFilename contentsIsPrefixOf:'testFile2' ) ifFalse:[self halt]. |
5876
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1868 |
|
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1869 |
s := 'testFile2' asFilename writeStream. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1870 |
s nextPutAll:'11111'. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1871 |
s nextPutAll:'22222'. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1872 |
s nextPutAll:'33333'. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1873 |
s nextPutAll:'44444'. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1874 |
s close. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1875 |
|
5877 | 1876 |
('testFile1' asFilename contentsIsPrefixOf:'testFile2' ) ifFalse:[self halt]. |
5876
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1877 |
|
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1878 |
s := 'testFile2' asFilename writeStream. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1879 |
s nextPutAll:'11111'. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1880 |
s nextPutAll:'22222'. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1881 |
s close. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1882 |
|
5877 | 1883 |
('testFile1' asFilename contentsIsPrefixOf:'testFile2' ) ifTrue:[self halt]. |
5876
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1884 |
|
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1885 |
s := 'testFile2' asFilename writeStream. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1886 |
s nextPutAll:'11111'. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1887 |
s nextPutAll:'22222'. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1888 |
s nextPutAll:'33334'. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1889 |
s close. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1890 |
|
5877 | 1891 |
('testFile1' asFilename contentsIsPrefixOf:'testFile2' ) ifTrue:[self halt]. |
1892 |
||
1893 |
" |
|
1894 |
! |
|
1895 |
||
1896 |
contentsStartsWithContentsOf:aFilename |
|
1897 |
"return true if the contents of the file represented by aFilename |
|
1898 |
is the same as or a prefix of the contents of the file represented by the receiver. |
|
16578 | 1899 |
This compares the files' actual contents; not the filenames." |
5877 | 1900 |
|
1901 |
^ aFilename asFilename contentsIsPrefixOf:self |
|
1902 |
||
1903 |
" |
|
1904 |
|s| |
|
1905 |
||
1906 |
s := 'testFile1' asFilename writeStream. |
|
1907 |
s nextPutAll:'11111'. |
|
1908 |
s nextPutAll:'22222'. |
|
1909 |
s nextPutAll:'33333'. |
|
1910 |
s close. |
|
1911 |
||
1912 |
s := 'testFile2' asFilename writeStream. |
|
1913 |
s nextPutAll:'11111'. |
|
1914 |
s nextPutAll:'22222'. |
|
1915 |
s nextPutAll:'33333'. |
|
1916 |
s close. |
|
1917 |
||
1918 |
('testFile2' asFilename contentsStartsWithContentsOf:'testFile1' ) ifFalse:[self halt]. |
|
1919 |
||
1920 |
s := 'testFile2' asFilename writeStream. |
|
1921 |
s nextPutAll:'11111'. |
|
1922 |
s nextPutAll:'22222'. |
|
1923 |
s nextPutAll:'33333'. |
|
1924 |
s nextPutAll:'44444'. |
|
1925 |
s close. |
|
1926 |
||
1927 |
('testFile2' asFilename contentsStartsWithContentsOf:'testFile1' ) ifFalse:[self halt]. |
|
1928 |
||
1929 |
s := 'testFile2' asFilename writeStream. |
|
1930 |
s nextPutAll:'11111'. |
|
1931 |
s nextPutAll:'22222'. |
|
1932 |
s close. |
|
1933 |
||
1934 |
('testFile2' asFilename contentsStartsWithContentsOf:'testFile1' ) ifTrue:[self halt]. |
|
1935 |
||
1936 |
s := 'testFile2' asFilename writeStream. |
|
1937 |
s nextPutAll:'11111'. |
|
1938 |
s nextPutAll:'22222'. |
|
1939 |
s nextPutAll:'33334'. |
|
1940 |
s close. |
|
1941 |
||
1942 |
('testFile2' asFilename contentsStartsWithContentsOf:'testFile1' ) ifTrue:[self halt]. |
|
5876
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1943 |
|
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1944 |
" |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1945 |
! |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1946 |
|
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1947 |
hash |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1948 |
"return an integer useful as a hash-key" |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1949 |
|
15811 | 1950 |
self species isCaseSensitive ifFalse:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1951 |
"/ asLowercase is slightly better: |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1952 |
"/ it never converts single-byte strings to double one's, |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1953 |
"/ whereas asUppercase might (for umlaut-y) |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1954 |
^ nameString asUppercase hash |
11424
c169cc34afe9
fixed hash for case-insensitive files
Claus Gittinger <cg@exept.de>
parents:
11406
diff
changeset
|
1955 |
]. |
5876
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1956 |
^ nameString hash |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1957 |
! |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1958 |
|
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1959 |
sameContentsAs:aFilename |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1960 |
"return true if the file represented by the receiver has the |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1961 |
same contents as the file represented by the argument, aFilename. |
16578 | 1962 |
This compares the file's actual contents; not the filenames." |
5876
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1963 |
|
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1964 |
|f2| |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1965 |
|
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1966 |
f2 := aFilename asFilename. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1967 |
f2 fileSize = self fileSize ifFalse:[^ false]. |
5877 | 1968 |
^ self contentsIsPrefixOf:f2. |
3868 | 1969 |
|
1970 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1971 |
'Make.proto' asFilename sameContentsAs:'Makefile' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1972 |
'Make.proto' asFilename sameContentsAs:'Make.proto' |
3868 | 1973 |
" |
5876
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1974 |
|
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1975 |
" |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1976 |
|s| |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1977 |
|
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1978 |
s := 'testFile1' asFilename writeStream. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1979 |
s nextPutAll:'11111'. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1980 |
s nextPutAll:'22222'. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1981 |
s nextPutAll:'33333'. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1982 |
s close. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1983 |
|
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1984 |
s := 'testFile2' asFilename writeStream. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1985 |
s nextPutAll:'11111'. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1986 |
s nextPutAll:'22222'. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1987 |
s nextPutAll:'33333'. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1988 |
s close. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1989 |
|
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1990 |
('testFile1' asFilename sameContentsAs:'testFile2' ) ifFalse:[self halt]. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1991 |
|
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1992 |
s := 'testFile2' asFilename writeStream. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1993 |
s nextPutAll:'11111'. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1994 |
s nextPutAll:'22222'. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1995 |
s nextPutAll:'33333'. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1996 |
s nextPutAll:'44444'. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1997 |
s close. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1998 |
|
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1999 |
('testFile1' asFilename sameContentsAs:'testFile2' ) ifTrue:[self halt]. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
2000 |
|
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
2001 |
s := 'testFile2' asFilename writeStream. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
2002 |
s nextPutAll:'11111'. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
2003 |
s nextPutAll:'22222'. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
2004 |
s close. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
2005 |
|
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
2006 |
('testFile1' asFilename sameContentsAs:'testFile2' ) ifTrue:[self halt]. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
2007 |
|
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
2008 |
s := 'testFile2' asFilename writeStream. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
2009 |
s nextPutAll:'11111'. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
2010 |
s nextPutAll:'22222'. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
2011 |
s nextPutAll:'33334'. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
2012 |
s close. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
2013 |
|
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
2014 |
('testFile1' asFilename sameContentsAs:'testFile2' ) ifTrue:[self halt]. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
2015 |
|
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
2016 |
" |
615 | 2017 |
! ! |
2018 |
||
2019 |
!Filename methodsFor:'converting'! |
|
2020 |
||
2021 |
asAbsoluteFilename |
|
2022 |
"return the receiver converted to a filename with |
|
2023 |
an absolute pathname." |
|
2024 |
||
15811 | 2025 |
^ self species named:self pathName |
7332 | 2026 |
|
2027 |
" |
|
2028 |
'.' asFilename |
|
2029 |
'.' asFilename asAbsoluteFilename |
|
9173 | 2030 |
'c:' asFilename asAbsoluteFilename |
7332 | 2031 |
" |
615 | 2032 |
! |
2033 |
||
10769 | 2034 |
asAutoDeletedFilename |
13653
6821135a2e1a
comment/format in: #asAutoDeletedFilename
Claus Gittinger <cg@exept.de>
parents:
13424
diff
changeset
|
2035 |
"will automatically delete myself, when no longer referenced" |
6821135a2e1a
comment/format in: #asAutoDeletedFilename
Claus Gittinger <cg@exept.de>
parents:
13424
diff
changeset
|
2036 |
|
11784 | 2037 |
^ AutoDeletedFilename basicNew setName:self name |
13653
6821135a2e1a
comment/format in: #asAutoDeletedFilename
Claus Gittinger <cg@exept.de>
parents:
13424
diff
changeset
|
2038 |
|
6821135a2e1a
comment/format in: #asAutoDeletedFilename
Claus Gittinger <cg@exept.de>
parents:
13424
diff
changeset
|
2039 |
"Modified (comment): / 07-09-2011 / 12:20:59 / cg" |
10769 | 2040 |
! |
2041 |
||
6802 | 2042 |
asCanonicalizedFilename |
2043 |
"return the receiver converted to a filename without intermediate ..'s and .'s |
|
2044 |
(similar to an absolute pathname, but symlinks are not resolved)." |
|
2045 |
||
15811 | 2046 |
^ self species named:(self species canonicalize:nameString) |
7074 | 2047 |
|
2048 |
" |
|
2049 |
'c:\test\work' asFilename asCanonicalizedFilename |
|
2050 |
'/test/work' asFilename asCanonicalizedFilename |
|
2051 |
" |
|
6802 | 2052 |
! |
2053 |
||
615 | 2054 |
asFilename |
1970 | 2055 |
"return the receiver converted to a filename; here, thats the receiver itself." |
615 | 2056 |
|
2057 |
"Thats pretty easy here :-)" |
|
2058 |
^ self |
|
1970 | 2059 |
|
2060 |
"Modified: 12.11.1996 / 12:40:03 / cg" |
|
615 | 2061 |
! |
2062 |
||
2063 |
asString |
|
2064 |
"return the receiver converted to a string" |
|
2065 |
||
2066 |
^ nameString |
|
2067 |
! |
|
2068 |
||
6256 | 2069 |
asURI |
15001 | 2070 |
"return the receiver converted to a file URI" |
6256 | 2071 |
|
2072 |
^ FileURI fromFilename:self. |
|
2073 |
! |
|
2074 |
||
15001 | 2075 |
asURL |
2076 |
"return an URL-object from myself" |
|
2077 |
||
2078 |
^ URL fromString:self pathName. |
|
2079 |
! |
|
2080 |
||
19665 | 2081 |
asUniqueFilename |
2082 |
"I a file by my name already exists, return a new filename with a unique string appended. |
|
2083 |
here, a somewhat naive strategy is performed, by trying _1, _2,... until a new name is generated." |
|
2084 |
||
2085 |
|fn baseFn nextSeqNr| |
|
2086 |
||
2087 |
fn := baseFn := self. |
|
2088 |
nextSeqNr := 0. |
|
2089 |
[ fn exists ] whileTrue:[ |
|
2090 |
|newFn| |
|
2091 |
||
2092 |
nextSeqNr := (nextSeqNr ? 0) + 1. |
|
2093 |
fn := (baseFn withoutSuffix name,'_',nextSeqNr asString) asFilename withSuffix:baseFn suffix. |
|
2094 |
]. |
|
2095 |
^ fn |
|
2096 |
||
2097 |
" |
|
2098 |
'aaa.txt' asFilename contents:'bla'. |
|
2099 |
'aaa.txt' asFilename asUniqueFilename contents:'bla2'. |
|
2100 |
'aaa.txt' asFilename asUniqueFilename contents:'bla3'. |
|
2101 |
'aaa.txt' asFilename asUniqueFilename contents:'bla4'. |
|
2102 |
#('aaa.txt' 'aaa_1.txt' 'aaa_2.txt' 'aaa_3.txt') do:[:f | f asFilename delete]. |
|
2103 |
" |
|
2104 |
! |
|
2105 |
||
5890 | 2106 |
components |
19440 | 2107 |
"return the receiver's filename components - that is the name of each directory |
5890 | 2108 |
along the pathName (that DOES include the root directory)" |
2109 |
||
15811 | 2110 |
^ self species components:self name |
5890 | 2111 |
|
2112 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2113 |
'.' asFilename asAbsoluteFilename components |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2114 |
'Makefile' asFilename asAbsoluteFilename components |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2115 |
" |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2116 |
! |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2117 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2118 |
makeLegalFilename |
19440 | 2119 |
"convert the receiver's name to be a legal filename. |
1970 | 2120 |
This removes/replaces invalid characters and/or compresses |
2121 |
the name as required by the OS. |
|
615 | 2122 |
The implementation may change in the future to be more |
2123 |
OS specific." |
|
2124 |
||
2125 |
" |
|
2126 |
actually, in Unix spaces are allowed - but it makes life |
|
2127 |
so hard; therefore, replace them by underscores ... |
|
2128 |
" |
|
16761 | 2129 |
nameString := nameString copyReplaceAll:(Character space) with:$_ ifNone:nameString. |
615 | 2130 |
" |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2131 |
need more - especially on SYS5.3 type systems, |
615 | 2132 |
we may want to contract the fileName to 14 characters. |
2133 |
" |
|
2134 |
^ self |
|
2135 |
||
2136 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2137 |
'hello world' asFilename makeLegalFilename |
615 | 2138 |
" |
1970 | 2139 |
|
3658 | 2140 |
"Modified: / 20.7.1998 / 13:16:51 / cg" |
2707
280456505357
added #findDefaultDirectory and #withEncoding:
Claus Gittinger <cg@exept.de>
parents:
2630
diff
changeset
|
2141 |
! |
280456505357
added #findDefaultDirectory and #withEncoding:
Claus Gittinger <cg@exept.de>
parents:
2630
diff
changeset
|
2142 |
|
280456505357
added #findDefaultDirectory and #withEncoding:
Claus Gittinger <cg@exept.de>
parents:
2630
diff
changeset
|
2143 |
withEncoding:encodingSymbol |
280456505357
added #findDefaultDirectory and #withEncoding:
Claus Gittinger <cg@exept.de>
parents:
2630
diff
changeset
|
2144 |
"dummy for now - for ST80 compatibility" |
280456505357
added #findDefaultDirectory and #withEncoding:
Claus Gittinger <cg@exept.de>
parents:
2630
diff
changeset
|
2145 |
|
280456505357
added #findDefaultDirectory and #withEncoding:
Claus Gittinger <cg@exept.de>
parents:
2630
diff
changeset
|
2146 |
^ self |
280456505357
added #findDefaultDirectory and #withEncoding:
Claus Gittinger <cg@exept.de>
parents:
2630
diff
changeset
|
2147 |
|
280456505357
added #findDefaultDirectory and #withEncoding:
Claus Gittinger <cg@exept.de>
parents:
2630
diff
changeset
|
2148 |
"Created: 20.6.1997 / 17:01:28 / cg" |
2 | 2149 |
! ! |
2150 |
||
18272 | 2151 |
|
5889
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2152 |
!Filename methodsFor:'enumerating-contents'! |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2153 |
|
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2154 |
allDirectoriesDo:aBlock |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2155 |
"evaluate aBlock for all (recursive) directories contained in the directory represented by the receiver. |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2156 |
The block is invoked with a filename-arguments. |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2157 |
The enumerations order within a directory is undefined - i.e. usually NOT sorted by |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2158 |
filenames (but by creation time - on some systems). |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2159 |
This excludes entries for '.' or '..'. |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2160 |
NoOp for non-existing directories; however, this behavior |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2161 |
may be changed in the near future, to raise an exception instead. |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2162 |
So users of this method better test for existing directory before." |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2163 |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2164 |
self recursiveDirectoryContentsDo:[:eachFileOrDirectoryName | |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2165 |
|eachFileOrDirectory| |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2166 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2167 |
eachFileOrDirectory := self construct:eachFileOrDirectoryName. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2168 |
eachFileOrDirectory isDirectory ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2169 |
aBlock value:eachFileOrDirectory |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2170 |
] |
5889
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2171 |
]. |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2172 |
|
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2173 |
" |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2174 |
'.' asFilename allDirectoriesDo:[:fn | Transcript showCR:fn name]. |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2175 |
'.' asFilename directoriesDo:[:fn | Transcript showCR:fn name]. |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2176 |
" |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2177 |
! |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2178 |
|
6773
26415b61ad09
isMountPoint & isParentDirectoryOf & allParentDirsDo:
penk
parents:
6771
diff
changeset
|
2179 |
allParentDirectoriesDo:aBlock |
26415b61ad09
isMountPoint & isParentDirectoryOf & allParentDirsDo:
penk
parents:
6771
diff
changeset
|
2180 |
"evaluate aBlock for all (recursive) directories along the parent directory path. |
26415b61ad09
isMountPoint & isParentDirectoryOf & allParentDirsDo:
penk
parents:
6771
diff
changeset
|
2181 |
The block is invoked with a filename-arguments." |
26415b61ad09
isMountPoint & isParentDirectoryOf & allParentDirsDo:
penk
parents:
6771
diff
changeset
|
2182 |
|
26415b61ad09
isMountPoint & isParentDirectoryOf & allParentDirsDo:
penk
parents:
6771
diff
changeset
|
2183 |
|parent here| |
26415b61ad09
isMountPoint & isParentDirectoryOf & allParentDirsDo:
penk
parents:
6771
diff
changeset
|
2184 |
|
26415b61ad09
isMountPoint & isParentDirectoryOf & allParentDirsDo:
penk
parents:
6771
diff
changeset
|
2185 |
here := self. |
26415b61ad09
isMountPoint & isParentDirectoryOf & allParentDirsDo:
penk
parents:
6771
diff
changeset
|
2186 |
parent := here directory. |
26415b61ad09
isMountPoint & isParentDirectoryOf & allParentDirsDo:
penk
parents:
6771
diff
changeset
|
2187 |
[here notNil and:[parent ~= here]] whileTrue:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2188 |
aBlock value:parent. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2189 |
here := parent. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2190 |
parent := here directory. |
6773
26415b61ad09
isMountPoint & isParentDirectoryOf & allParentDirsDo:
penk
parents:
6771
diff
changeset
|
2191 |
]. |
26415b61ad09
isMountPoint & isParentDirectoryOf & allParentDirsDo:
penk
parents:
6771
diff
changeset
|
2192 |
|
26415b61ad09
isMountPoint & isParentDirectoryOf & allParentDirsDo:
penk
parents:
6771
diff
changeset
|
2193 |
" |
26415b61ad09
isMountPoint & isParentDirectoryOf & allParentDirsDo:
penk
parents:
6771
diff
changeset
|
2194 |
'.' asFilename allParentDirectoriesDo:[:fn | Transcript showCR:fn pathName]. |
26415b61ad09
isMountPoint & isParentDirectoryOf & allParentDirsDo:
penk
parents:
6771
diff
changeset
|
2195 |
" |
26415b61ad09
isMountPoint & isParentDirectoryOf & allParentDirsDo:
penk
parents:
6771
diff
changeset
|
2196 |
! |
26415b61ad09
isMountPoint & isParentDirectoryOf & allParentDirsDo:
penk
parents:
6771
diff
changeset
|
2197 |
|
9362 | 2198 |
directories |
2199 |
"return a collection of directories contained in the directory represented by the receiver." |
|
2200 |
||
19821 | 2201 |
^ OrderedCollection withCollectedContents:[:coll | |
2202 |
self directoriesDo:[:eachDirectory | coll add:eachDirectory]] |
|
9362 | 2203 |
|
2204 |
" |
|
2205 |
'.' asFilename directories. |
|
2206 |
" |
|
10557 | 2207 |
|
2208 |
"Modified: / 29-05-2007 / 12:02:56 / cg" |
|
9362 | 2209 |
! |
2210 |
||
5889
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2211 |
directoriesDo:aBlock |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2212 |
"evaluate aBlock for directories contained in the directory represented by the receiver. |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2213 |
The block is invoked with a filename-arguments. |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2214 |
The enumerations order is undefined - i.e. usually NOT sorted by |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2215 |
filenames (but by creation time - on some systems). |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2216 |
This excludes entries for '.' or '..'. |
18686 | 2217 |
OpenError is raised if I represent a non-existent or non-readable directories. |
5889
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2218 |
So users of this method better test for existing directory before." |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2219 |
|
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2220 |
self directoryContentsAsFilenamesDo:[:eachFileOrDirectory | |
19599 | 2221 |
eachFileOrDirectory isDirectory ifTrue:[ |
2222 |
aBlock value:eachFileOrDirectory |
|
2223 |
] |
|
5889
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2224 |
]. |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2225 |
|
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2226 |
" |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2227 |
'.' asFilename directoriesDo:[:fn | Transcript showCR:fn baseName]. |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2228 |
" |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2229 |
! |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2230 |
|
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2231 |
directoryContentsAsFilenamesDo:aBlock |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2232 |
"evaluate aBlock for each file in the directory represented by the receiver. |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2233 |
The block is invoked with a filename-argument. |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2234 |
The enumerations order is undefined - i.e. usually NOT sorted by |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2235 |
filenames (but by creation time - on some systems). |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2236 |
This excludes entries for '.' or '..'. |
17310 | 2237 |
An OpenError exception is raised it the directory does not exist or is not readable. |
5889
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2238 |
So users of this method better test for existing directory before. |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2239 |
Notice: this enumerates fileName objects; see also |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2240 |
#directoryContentsDo:, which enumerates strings." |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2241 |
|
6776
11df52e55905
better loop (dont preread all items in ..asFilenamesDo:)
penk
parents:
6773
diff
changeset
|
2242 |
self directoryContentsDo:[:entry | |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2243 |
aBlock value:(self construct:entry). |
6776
11df52e55905
better loop (dont preread all items in ..asFilenamesDo:)
penk
parents:
6773
diff
changeset
|
2244 |
] |
5889
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2245 |
|
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2246 |
" |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2247 |
'.' asFilename directoryContentsAsFilenamesDo:[:fn | Transcript showCR:fn pathName]. |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2248 |
" |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2249 |
|
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2250 |
"Modified: / 18.9.1997 / 18:42:23 / stefan" |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2251 |
"Modified: / 23.12.1999 / 20:56:35 / cg" |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2252 |
! |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2253 |
|
7464 | 2254 |
directoryContentsDo:aBlock |
2255 |
"evaluate aBlock for each file in the directory represented by the receiver. |
|
2256 |
The block is invoked with a string as argument. |
|
2257 |
The enumerations order is undefined - i.e. usually NOT sorted by |
|
2258 |
filenames (but by creation time - on some systems). |
|
2259 |
This excludes entries for '.' or '..'. |
|
17310 | 2260 |
An OpenError exception is raised it the directory does not exist or is not readable. |
7464 | 2261 |
So users of this method better test for existing directory before. |
2262 |
Notice: this enumerates strings; see also |
|
2263 |
#directoryContentsAsFilenamesDo:, which enumerates fileName objects." |
|
2264 |
||
17310 | 2265 |
|s| |
2266 |
||
2267 |
s := DirectoryStream directoryNamed:self osNameForDirectoryContents. |
|
2268 |
"check for nil, in order to allow to proceed from an OpenError" |
|
2269 |
s notNil ifTrue:[ |
|
19821 | 2270 |
[ |
2271 |
[s atEnd] whileFalse:[ |
|
2272 |
|fn| |
|
2273 |
||
2274 |
fn := s nextLine. |
|
2275 |
(fn notNil and:[fn ~= '.' and:[fn ~= '..']]) ifTrue:[ |
|
2276 |
aBlock value:fn |
|
2277 |
]. |
|
2278 |
]. |
|
2279 |
] ensure:[ |
|
2280 |
s close. |
|
2281 |
]. |
|
7464 | 2282 |
]. |
2283 |
||
2284 |
" |
|
2285 |
'.' asFilename directoryContentsDo:[:fn | Transcript showCR:fn]. |
|
7473 | 2286 |
'doeSnotExIST' asFilename directoryContentsDo:[:fn | Transcript showCR:fn]. |
17310 | 2287 |
[ |
19821 | 2288 |
'doeSnotExIST' asFilename directoryContentsDo:[:fn | Transcript showCR:fn]. |
17310 | 2289 |
] on:OpenError do:[:ex| ex proceed] |
7464 | 2290 |
" |
2291 |
||
2292 |
"Modified: / 18.9.1997 / 18:42:23 / stefan" |
|
2293 |
"Modified: / 23.12.1999 / 20:56:35 / cg" |
|
2294 |
! |
|
2295 |
||
9382 | 2296 |
files |
19599 | 2297 |
"return a collection of regular files |
18734 | 2298 |
contained in the directory represented by the receiver." |
9382 | 2299 |
|
19821 | 2300 |
^ OrderedCollection withCollectedContents:[:coll | |
2301 |
self filesDo:[:eachFileName | coll add:eachFileName]]. |
|
9382 | 2302 |
|
2303 |
" |
|
2304 |
'.' asFilename files. |
|
2305 |
" |
|
10557 | 2306 |
|
2307 |
"Modified: / 29-05-2007 / 12:02:15 / cg" |
|
9382 | 2308 |
! |
2309 |
||
9806 | 2310 |
filesDo:aBlock |
18734 | 2311 |
"evaluate aBlock for all regular files (i.e. subdirs are ignored) |
2312 |
contained in the directory represented by the receiver." |
|
9806 | 2313 |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2314 |
^ self directoryContentsAsFilenamesDo:[:eachFileOrDirectory | |
19599 | 2315 |
eachFileOrDirectory isRegularFile ifTrue:[ |
2316 |
aBlock value: eachFileOrDirectory |
|
2317 |
]. |
|
17310 | 2318 |
]. |
9806 | 2319 |
|
2320 |
" |
|
2321 |
'.' asFilename filesDo:[:f | Transcript showCR:f]. |
|
2322 |
" |
|
2323 |
||
2324 |
"Created: / 29-08-2006 / 11:03:15 / cg" |
|
10557 | 2325 |
"Modified: / 29-05-2007 / 12:02:46 / cg" |
9806 | 2326 |
! |
2327 |
||
19821 | 2328 |
filesMatchingGLOB:pattern do:aBlock |
2329 |
"Interpreting pattern as a GLOB pattern, |
|
2330 |
evaluate aBlock for each file in me, which matches. |
|
2331 |
Returns the number of matches." |
|
2332 |
||
2333 |
self assert:(pattern asFilename isAbsolute not). |
|
2334 |
^ self filesMatchingGLOBComponents:(Filename components:pattern) do:aBlock |
|
2335 |
||
2336 |
" |
|
2337 |
'..' asFilename filesMatchingGLOB:'A*' do:[:fn | Transcript showCR:fn]. |
|
2338 |
'../..' asFilename filesMatchingGLOB:'lib*/*.st' do:[:fn | Transcript showCR:fn]. |
|
2339 |
" |
|
2340 |
! |
|
2341 |
||
2342 |
filesMatchingGLOBComponents:patternComponents do:aBlock |
|
2343 |
"patternComponents is a component-collection with possible GLOB patterns. |
|
2344 |
Evaluate aBlock for each file in me, which matches. |
|
2345 |
Returns the number of matches" |
|
2346 |
||
2347 |
|dirPath subComponents count| |
|
2348 |
||
2349 |
dirPath := patternComponents first. |
|
2350 |
subComponents := patternComponents copyFrom:2. |
|
2351 |
||
2352 |
dirPath includesMatchCharacters ifFalse:[ |
|
2353 |
| sub | |
|
2354 |
||
2355 |
sub := (self / dirPath). |
|
2356 |
subComponents isEmpty ifTrue:[ |
|
2357 |
"/ I am a leaf |
|
2358 |
sub exists ifTrue:[ |
|
2359 |
aBlock value:sub. |
|
2360 |
^ 1. |
|
2361 |
]. |
|
2362 |
^ 0 |
|
2363 |
] ifFalse:[ |
|
2364 |
^ sub filesMatchingGLOBComponents:subComponents do:aBlock |
|
2365 |
]. |
|
2366 |
] ifTrue:[ |
|
2367 |
count := 0. |
|
2368 |
subComponents isEmpty ifTrue:[ |
|
2369 |
"/ I am a leaf |
|
2370 |
self isDirectory ifTrue:[ |
|
2371 |
self filesMatching:dirPath do:[:eachMatchingFile | |
|
2372 |
aBlock value:(self / eachMatchingFile). |
|
2373 |
count := count + 1. |
|
2374 |
] |
|
2375 |
] |
|
2376 |
] ifFalse:[ |
|
2377 |
self filesMatching:dirPath do:[:eachMatchingSubDir | |
|
2378 |
|sub| |
|
2379 |
sub := (self / eachMatchingSubDir). |
|
2380 |
sub isDirectory ifTrue:[ |
|
2381 |
count := count + (sub filesMatchingGLOBComponents:subComponents do:aBlock) |
|
2382 |
]. |
|
2383 |
]. |
|
2384 |
]. |
|
2385 |
^ count |
|
2386 |
]. |
|
2387 |
||
2388 |
" |
|
2389 |
'/etc/A*' asFilename filesMatchingGLOBDo:[:fn | Transcript showCR:fn]. |
|
2390 |
'../A*' asFilename filesMatchingGLOBDo:[:fn | Transcript showCR:fn]. |
|
2391 |
'../../lib*/*.st' asFilename filesMatchingGLOBDo:[:fn | Transcript showCR:fn]. |
|
2392 |
" |
|
2393 |
! |
|
2394 |
||
2395 |
filesMatchingGLOBDo:aBlock |
|
2396 |
"Interpreting myself as a GLOB pattern, |
|
2397 |
evaluate aBlock for each file which matches." |
|
2398 |
||
2399 |
|parts dirPath subComponents count top| |
|
2400 |
||
2401 |
parts := self components. |
|
2402 |
dirPath := parts first. |
|
2403 |
subComponents := parts copyFrom:2. |
|
2404 |
||
2405 |
OpenError handle:[:ex | |
|
2406 |
('%1 [info]: failed to open %2: %3' |
|
2407 |
bindWith:self class name |
|
2408 |
with:ex pathName |
|
2409 |
with:ex description) infoPrintCR. |
|
2410 |
self breakPoint:#cg. |
|
2411 |
ex proceed. |
|
2412 |
] do:[ |
|
2413 |
top := dirPath asFilename. |
|
2414 |
||
2415 |
dirPath includesMatchCharacters ifFalse:[ |
|
2416 |
top isAbsolute ifFalse:[ |
|
2417 |
top := Filename currentDirectory construct:dirPath. |
|
2418 |
]. |
|
2419 |
^ top filesMatchingGLOBComponents:subComponents do:aBlock |
|
2420 |
]. |
|
2421 |
||
2422 |
top isAbsolute ifFalse:[ |
|
2423 |
top := Filename currentDirectory. |
|
2424 |
]. |
|
2425 |
count := 0. |
|
2426 |
top filesMatching:dirPath do:[:sub | |
|
2427 |
count := count + ((self / sub) filesMatchingGLOBComponents:subComponents do:aBlock) |
|
2428 |
]. |
|
2429 |
^ count |
|
2430 |
]. |
|
2431 |
||
2432 |
" |
|
2433 |
'/etc/A*' asFilename filesMatchingGLOBDo:[:fn | Transcript showCR:fn]. |
|
2434 |
'/etc/a*' asFilename filesMatchingGLOBDo:[:fn | Transcript showCR:fn]. |
|
2435 |
'../A*' asFilename filesMatchingGLOBDo:[:fn | Transcript showCR:fn]. |
|
2436 |
'../../lib*/*.st' asFilename filesMatchingGLOBDo:[:fn | Transcript showCR:fn]. |
|
2437 |
'../../lib*/[A-D]*.st' asFilename filesMatchingGLOBDo:[:fn | Transcript showCR:fn]. |
|
2438 |
'../../*/[A-D]*.st' asFilename filesMatchingGLOBDo:[:fn | Transcript showCR:fn]. |
|
2439 |
'../../*/*/[A-D]*.st' asFilename filesMatchingGLOBDo:[:fn | Transcript showCR:fn]. |
|
2440 |
'../../*java*/*/[A-D]*.st' asFilename filesMatchingGLOBDo:[:fn | Transcript showCR:fn]. |
|
2441 |
'../../*java*/*/Ary.st' asFilename filesMatchingGLOBDo:[:fn | Transcript showCR:fn]. |
|
2442 |
'/*/A*' asFilename filesMatchingGLOBDo:[:fn | Transcript showCR:fn]. |
|
2443 |
'*/A*' asFilename filesMatchingGLOBDo:[:fn | Transcript showCR:fn]. |
|
2444 |
'../*/A*' asFilename filesMatchingGLOBDo:[:fn | Transcript showCR:fn]. |
|
2445 |
'./*/A*' asFilename filesMatchingGLOBDo:[:fn | Transcript showCR:fn]. |
|
2446 |
'./*/*' asFilename filesMatchingGLOBDo:[:fn | Transcript showCR:fn]. |
|
2447 |
'././A*' asFilename filesMatchingGLOBDo:[:fn | Transcript showCR:fn]. |
|
2448 |
" |
|
2449 |
! |
|
2450 |
||
18734 | 2451 |
filesWithSuffix:suffix |
2452 |
"return a collection of regular files (i.e. not subdirectories) |
|
19599 | 2453 |
with a given suffix which are contained in the directory |
18734 | 2454 |
represented by the receiver." |
2455 |
||
19821 | 2456 |
^ OrderedCollection withCollectedContents:[:coll | |
2457 |
self filesWithSuffix:suffix do:[:eachFileName | coll add:eachFileName]]. |
|
18734 | 2458 |
|
2459 |
" |
|
2460 |
'.' asFilename filesWithSuffix:'so'. |
|
19821 | 2461 |
'packages' asFilename filesWithSuffix:'so'. |
18734 | 2462 |
" |
2463 |
! |
|
2464 |
||
2465 |
filesWithSuffix:suffix do:aBlock |
|
2466 |
"evaluate aBlock for all regular files with a given suffix |
|
2467 |
contained in the directory represented by the receiver. |
|
2468 |
(i.e. subdirs are ignored)" |
|
2469 |
||
2470 |
^ self directoryContentsAsFilenamesDo:[:eachFileOrDirectory | |
|
19599 | 2471 |
(eachFileOrDirectory hasSuffix:suffix) ifTrue:[ |
2472 |
eachFileOrDirectory isRegularFile ifTrue:[ |
|
2473 |
aBlock value: eachFileOrDirectory |
|
2474 |
]. |
|
2475 |
]. |
|
18734 | 2476 |
]. |
2477 |
||
2478 |
" |
|
2479 |
'.' asFilename filesWithSuffix:'so' do:[:f | Transcript showCR:f]. |
|
2480 |
" |
|
2481 |
! |
|
2482 |
||
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2483 |
recursiveDirectoryContentsAsFilenamesDo:aBlock |
13191
10ffa6ac5505
added: #recursiveDirectoryContentsAsFilenamesDo:
Claus Gittinger <cg@exept.de>
parents:
13139
diff
changeset
|
2484 |
"evaluate aBlock for all files and directories found under the receiver. |
10ffa6ac5505
added: #recursiveDirectoryContentsAsFilenamesDo:
Claus Gittinger <cg@exept.de>
parents:
13139
diff
changeset
|
2485 |
The block is invoked with the filenames as argument. |
10ffa6ac5505
added: #recursiveDirectoryContentsAsFilenamesDo:
Claus Gittinger <cg@exept.de>
parents:
13139
diff
changeset
|
2486 |
The walk is bread-first. |
10ffa6ac5505
added: #recursiveDirectoryContentsAsFilenamesDo:
Claus Gittinger <cg@exept.de>
parents:
13139
diff
changeset
|
2487 |
This excludes any entries for '.' or '..'. |
10ffa6ac5505
added: #recursiveDirectoryContentsAsFilenamesDo:
Claus Gittinger <cg@exept.de>
parents:
13139
diff
changeset
|
2488 |
Subdirectory files are included with a relative pathname. |
10ffa6ac5505
added: #recursiveDirectoryContentsAsFilenamesDo:
Claus Gittinger <cg@exept.de>
parents:
13139
diff
changeset
|
2489 |
Warning: this may take a long time to execute (especially with deep and/or remote fileSystems)." |
10ffa6ac5505
added: #recursiveDirectoryContentsAsFilenamesDo:
Claus Gittinger <cg@exept.de>
parents:
13139
diff
changeset
|
2490 |
|
10ffa6ac5505
added: #recursiveDirectoryContentsAsFilenamesDo:
Claus Gittinger <cg@exept.de>
parents:
13139
diff
changeset
|
2491 |
self recursiveDirectoryContentsDo:[:relFn | |
19664 | 2492 |
aBlock value:(self construct:relFn) |
13191
10ffa6ac5505
added: #recursiveDirectoryContentsAsFilenamesDo:
Claus Gittinger <cg@exept.de>
parents:
13139
diff
changeset
|
2493 |
]. |
10ffa6ac5505
added: #recursiveDirectoryContentsAsFilenamesDo:
Claus Gittinger <cg@exept.de>
parents:
13139
diff
changeset
|
2494 |
|
10ffa6ac5505
added: #recursiveDirectoryContentsAsFilenamesDo:
Claus Gittinger <cg@exept.de>
parents:
13139
diff
changeset
|
2495 |
" |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2496 |
'.' asFilename recursiveDirectoryContentsAsFilenamesDo:[:f | Transcript showCR:f] |
13191
10ffa6ac5505
added: #recursiveDirectoryContentsAsFilenamesDo:
Claus Gittinger <cg@exept.de>
parents:
13139
diff
changeset
|
2497 |
" |
10ffa6ac5505
added: #recursiveDirectoryContentsAsFilenamesDo:
Claus Gittinger <cg@exept.de>
parents:
13139
diff
changeset
|
2498 |
|
10ffa6ac5505
added: #recursiveDirectoryContentsAsFilenamesDo:
Claus Gittinger <cg@exept.de>
parents:
13139
diff
changeset
|
2499 |
"Modified: / 12-09-2010 / 15:43:22 / cg" |
10ffa6ac5505
added: #recursiveDirectoryContentsAsFilenamesDo:
Claus Gittinger <cg@exept.de>
parents:
13139
diff
changeset
|
2500 |
! |
10ffa6ac5505
added: #recursiveDirectoryContentsAsFilenamesDo:
Claus Gittinger <cg@exept.de>
parents:
13139
diff
changeset
|
2501 |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2502 |
recursiveDirectoryContentsDo:aBlock |
5889
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2503 |
"evaluate aBlock for all files and directories found under the receiver. |
13057
4f7fa62156ac
comment/format in: #recursiveDirectoryContentsDo:
Claus Gittinger <cg@exept.de>
parents:
12975
diff
changeset
|
2504 |
The block is invoked with the relative filenames as string-argument. |
5889
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2505 |
The walk is bread-first. |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2506 |
This excludes any entries for '.' or '..'. |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2507 |
Subdirectory files are included with a relative pathname. |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2508 |
Warning: this may take a long time to execute (especially with deep and/or remote fileSystems)." |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2509 |
|
19664 | 2510 |
self |
2511 |
recursiveDirectoryContentsWithPrefix:'' |
|
2512 |
filesDo:aBlock |
|
2513 |
directoriesDo:aBlock |
|
5889
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2514 |
|
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2515 |
" |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2516 |
'.' asFilename recursiveDirectoryContentsDo:[:f | Transcript showCR:f] |
5889
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2517 |
" |
13057
4f7fa62156ac
comment/format in: #recursiveDirectoryContentsDo:
Claus Gittinger <cg@exept.de>
parents:
12975
diff
changeset
|
2518 |
|
4f7fa62156ac
comment/format in: #recursiveDirectoryContentsDo:
Claus Gittinger <cg@exept.de>
parents:
12975
diff
changeset
|
2519 |
"Modified: / 12-09-2010 / 15:43:22 / cg" |
5889
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2520 |
! |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2521 |
|
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2522 |
recursiveDirectoryContentsDo:aBlock directoryPrefix:aPrefix |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2523 |
"evaluate aBlock for all files and directories found under the receiver. |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2524 |
The block is invoked with a string-argument. |
7088
cc3233554827
Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents:
7075
diff
changeset
|
2525 |
The walk is breadth-first. |
5889
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2526 |
This excludes any entries for '.' or '..'. |
19664 | 2527 |
The argument to aBlock is a pathname relative to aPrefix. |
19114 | 2528 |
A proceedable exception is raised forn non-accessible directories. |
5889
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2529 |
Warning: this may take a long time to execute (especially with deep and/or remote fileSystems)." |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2530 |
|
19664 | 2531 |
self |
2532 |
recursiveDirectoryContentsWithPrefix:aPrefix |
|
2533 |
filesDo:aBlock |
|
2534 |
directoriesDo:aBlock |
|
5889
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2535 |
|
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2536 |
" |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2537 |
'.' asFilename recursiveDirectoryContentsDo:[:f | Transcript showCR:f] |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2538 |
'/etc' asFilename recursiveDirectoryContentsDo:[:f | Transcript showCR:f] |
5889
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2539 |
" |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2540 |
! |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2541 |
|
19664 | 2542 |
recursiveDirectoryContentsWithPrefix:aPrefix filesDo:fileBlock directoriesDo:dirBlock |
2543 |
"evaluate aBlock for all files and directories found under the receiver. |
|
2544 |
The blocks are invoked with a relative pathname as string-argument. |
|
2545 |
The walk is breadth-first (first files, then directories). |
|
2546 |
This excludes any entries for '.' or '..'. |
|
2547 |
A proceedable exception is raised for non-accessible directories. |
|
2548 |
Warning: this may take a long time to execute (especially with deep and/or remote fileSystems)." |
|
2549 |
||
2550 |
|fileNames dirNames p| |
|
2551 |
||
2552 |
"/ first collect files and dirs |
|
2553 |
fileNames := OrderedCollection new. |
|
2554 |
dirNames := OrderedCollection new. |
|
2555 |
||
2556 |
self directoryContentsDo:[:f | |t| |
|
2557 |
t := self construct:f. |
|
2558 |
t isDirectory ifTrue:[ |
|
2559 |
dirBlock notNil ifTrue:[ |
|
2560 |
t isSymbolicLink ifFalse:[ |
|
2561 |
dirNames add:f |
|
2562 |
] |
|
2563 |
] |
|
2564 |
] ifFalse:[ |
|
2565 |
fileBlock notNil ifTrue:[ |
|
2566 |
fileNames add:f |
|
2567 |
] |
|
2568 |
] |
|
2569 |
]. |
|
2570 |
||
2571 |
aPrefix size > 0 ifTrue:[ |
|
2572 |
p := aPrefix , self separator |
|
2573 |
] ifFalse:[ |
|
2574 |
p := '' |
|
2575 |
]. |
|
2576 |
||
2577 |
fileBlock notNil ifTrue:[ |
|
2578 |
fileNames do:[:aFile | fileBlock value:(p , aFile)]. |
|
2579 |
]. |
|
2580 |
dirBlock notNil ifTrue:[ |
|
2581 |
dirNames do:[:dN | |
|
2582 |
dirBlock value:(p , dN). |
|
2583 |
(self construct:dN) |
|
2584 |
recursiveDirectoryContentsWithPrefix:(p , dN) |
|
2585 |
filesDo:fileBlock directoriesDo:dirBlock |
|
2586 |
]. |
|
2587 |
]. |
|
2588 |
||
2589 |
" |
|
2590 |
'.' asFilename |
|
2591 |
recursiveDirectoryContentsWithPrefix:'bla' |
|
2592 |
filesDo:[:f | Transcript show:'file: '; showCR:f] |
|
2593 |
directoriesDo:[:f | Transcript show:'dir: '; showCR:f] |
|
2594 |
" |
|
2595 |
! |
|
2596 |
||
5889
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2597 |
withAllDirectoriesDo:aBlock |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2598 |
"evaluate aBlock for myself and all (recursive) directories contained in the directory represented by the receiver. |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2599 |
The block is invoked with a filename-arguments. |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2600 |
The enumerations order within a directory is undefined - i.e. usually NOT sorted by |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2601 |
filenames (but by creation time - on some systems). |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2602 |
This excludes entries for '.' or '..'. |
17310 | 2603 |
OpenError is raised if the name I represent does not exist or is not readable. |
5889
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2604 |
So users of this method better test for existing directory before." |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2605 |
|
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2606 |
self isDirectory ifTrue:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2607 |
aBlock value:self. |
5889
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2608 |
]. |
17310 | 2609 |
self allDirectoriesDo:aBlock. |
5889
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2610 |
|
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2611 |
" |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2612 |
'.' asFilename withAllDirectoriesDo:[:fn | Transcript showCR:fn name]. |
17310 | 2613 |
'IdoNOTexist' asFilename withAllDirectoriesDo:[:fn | Transcript showCR:fn name]. |
2614 |
'/etc/hosts' asFilename withAllDirectoriesDo:[:fn | Transcript showCR:fn name]. |
|
5889
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2615 |
" |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2616 |
! ! |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2617 |
|
542 | 2618 |
!Filename methodsFor:'error handling'! |
2619 |
||
615 | 2620 |
accessDeniedError:filename |
1120
94c803be0210
compile errorMethods with +optSpace
Claus Gittinger <cg@exept.de>
parents:
1081
diff
changeset
|
2621 |
"{ Pragma: +optSpace }" |
94c803be0210
compile errorMethods with +optSpace
Claus Gittinger <cg@exept.de>
parents:
1081
diff
changeset
|
2622 |
|
94c803be0210
compile errorMethods with +optSpace
Claus Gittinger <cg@exept.de>
parents:
1081
diff
changeset
|
2623 |
"report an error that access to some file was denied" |
94c803be0210
compile errorMethods with +optSpace
Claus Gittinger <cg@exept.de>
parents:
1081
diff
changeset
|
2624 |
|
4820 | 2625 |
|errNo errString| |
2626 |
||
2627 |
errNo := OperatingSystem lastErrorNumber. |
|
2628 |
errString := OperatingSystem lastErrorString. |
|
2629 |
errString size == 0 ifTrue:[ |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2630 |
errString := ''. |
4820 | 2631 |
] ifFalse:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2632 |
errString := ' (' , errString , ')' |
4820 | 2633 |
]. |
2634 |
||
615 | 2635 |
^ OperatingSystem accessDeniedErrorSignal |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2636 |
raiseRequestWith:filename ? self |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2637 |
errorString:(' : ' , (filename ? self) asString , errString) |
4820 | 2638 |
|
2639 |
"Modified: / 26.9.1999 / 16:11:44 / cg" |
|
615 | 2640 |
! |
2641 |
||
2642 |
fileCreationError:filename |
|
1120
94c803be0210
compile errorMethods with +optSpace
Claus Gittinger <cg@exept.de>
parents:
1081
diff
changeset
|
2643 |
"{ Pragma: +optSpace }" |
94c803be0210
compile errorMethods with +optSpace
Claus Gittinger <cg@exept.de>
parents:
1081
diff
changeset
|
2644 |
|
94c803be0210
compile errorMethods with +optSpace
Claus Gittinger <cg@exept.de>
parents:
1081
diff
changeset
|
2645 |
"report an error that some file could not be created" |
94c803be0210
compile errorMethods with +optSpace
Claus Gittinger <cg@exept.de>
parents:
1081
diff
changeset
|
2646 |
|
615 | 2647 |
^ OperatingSystem accessDeniedErrorSignal |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2648 |
raiseRequestWith:filename?self |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2649 |
errorString:(' - cannot create/write file: "%1"' bindWith:(filename ? self) asString) |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2650 |
! |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2651 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2652 |
fileNotFoundError:filename |
1120
94c803be0210
compile errorMethods with +optSpace
Claus Gittinger <cg@exept.de>
parents:
1081
diff
changeset
|
2653 |
"{ Pragma: +optSpace }" |
94c803be0210
compile errorMethods with +optSpace
Claus Gittinger <cg@exept.de>
parents:
1081
diff
changeset
|
2654 |
|
94c803be0210
compile errorMethods with +optSpace
Claus Gittinger <cg@exept.de>
parents:
1081
diff
changeset
|
2655 |
"report an error that some file was not found" |
94c803be0210
compile errorMethods with +optSpace
Claus Gittinger <cg@exept.de>
parents:
1081
diff
changeset
|
2656 |
|
542 | 2657 |
^ OperatingSystem fileNotFoundErrorSignal |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2658 |
raiseRequestWith:filename?self |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2659 |
errorString:('file not found: ' , (filename ? self) asString) |
542 | 2660 |
! |
2661 |
||
2662 |
removeError:filename |
|
1120
94c803be0210
compile errorMethods with +optSpace
Claus Gittinger <cg@exept.de>
parents:
1081
diff
changeset
|
2663 |
"{ Pragma: +optSpace }" |
94c803be0210
compile errorMethods with +optSpace
Claus Gittinger <cg@exept.de>
parents:
1081
diff
changeset
|
2664 |
|
94c803be0210
compile errorMethods with +optSpace
Claus Gittinger <cg@exept.de>
parents:
1081
diff
changeset
|
2665 |
"report an error that some file could not be removed" |
94c803be0210
compile errorMethods with +optSpace
Claus Gittinger <cg@exept.de>
parents:
1081
diff
changeset
|
2666 |
|
542 | 2667 |
^ OperatingSystem accessDeniedErrorSignal |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2668 |
raiseRequestWith:filename?self |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2669 |
errorString:('cannot remove: ' , (filename?self) asString) |
615 | 2670 |
! |
2671 |
||
2672 |
reportError:string with:filename |
|
1120
94c803be0210
compile errorMethods with +optSpace
Claus Gittinger <cg@exept.de>
parents:
1081
diff
changeset
|
2673 |
"{ Pragma: +optSpace }" |
94c803be0210
compile errorMethods with +optSpace
Claus Gittinger <cg@exept.de>
parents:
1081
diff
changeset
|
2674 |
|
94c803be0210
compile errorMethods with +optSpace
Claus Gittinger <cg@exept.de>
parents:
1081
diff
changeset
|
2675 |
"report an error" |
94c803be0210
compile errorMethods with +optSpace
Claus Gittinger <cg@exept.de>
parents:
1081
diff
changeset
|
2676 |
|
15192 | 2677 |
^ OsError |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2678 |
raiseRequestWith:filename?self |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2679 |
errorString:string |
615 | 2680 |
! ! |
2681 |
||
2682 |
!Filename methodsFor:'file access'! |
|
2683 |
||
3015 | 2684 |
appendStream |
2685 |
"return a stream for appending to the file represented by the receiver. |
|
2686 |
If the file does not already exist, it is created. |
|
2687 |
Same as #appendingWriteStream for ST-80 compatibility." |
|
2688 |
||
2689 |
^ self appendingWriteStream |
|
2690 |
! |
|
2691 |
||
615 | 2692 |
appendingWriteStream |
2693 |
"return a stream for appending to the file represented by the receiver. |
|
5720 | 2694 |
If the file does not already exist, it is created; |
2695 |
if it does exist, writes are appended at the end." |
|
615 | 2696 |
|
2947 | 2697 |
^ FileStream appendingOldFileNamed:(self osNameForAccess) |
5720 | 2698 |
|
2699 |
" |
|
2700 |
|s| |
|
2701 |
||
2702 |
s := '/tmp/foo' asFilename writeStream. |
|
2703 |
s nextPutAll:'1234567890'. |
|
2704 |
s close. |
|
2705 |
||
2706 |
s := '/tmp/foo' asFilename appendingWriteStream. |
|
2707 |
s nextPutAll:'abcdef'. |
|
2708 |
s close. |
|
2709 |
||
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2710 |
'/tmp/foo' asFilename contents |
5720 | 2711 |
" |
615 | 2712 |
! |
2713 |
||
15490 | 2714 |
existingReadWriteStream |
2715 |
"return a stream for read/write the file represented by the receiver. |
|
2716 |
If the file does not already exist, an exception is raised." |
|
2717 |
||
2718 |
^ FileStream oldFileNamed:(self osNameForAccess) |
|
2719 |
||
2720 |
" |
|
2721 |
'/tmp/blaFaselQuall666666' asFilename remove. |
|
2722 |
'/tmp/blaFaselQuall666666' asFilename existingReadWriteStream. |
|
2723 |
" |
|
2724 |
" |
|
2725 |
|s| |
|
2726 |
s := '/tmp/foo' asFilename readWriteStream. |
|
2727 |
s nextPutAll:'1234567890'; close. |
|
2728 |
s := '/tmp/foo' asFilename existingReadWriteStream. |
|
2729 |
s nextPutAll:'abcdef'; close. |
|
2730 |
||
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2731 |
'/tmp/foo' asFilename contents inspect. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2732 |
'/tmp/foo' asFilename remove |
15490 | 2733 |
" |
2734 |
! |
|
2735 |
||
615 | 2736 |
newReadWriteStream |
2737 |
"return a stream for read/write the file represented by the receiver. |
|
5720 | 2738 |
If the file does not already exist, it is created; |
2739 |
if it does exist, it is truncated." |
|
615 | 2740 |
|
2947 | 2741 |
^ FileStream newFileNamed:(self osNameForAccess) |
5720 | 2742 |
|
2743 |
" |
|
2744 |
|s| |
|
2745 |
||
2746 |
s := '/tmp/foo' asFilename writeStream. |
|
2747 |
s nextPutAll:'1234567890'. |
|
2748 |
s close. |
|
2749 |
||
2750 |
s := '/tmp/foo' asFilename newReadWriteStream. |
|
2751 |
s nextPutAll:'12345'. |
|
2752 |
s close. |
|
2753 |
||
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2754 |
'/tmp/foo' asFilename contents |
5720 | 2755 |
" |
615 | 2756 |
! |
2757 |
||
15459 | 2758 |
openWithMode:anArrayOrString |
2759 |
"return a stream for read/write the file represented by the receiver. |
|
2760 |
If the file does not already exist, it is created; |
|
2761 |
if it does exist, it is truncated." |
|
2762 |
||
2763 |
^ FileStream open:self osNameForAccess withMode:anArrayOrString |
|
2764 |
||
2765 |
" |
|
2766 |
|s| |
|
2767 |
||
2768 |
s := '/tmp/foo' asFilename openWithMode:'r+'. |
|
2769 |
s nextPutAll:'1234567890'. |
|
2770 |
s close. |
|
2771 |
||
2772 |
||
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2773 |
'/tmp/foo' asFilename contents |
15459 | 2774 |
" |
2775 |
! |
|
2776 |
||
615 | 2777 |
readStream |
2778 |
"return a stream for reading from the file represented by the receiver. |
|
7828 | 2779 |
Raises an error if the file does not exist." |
615 | 2780 |
|
2947 | 2781 |
^ FileStream readonlyFileNamed:(self osNameForAccess) |
615 | 2782 |
|
2783 |
" |
|
17143 | 2784 |
'/tmp/foo' asFilename readStream. |
615 | 2785 |
" |
2786 |
! |
|
2787 |
||
2788 |
readWriteStream |
|
2789 |
"return a stream for read/write the file represented by the receiver. |
|
7828 | 2790 |
If the file does not already exist, it is created. |
2791 |
If the file does exist, it is NOT truncated, but rewritten at the beginning." |
|
615 | 2792 |
|
7088
cc3233554827
Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents:
7075
diff
changeset
|
2793 |
^ FileStream fileNamed:(self osNameForAccess) |
5720 | 2794 |
|
2795 |
" |
|
2796 |
|s| |
|
2797 |
||
2798 |
s := '/tmp/foo' asFilename writeStream. |
|
2799 |
s nextPutAll:'1234567890'. |
|
2800 |
s close. |
|
2801 |
||
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2802 |
s := '/tmp/foo' asFilename readWriteStream. |
5720 | 2803 |
s nextPutAll:'abcdef'. |
2804 |
s close. |
|
2805 |
||
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2806 |
'/tmp/foo' asFilename contents |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2807 |
'/tmp/foo' asFilename remove |
5720 | 2808 |
" |
615 | 2809 |
! |
2810 |
||
2811 |
writeStream |
|
2812 |
"return a stream for writing to the file represented by the receiver. |
|
5720 | 2813 |
If the file does not already exist, it is created; |
2814 |
if it does exist, it is truncated." |
|
615 | 2815 |
|
2947 | 2816 |
^ FileStream newFileForWritingNamed:(self osNameForAccess) |
615 | 2817 |
|
2818 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2819 |
'/tmp/foo' asFilename writeStream |
615 | 2820 |
" |
5720 | 2821 |
|
2822 |
" |
|
2823 |
|s| |
|
2824 |
||
2825 |
s := '/tmp/foo' asFilename writeStream. |
|
2826 |
s nextPutAll:'1234567890'. |
|
2827 |
s close. |
|
2828 |
||
2829 |
s := '/tmp/foo' asFilename writeStream. |
|
2830 |
s nextPutAll:'12345'. |
|
2831 |
s close. |
|
2832 |
||
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2833 |
'/tmp/foo' asFilename contents |
5720 | 2834 |
" |
615 | 2835 |
! ! |
2836 |
||
8140
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2837 |
!Filename methodsFor:'file access - migration'! |
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2838 |
|
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2839 |
appendingWriteStreamOrNil |
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2840 |
"return a stream for appending to the file represented by the receiver. |
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2841 |
If the file does not already exist, it is created; |
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2842 |
if it does exist, writes are appended at the end. |
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2843 |
|
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2844 |
Return nil, if the file cannot be opened. |
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2845 |
Use this method for migration of old smalltalk code that expects a nil return code |
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2846 |
instead of an exception when an error occurs." |
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2847 |
|
8280
0caa2f092e45
avoid expensive full-blocks (which return)
Claus Gittinger <cg@exept.de>
parents:
8243
diff
changeset
|
2848 |
^ [ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2849 |
FileStream appendingOldFileNamed:(self osNameForAccess) |
8280
0caa2f092e45
avoid expensive full-blocks (which return)
Claus Gittinger <cg@exept.de>
parents:
8243
diff
changeset
|
2850 |
] on:FileStream openErrorSignal do:[:ex| nil]. |
8140
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2851 |
! |
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2852 |
|
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2853 |
newReadWriteStreamOrNil |
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2854 |
"return a stream for read/write the file represented by the receiver. |
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2855 |
If the file does not already exist, it is created; |
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2856 |
if it does exist, it is truncated. |
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2857 |
|
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2858 |
Return nil, if the file cannot be opened. |
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2859 |
Use this method for migration of old smalltalk code that expects a nil return code |
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2860 |
instead of an exception when an error occurs." |
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2861 |
|
8280
0caa2f092e45
avoid expensive full-blocks (which return)
Claus Gittinger <cg@exept.de>
parents:
8243
diff
changeset
|
2862 |
^ [ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2863 |
FileStream newFileNamed:(self osNameForAccess) |
8280
0caa2f092e45
avoid expensive full-blocks (which return)
Claus Gittinger <cg@exept.de>
parents:
8243
diff
changeset
|
2864 |
] on:FileStream openErrorSignal do:[:ex|nil]. |
8140
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2865 |
! |
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2866 |
|
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2867 |
readStreamOrNil |
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2868 |
"return a stream for reading from the file represented by the receiver. |
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2869 |
If the file does not already exist, nil is returned. |
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2870 |
|
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2871 |
Return nil, if the file cannot be opened. |
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2872 |
Use this method for migration of old smalltalk code that expects a nil return code |
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2873 |
instead of an exception when an error occurs." |
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2874 |
|
8280
0caa2f092e45
avoid expensive full-blocks (which return)
Claus Gittinger <cg@exept.de>
parents:
8243
diff
changeset
|
2875 |
^ [ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2876 |
FileStream readonlyFileNamed:(self osNameForAccess) |
8280
0caa2f092e45
avoid expensive full-blocks (which return)
Claus Gittinger <cg@exept.de>
parents:
8243
diff
changeset
|
2877 |
] on:FileStream openErrorSignal do:[:ex|nil]. |
8140
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2878 |
|
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2879 |
" |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2880 |
'/tmp/foo' asFilename readStreamOrNil |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2881 |
'/tmp/foo' asFilename readStream |
8140
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2882 |
" |
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2883 |
! |
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2884 |
|
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2885 |
readWriteStreamOrNil |
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2886 |
"return a stream for read/write the file represented by the receiver. |
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2887 |
If the file does not already exist, it is created. |
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2888 |
If the file does exist, it is NOT truncated, but rewritten at the beginning |
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2889 |
|
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2890 |
Return nil, if the file cannot be opened. |
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2891 |
Use this method for migration of old smalltalk code that expects a nil return code |
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2892 |
instead of an exception when an error occurs." |
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2893 |
|
8280
0caa2f092e45
avoid expensive full-blocks (which return)
Claus Gittinger <cg@exept.de>
parents:
8243
diff
changeset
|
2894 |
^ [ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2895 |
FileStream fileNamed:(self osNameForAccess) |
8280
0caa2f092e45
avoid expensive full-blocks (which return)
Claus Gittinger <cg@exept.de>
parents:
8243
diff
changeset
|
2896 |
] on:FileStream openErrorSignal do:[:ex|^ nil]. |
8140
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2897 |
! |
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2898 |
|
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2899 |
writeStreamOrNil |
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2900 |
"return a stream for writing to the file represented by the receiver. |
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2901 |
If the file does not already exist, it is created; |
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2902 |
if it does exist, it is truncated. |
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2903 |
|
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2904 |
Return nil, if the file cannot be opened. |
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2905 |
Use this method for migration of old smalltalk code that expects a nil return code |
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2906 |
instead of an exception when an error occurs." |
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2907 |
|
8280
0caa2f092e45
avoid expensive full-blocks (which return)
Claus Gittinger <cg@exept.de>
parents:
8243
diff
changeset
|
2908 |
^ [ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2909 |
FileStream newFileForWritingNamed:(self osNameForAccess) |
8280
0caa2f092e45
avoid expensive full-blocks (which return)
Claus Gittinger <cg@exept.de>
parents:
8243
diff
changeset
|
2910 |
] on:FileStream openErrorSignal do:[:ex|^ nil]. |
8140
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2911 |
|
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2912 |
|
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2913 |
" |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2914 |
'/etc/foo' asFilename writeStreamOrNil |
8140
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2915 |
" |
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2916 |
! ! |
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2917 |
|
16310 | 2918 |
!Filename methodsFor:'file access rights'! |
615 | 2919 |
|
12529 | 2920 |
accessRights |
2921 |
"return the access rights of the file as opaque data |
|
2922 |
(SmallInteger in unix/linux)" |
|
2923 |
||
2924 |
^ OperatingSystem accessModeOf:self osNameForFile. |
|
2925 |
||
2926 |
" |
|
2927 |
'Make.proto' asFilename accessRights |
|
2928 |
" |
|
2929 |
! |
|
2930 |
||
2931 |
accessRights:opaqueData |
|
2932 |
"set the access rights of the file to opaqueData, |
|
2933 |
which is normally retrieved by Filename>>#accessRights." |
|
2934 |
||
2935 |
(OperatingSystem changeAccessModeOf:self osNameForFile to:opaqueData) ifFalse:[ |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2936 |
^ self accessDeniedError:self |
12529 | 2937 |
]. |
2938 |
||
2939 |
" |
|
2940 |
|rights| |
|
2941 |
||
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2942 |
rights := 'Make.proto' asFilename accessRights. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2943 |
'Make.proto' asFilename accessRights:rights. |
12529 | 2944 |
" |
2945 |
||
2946 |
"Modified: / 5.5.1999 / 13:41:21 / cg" |
|
2947 |
! |
|
2948 |
||
615 | 2949 |
addAccessRights:aCollection |
2950 |
"add the access rights as specified in aCollection for the file represented |
|
2951 |
by the receiver. The argument must be a collection of symbols, |
|
2952 |
such as #readUser, #writeGroup etc." |
|
2953 |
||
2922 | 2954 |
|access osName| |
2955 |
||
2947 | 2956 |
osName := self osNameForFile. |
2922 | 2957 |
access := OperatingSystem accessModeOf:osName. |
615 | 2958 |
aCollection do:[:accessSymbol | |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2959 |
access := access bitOr:(OperatingSystem accessMaskFor:accessSymbol). |
615 | 2960 |
]. |
2922 | 2961 |
(OperatingSystem changeAccessModeOf:osName to:access) ifFalse:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2962 |
^ self accessDeniedError:self |
615 | 2963 |
] |
2964 |
||
2965 |
" |
|
2966 |
'foo' asFilename writeStream close. |
|
2967 |
'foo' asFilename addAccessRights:#(readUser readGroup readOthers). |
|
2968 |
'foo' asFilename addAccessRights:#(writeUser writeGroup writeOthers). |
|
2969 |
'foo' asFilename addAccessRights:#(executeUser executeGroup executeOthers). |
|
2970 |
" |
|
2971 |
! |
|
2972 |
||
6223 | 2973 |
makeExecutable |
2974 |
"make the file executable - you must have permission to do so. |
|
2975 |
For directories, execution means: 'allow changing into it'" |
|
2976 |
||
2977 |
^ self addAccessRights:#(executeUser) |
|
2978 |
||
2979 |
"Created: 9.1.1996 / 15:32:47 / cg" |
|
2980 |
! |
|
2981 |
||
2982 |
makeExecutableForAll |
|
2983 |
"make the file executable for all - you must have permission to do so. |
|
2984 |
For directories, execution means: 'allow changing into it'" |
|
2985 |
||
2986 |
^ self addAccessRights:#(executeUser executeGroup executeOthers) |
|
2987 |
||
2988 |
"Created: 9.1.1996 / 15:32:28 / cg" |
|
2989 |
! |
|
2990 |
||
2991 |
makeExecutableForGroup |
|
2992 |
"make the file executable for the group - you must have permission to do so. |
|
2993 |
For directories, execution means: 'allow changing into it'" |
|
2994 |
||
2995 |
^ self addAccessRights:#(executeGroup) |
|
2996 |
||
2997 |
"Created: 9.1.1996 / 15:32:28 / cg" |
|
2998 |
! |
|
2999 |
||
3000 |
makeReadable |
|
3001 |
"make the file readable for the owner - you must have permission to do so." |
|
3002 |
||
3003 |
^ self addAccessRights:#(readUser) |
|
3004 |
! |
|
3005 |
||
3006 |
makeReadableForAll |
|
3007 |
"make the file readable for all - you must have permission to do so." |
|
3008 |
||
3009 |
^ self addAccessRights:#(readUser readGroup readOthers) |
|
3010 |
! |
|
3011 |
||
3012 |
makeReadableForGroup |
|
3013 |
"make the file readable for the group - you must have permission to do so." |
|
3014 |
||
3015 |
^ self addAccessRights:#(readGroup) |
|
3016 |
! |
|
3017 |
||
3018 |
makeUnwritable |
|
3019 |
"make the file unwritable for all - you must have permission to do so." |
|
3020 |
||
3021 |
^ self removeAccessRights:#(writeUser writeGroup writeOthers) |
|
3022 |
! |
|
3023 |
||
3024 |
makeWritable |
|
3025 |
"make the file writableable for all - you must have permission to do so." |
|
3026 |
||
3027 |
^ self addAccessRights:#(writeUser) |
|
3028 |
! |
|
3029 |
||
3030 |
makeWritableForAll |
|
3031 |
"make the file writable for all - you must have permission to do so." |
|
3032 |
||
3033 |
^ self addAccessRights:#(writeUser writeGroup writeOthers) |
|
3034 |
! |
|
3035 |
||
3036 |
makeWritableForGroup |
|
3037 |
"make the file writable for the group - you must have permission to do so." |
|
3038 |
||
3039 |
^ self addAccessRights:#(writeGroup) |
|
3040 |
! |
|
3041 |
||
3042 |
removeAccessRights:aCollection |
|
3043 |
"remove the access rights as specified in aCollection for the file represented |
|
3044 |
by the receiver. The argument must be a collection of symbols, |
|
3045 |
such as #readUser, #writeGroup etc. |
|
3046 |
Raises an exception if not successful." |
|
3047 |
||
3048 |
|access osName| |
|
3049 |
||
3050 |
osName := self osNameForFile. |
|
3051 |
access := OperatingSystem accessModeOf:osName. |
|
3052 |
aCollection do:[:accessSymbol | |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3053 |
access := access bitAnd:(OperatingSystem accessMaskFor:accessSymbol) bitInvert. |
6223 | 3054 |
]. |
3055 |
(OperatingSystem changeAccessModeOf:osName to:access) ifFalse:[ |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3056 |
^ self accessDeniedError:self |
6223 | 3057 |
]. |
3058 |
||
3059 |
" |
|
3060 |
'foo' asFilename writeStream close. |
|
3061 |
'foo' asFilename removeAccessRights:#(readUser readGroup readOthers). |
|
3062 |
'foo' asFilename removeAccessRights:#(writeUser writeGroup writeOthers). |
|
3063 |
'foo' asFilename removeAccessRights:#(executeUser executeGroup executeOthers). |
|
3064 |
" |
|
3065 |
||
3066 |
"Modified: / 5.5.1999 / 13:41:21 / cg" |
|
3067 |
! |
|
3068 |
||
3069 |
symbolicAccessRights |
|
3070 |
"return the access rights of the file as a aCollection of access symbols. |
|
3071 |
The returned collection consists of symbols like: |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3072 |
#readUser, #writeGroup etc." |
6223 | 3073 |
|
3074 |
|access osName| |
|
3075 |
||
3076 |
osName := self osNameForFile. |
|
3077 |
access := OperatingSystem accessModeOf:osName. |
|
3078 |
||
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3079 |
^ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3080 |
#( readUser writeUser executeUser |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3081 |
readGroup writeGroup executeGroup |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3082 |
readOthers writeOthers executeOthers |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3083 |
) select:[:eachSymbolicAccessSymbol | |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3084 |
access bitTest:(OperatingSystem accessMaskFor:eachSymbolicAccessSymbol). |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3085 |
]. |
6223 | 3086 |
|
3087 |
" |
|
3088 |
'Makefile' asFilename symbolicAccessRights |
|
3089 |
" |
|
3090 |
||
3091 |
"Modified: / 5.5.1999 / 13:41:21 / cg" |
|
3092 |
! |
|
3093 |
||
3094 |
symbolicAccessRights:aCollectionOfSymbols |
|
3095 |
"set the access rights of the file given a aCollection of access symbols. |
|
3096 |
The collection must consist of symbols like: |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3097 |
#readUser, #writeGroup etc." |
6223 | 3098 |
|
3099 |
|access osName| |
|
3100 |
||
3101 |
osName := self osNameForFile. |
|
3102 |
access := aCollectionOfSymbols inject:0 into:[:bitsSoFar :eachSymbolicAccessSymbol | |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3103 |
bitsSoFar bitOr:(OperatingSystem accessMaskFor:eachSymbolicAccessSymbol) |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3104 |
]. |
6223 | 3105 |
|
3106 |
(OperatingSystem changeAccessModeOf:osName to:access) ifFalse:[ |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3107 |
^ self accessDeniedError:self |
6223 | 3108 |
]. |
3109 |
||
3110 |
" |
|
3111 |
|rights| |
|
3112 |
||
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3113 |
rights := 'Makefile' asFilename symbolicAccessRights. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3114 |
'Makefile' asFilename symbolicAccessRights:(rights , #(executeOthers)). |
6223 | 3115 |
" |
3116 |
||
3117 |
"Modified: / 5.5.1999 / 13:41:21 / cg" |
|
3118 |
! ! |
|
3119 |
||
3120 |
!Filename methodsFor:'file operations'! |
|
3121 |
||
7329 | 3122 |
appendTo:newNameOrStream |
3123 |
"append the file - the argument must be convertable to a filename. |
|
3124 |
Raises an exception, if an error occurs." |
|
3125 |
||
3126 |
|inStream outStream outStreamToClose| |
|
3127 |
||
3128 |
inStream := self readStream. |
|
3129 |
[ |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3130 |
newNameOrStream isStream ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3131 |
outStream := newNameOrStream. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3132 |
] ifFalse:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3133 |
outStream := outStreamToClose := newNameOrStream asFilename appendingWriteStream. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3134 |
]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3135 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3136 |
inStream binary. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3137 |
outStream binary. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3138 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3139 |
[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3140 |
inStream copyToEndInto:outStream. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3141 |
] on:OsError do:[:ex| |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3142 |
^ self fileCreationError:newNameOrStream |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3143 |
] |
7329 | 3144 |
] ensure:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3145 |
inStream close. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3146 |
outStreamToClose notNil ifTrue:[outStreamToClose close]. |
7329 | 3147 |
]. |
3148 |
||
3149 |
" |
|
3150 |
'/etc/group' asFilename appendTo:'/tmp/Makefile.foo'. |
|
3151 |
'Makefile' asFilename appendTo:'/tmp/Makefile.foo' |
|
3152 |
'Makefile' asFilename copyTo:'/' |
|
3153 |
'smalltalk' asFilename copyTo:'/dev/null' |
|
3154 |
" |
|
3155 |
||
3156 |
"Modified: / 23.12.1999 / 21:52:36 / cg" |
|
3157 |
! |
|
3158 |
||
2982 | 3159 |
basicMakeDirectory |
19440 | 3160 |
"create a directory with the receiver's name. |
2982 | 3161 |
Return true if successful, false if not." |
3162 |
||
3163 |
^ OperatingSystem createDirectory:(self osNameForDirectory) |
|
3164 |
! |
|
3165 |
||
10020 | 3166 |
copyTo:newNameArg |
16578 | 3167 |
"Copy the file's contents into another file. |
9235 | 3168 |
The argument must be convertable to a filename. |
4148
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3169 |
Raises an exception, if an error occurs." |
615 | 3170 |
|
12529 | 3171 |
|newName inStream outStream newNameAlreadyExists| |
10020 | 3172 |
|
3173 |
newName := newNameArg asFilename. |
|
6804
caf6a4521d4c
added utility: ExternalStream >> copyToEndInto:
Claus Gittinger <cg@exept.de>
parents:
6803
diff
changeset
|
3174 |
|
8535 | 3175 |
"Contents is not copied if newName represent same file as me." |
10020 | 3176 |
newName asAbsoluteFilename = self asAbsoluteFilename ifTrue: [ ^ self ]. |
8535 | 3177 |
|
615 | 3178 |
inStream := self readStream. |
17143 | 3179 |
inStream isNil ifTrue:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3180 |
"open failed, but somenone did a proceed for the OpenError. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3181 |
Ignore this file but continue in order to copy the rest when |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3182 |
doing a recursive copy" |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3183 |
^ self. |
17143 | 3184 |
]. |
3185 |
||
6804
caf6a4521d4c
added utility: ExternalStream >> copyToEndInto:
Claus Gittinger <cg@exept.de>
parents:
6803
diff
changeset
|
3186 |
[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3187 |
newNameAlreadyExists := newName exists. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3188 |
outStream := newName writeStream. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3189 |
newNameAlreadyExists ifFalse:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3190 |
[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3191 |
"would be nice to keep the access rights of the original test suite" |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3192 |
newName accessRights:self accessRights. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3193 |
] on:OperatingSystem accessDeniedErrorSignal do:[:ex| |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3194 |
"ignore the error - may occure when copying to a network drive" |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3195 |
]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3196 |
]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3197 |
inStream binary; buffered:false. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3198 |
outStream binary; buffered:false. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3199 |
inStream copyToEndInto:outStream. |
6804
caf6a4521d4c
added utility: ExternalStream >> copyToEndInto:
Claus Gittinger <cg@exept.de>
parents:
6803
diff
changeset
|
3200 |
] ensure:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3201 |
inStream close. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3202 |
outStream notNil ifTrue:[outStream close]. |
615 | 3203 |
]. |
3204 |
||
3205 |
" |
|
12529 | 3206 |
'Make.proto' asFilename copyTo:'/tmp/Makefile.foo' |
3207 |
'Make.proto' asFilename copyTo:'/' |
|
615 | 3208 |
'smalltalk' asFilename copyTo:'/dev/null' |
3209 |
" |
|
4148
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3210 |
|
10020 | 3211 |
"Modified: / 10-09-2004 / 09:49:28 / janfrog" |
3212 |
"Modified: / 29-09-2006 / 16:26:32 / cg" |
|
615 | 3213 |
! |
3214 |
||
15465 | 3215 |
copyToStream:outStream |
16578 | 3216 |
"Copy the file's contents into another file. |
15465 | 3217 |
The argument must be convertable to a filename. |
3218 |
Raises an exception, if an error occurs." |
|
3219 |
||
15858 | 3220 |
|inStream resetBinary| |
15465 | 3221 |
|
3222 |
"Contents is not copied if newName represent same file as me." |
|
3223 |
outStream isFileStream ifTrue:[ |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3224 |
outStream fileName asAbsoluteFilename = self asAbsoluteFilename ifTrue: [ ^ self ]. |
15465 | 3225 |
]. |
3226 |
||
3227 |
inStream := self readStream. |
|
3228 |
[ |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3229 |
inStream binary"; buffered:false". |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3230 |
resetBinary := false. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3231 |
outStream isBinary ifFalse:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3232 |
outStream binary. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3233 |
resetBinary := true. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3234 |
]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3235 |
inStream copyToEndInto:outStream. |
15465 | 3236 |
] ensure:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3237 |
inStream close. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3238 |
resetBinary ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3239 |
outStream text. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3240 |
]. |
15465 | 3241 |
]. |
3242 |
||
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3243 |
" |
15465 | 3244 |
|out| |
3245 |
out := FileStream newTemporary. |
|
3246 |
'Make.proto' asFilename copyToStream:out. |
|
3247 |
out reset; contents |
|
3248 |
" |
|
3249 |
! |
|
3250 |
||
6983 | 3251 |
createAsEmptyFile |
19440 | 3252 |
"create an empty file with the receiver's name. |
6983 | 3253 |
Raises an exception if not successful |
3254 |
(either already existing or creation not possible)" |
|
3255 |
||
3256 |
|writeStream| |
|
3257 |
||
3258 |
self exists ifTrue:[ |
|
19599 | 3259 |
OperatingSystem accessDeniedErrorSignal |
3260 |
raiseRequestWith:self |
|
3261 |
errorString:(' - file exists: ' , self asString). |
|
3262 |
^ self |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3263 |
]. |
6983 | 3264 |
|
3265 |
FileStream openErrorSignal handle:[:ex| |
|
19599 | 3266 |
self fileCreationError:self. |
3267 |
^ self |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3268 |
] do:[ |
19599 | 3269 |
writeStream := self newReadWriteStream. |
6983 | 3270 |
]. |
3271 |
writeStream close. |
|
3272 |
! |
|
3273 |
||
17143 | 3274 |
createAsSymbolicLinkTo:linkFilenameString |
19440 | 3275 |
"create a directory with the receiver's name. |
17143 | 3276 |
Raises an exception if not successful" |
3277 |
||
3278 |
OperatingSystem createSymbolicLinkFrom:linkFilenameString to:self pathName. |
|
3279 |
||
3280 |
" |
|
19599 | 3281 |
'/tmp/link' asFilename makeSymbolicLinkTo:'bla' |
17143 | 3282 |
" |
3283 |
! |
|
3284 |
||
615 | 3285 |
delete |
3286 |
"remove the file - same as remove, for ST-80 compatibility" |
|
3287 |
||
3288 |
self remove |
|
3289 |
! |
|
3290 |
||
3291 |
makeDirectory |
|
19440 | 3292 |
"create a directory with the receiver's name. |
4148
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3293 |
Raises an exception if not successful" |
615 | 3294 |
|
2982 | 3295 |
(self basicMakeDirectory) ifFalse:[ |
19599 | 3296 |
"/ |
3297 |
"/ could have existed before ... |
|
3298 |
"/ |
|
3299 |
(self exists and:[self isDirectory]) ifFalse:[ |
|
3300 |
self fileCreationError:self. |
|
3301 |
^ false |
|
3302 |
] |
|
2982 | 3303 |
]. |
3304 |
^ true |
|
1970 | 3305 |
|
4148
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3306 |
"Modified: / 5.5.1999 / 13:36:33 / cg" |
615 | 3307 |
! |
3308 |
||
6996
720a54a2a358
move now also supports recursive directory moves
Claus Gittinger <cg@exept.de>
parents:
6995
diff
changeset
|
3309 |
moveFileTo:newName |
720a54a2a358
move now also supports recursive directory moves
Claus Gittinger <cg@exept.de>
parents:
6995
diff
changeset
|
3310 |
"copy the file represented by the receiver, then delete it. |
720a54a2a358
move now also supports recursive directory moves
Claus Gittinger <cg@exept.de>
parents:
6995
diff
changeset
|
3311 |
This is different to renaming in case of cross device moves. |
720a54a2a358
move now also supports recursive directory moves
Claus Gittinger <cg@exept.de>
parents:
6995
diff
changeset
|
3312 |
Raise an exception if not successful. |
720a54a2a358
move now also supports recursive directory moves
Claus Gittinger <cg@exept.de>
parents:
6995
diff
changeset
|
3313 |
(Notice, that a rename is tried first, in case of non-cross device move)" |
720a54a2a358
move now also supports recursive directory moves
Claus Gittinger <cg@exept.de>
parents:
6995
diff
changeset
|
3314 |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3315 |
[self renameTo:newName] |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3316 |
on:OsError |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3317 |
do:[:ex | |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3318 |
ex creator == OperatingSystem fileNotFoundErrorSignal ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3319 |
ex reject |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3320 |
]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3321 |
self safeCopyTo:newName. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3322 |
self remove |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3323 |
]. |
6996
720a54a2a358
move now also supports recursive directory moves
Claus Gittinger <cg@exept.de>
parents:
6995
diff
changeset
|
3324 |
|
720a54a2a358
move now also supports recursive directory moves
Claus Gittinger <cg@exept.de>
parents:
6995
diff
changeset
|
3325 |
" |
720a54a2a358
move now also supports recursive directory moves
Claus Gittinger <cg@exept.de>
parents:
6995
diff
changeset
|
3326 |
|f s| |
720a54a2a358
move now also supports recursive directory moves
Claus Gittinger <cg@exept.de>
parents:
6995
diff
changeset
|
3327 |
|
720a54a2a358
move now also supports recursive directory moves
Claus Gittinger <cg@exept.de>
parents:
6995
diff
changeset
|
3328 |
f := '/tmp/foo' asFilename. |
720a54a2a358
move now also supports recursive directory moves
Claus Gittinger <cg@exept.de>
parents:
6995
diff
changeset
|
3329 |
s := f writeStream. |
720a54a2a358
move now also supports recursive directory moves
Claus Gittinger <cg@exept.de>
parents:
6995
diff
changeset
|
3330 |
s nextPutLine:'hello'. |
720a54a2a358
move now also supports recursive directory moves
Claus Gittinger <cg@exept.de>
parents:
6995
diff
changeset
|
3331 |
s close. |
720a54a2a358
move now also supports recursive directory moves
Claus Gittinger <cg@exept.de>
parents:
6995
diff
changeset
|
3332 |
f renameTo:'./foo' |
720a54a2a358
move now also supports recursive directory moves
Claus Gittinger <cg@exept.de>
parents:
6995
diff
changeset
|
3333 |
" |
720a54a2a358
move now also supports recursive directory moves
Claus Gittinger <cg@exept.de>
parents:
6995
diff
changeset
|
3334 |
|
720a54a2a358
move now also supports recursive directory moves
Claus Gittinger <cg@exept.de>
parents:
6995
diff
changeset
|
3335 |
" |
720a54a2a358
move now also supports recursive directory moves
Claus Gittinger <cg@exept.de>
parents:
6995
diff
changeset
|
3336 |
|f s| |
720a54a2a358
move now also supports recursive directory moves
Claus Gittinger <cg@exept.de>
parents:
6995
diff
changeset
|
3337 |
|
720a54a2a358
move now also supports recursive directory moves
Claus Gittinger <cg@exept.de>
parents:
6995
diff
changeset
|
3338 |
f := '/tmp/foo' asFilename. |
720a54a2a358
move now also supports recursive directory moves
Claus Gittinger <cg@exept.de>
parents:
6995
diff
changeset
|
3339 |
s := f writeStream. |
720a54a2a358
move now also supports recursive directory moves
Claus Gittinger <cg@exept.de>
parents:
6995
diff
changeset
|
3340 |
s nextPutLine:'hello'. |
720a54a2a358
move now also supports recursive directory moves
Claus Gittinger <cg@exept.de>
parents:
6995
diff
changeset
|
3341 |
s close. |
720a54a2a358
move now also supports recursive directory moves
Claus Gittinger <cg@exept.de>
parents:
6995
diff
changeset
|
3342 |
f moveTo:'./foo' |
720a54a2a358
move now also supports recursive directory moves
Claus Gittinger <cg@exept.de>
parents:
6995
diff
changeset
|
3343 |
" |
720a54a2a358
move now also supports recursive directory moves
Claus Gittinger <cg@exept.de>
parents:
6995
diff
changeset
|
3344 |
! |
720a54a2a358
move now also supports recursive directory moves
Claus Gittinger <cg@exept.de>
parents:
6995
diff
changeset
|
3345 |
|
16490 | 3346 |
moveTo:newNameArg |
615 | 3347 |
"copy the file represented by the receiver, then delete it. |
3348 |
This is different to renaming in case of cross device moves. |
|
5594
3d801043be3f
dont read the whole directory in #directoryContentsDo:
Claus Gittinger <cg@exept.de>
parents:
5577
diff
changeset
|
3349 |
Raise an exception if not successful. |
3d801043be3f
dont read the whole directory in #directoryContentsDo:
Claus Gittinger <cg@exept.de>
parents:
5577
diff
changeset
|
3350 |
(Notice, that a rename is tried first, in case of non-cross device move)" |
615 | 3351 |
|
16490 | 3352 |
|newName| |
3353 |
||
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3354 |
newName := newNameArg asFilename. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3355 |
[self renameTo:newName] |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3356 |
on:(OSErrorHolder inappropriateReferentSignal) |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3357 |
do:[:ex | |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3358 |
"handle renames accross device boundaries (Unix. cross device link)" |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3359 |
self isDirectory ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3360 |
self recursiveMoveDirectoryTo:newName. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3361 |
] ifFalse:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3362 |
self safeCopyTo:newName. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3363 |
self remove. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3364 |
]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3365 |
]. |
5507
e8c61b1741c6
in #moveTo: - try a link first, then do a copy-remove.
Claus Gittinger <cg@exept.de>
parents:
5303
diff
changeset
|
3366 |
|
e8c61b1741c6
in #moveTo: - try a link first, then do a copy-remove.
Claus Gittinger <cg@exept.de>
parents:
5303
diff
changeset
|
3367 |
" |
e8c61b1741c6
in #moveTo: - try a link first, then do a copy-remove.
Claus Gittinger <cg@exept.de>
parents:
5303
diff
changeset
|
3368 |
|f s| |
e8c61b1741c6
in #moveTo: - try a link first, then do a copy-remove.
Claus Gittinger <cg@exept.de>
parents:
5303
diff
changeset
|
3369 |
|
e8c61b1741c6
in #moveTo: - try a link first, then do a copy-remove.
Claus Gittinger <cg@exept.de>
parents:
5303
diff
changeset
|
3370 |
f := '/tmp/foo' asFilename. |
e8c61b1741c6
in #moveTo: - try a link first, then do a copy-remove.
Claus Gittinger <cg@exept.de>
parents:
5303
diff
changeset
|
3371 |
s := f writeStream. |
e8c61b1741c6
in #moveTo: - try a link first, then do a copy-remove.
Claus Gittinger <cg@exept.de>
parents:
5303
diff
changeset
|
3372 |
s nextPutLine:'hello'. |
e8c61b1741c6
in #moveTo: - try a link first, then do a copy-remove.
Claus Gittinger <cg@exept.de>
parents:
5303
diff
changeset
|
3373 |
s close. |
e8c61b1741c6
in #moveTo: - try a link first, then do a copy-remove.
Claus Gittinger <cg@exept.de>
parents:
5303
diff
changeset
|
3374 |
f renameTo:'./foo' |
e8c61b1741c6
in #moveTo: - try a link first, then do a copy-remove.
Claus Gittinger <cg@exept.de>
parents:
5303
diff
changeset
|
3375 |
" |
e8c61b1741c6
in #moveTo: - try a link first, then do a copy-remove.
Claus Gittinger <cg@exept.de>
parents:
5303
diff
changeset
|
3376 |
|
e8c61b1741c6
in #moveTo: - try a link first, then do a copy-remove.
Claus Gittinger <cg@exept.de>
parents:
5303
diff
changeset
|
3377 |
" |
e8c61b1741c6
in #moveTo: - try a link first, then do a copy-remove.
Claus Gittinger <cg@exept.de>
parents:
5303
diff
changeset
|
3378 |
|f s| |
e8c61b1741c6
in #moveTo: - try a link first, then do a copy-remove.
Claus Gittinger <cg@exept.de>
parents:
5303
diff
changeset
|
3379 |
|
e8c61b1741c6
in #moveTo: - try a link first, then do a copy-remove.
Claus Gittinger <cg@exept.de>
parents:
5303
diff
changeset
|
3380 |
f := '/tmp/foo' asFilename. |
e8c61b1741c6
in #moveTo: - try a link first, then do a copy-remove.
Claus Gittinger <cg@exept.de>
parents:
5303
diff
changeset
|
3381 |
s := f writeStream. |
e8c61b1741c6
in #moveTo: - try a link first, then do a copy-remove.
Claus Gittinger <cg@exept.de>
parents:
5303
diff
changeset
|
3382 |
s nextPutLine:'hello'. |
e8c61b1741c6
in #moveTo: - try a link first, then do a copy-remove.
Claus Gittinger <cg@exept.de>
parents:
5303
diff
changeset
|
3383 |
s close. |
e8c61b1741c6
in #moveTo: - try a link first, then do a copy-remove.
Claus Gittinger <cg@exept.de>
parents:
5303
diff
changeset
|
3384 |
f moveTo:'./foo' |
e8c61b1741c6
in #moveTo: - try a link first, then do a copy-remove.
Claus Gittinger <cg@exept.de>
parents:
5303
diff
changeset
|
3385 |
" |
4148
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3386 |
! |
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3387 |
|
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3388 |
recursiveCopyTo:destination |
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3389 |
"if I represent a regular file, copy it. |
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3390 |
Otherwise, copy the directory and recursively |
12975 | 3391 |
all of its subfiles/subdirectories. |
17143 | 3392 |
|
3393 |
Raises an exception if not successful. |
|
3394 |
Do not resolve symbolic links. |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3395 |
If a whole directory is to be copied and the destination directory |
17143 | 3396 |
does not exist, it will be created." |
3397 |
||
3398 |
|ok destinationFilename| |
|
3399 |
||
3400 |
destinationFilename := destination asFilename. |
|
4148
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3401 |
self isDirectory ifFalse:[ |
19599 | 3402 |
destinationFilename isDirectory ifTrue:[ |
3403 |
destinationFilename := destinationFilename construct:self baseName. |
|
3404 |
]. |
|
3405 |
self copyTo:destinationFilename. |
|
3406 |
^ self. |
|
4148
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3407 |
]. |
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3408 |
|
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3409 |
"/ typically, an 'cp -r' is faster; |
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3410 |
"/ however, if the command fails (or the OS does not support it), |
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3411 |
"/ fallBack doing a manual directory walk. |
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3412 |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3413 |
ok := OperatingSystem |
19599 | 3414 |
recursiveCopyDirectory:(self osNameForDirectory) |
3415 |
to:(destinationFilename osNameForDirectory). |
|
4148
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3416 |
|
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3417 |
ok ifFalse:[ |
19599 | 3418 |
self recursiveCopyWithoutOSCommandTo:destinationFilename |
3419 |
]. |
|
3420 |
||
3421 |
" |
|
3422 |
'.' asFilename recursiveCopyTo:'/temp/xxx'. |
|
17143 | 3423 |
" |
3424 |
||
12975 | 3425 |
"Created: / 05-05-1999 / 13:35:01 / cg" |
3426 |
"Modified: / 31-05-1999 / 13:11:34 / cg" |
|
3427 |
"Modified: / 29-07-2010 / 12:41:06 / sr" |
|
4148
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3428 |
! |
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3429 |
|
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3430 |
recursiveCopyWithoutOSCommandTo:destination |
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3431 |
"if I represent a regular file, copy it. |
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3432 |
Otherwise, copy the directory and all of its subfiles/subdirectories. |
11192
828184f29182
recursiveCopyWithoutOSCommandTo: - if target does not exist,
Claus Gittinger <cg@exept.de>
parents:
11004
diff
changeset
|
3433 |
This one walks down the directory hierarchy, not using any OS command to do the copy. |
17143 | 3434 |
Raises an exception if not successful. |
3435 |
||
3436 |
Do not resolve symbolic links. |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3437 |
If a whole directory is to be copied and the destination directory |
17143 | 3438 |
does not exist, it will be created." |
4148
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3439 |
|
12529 | 3440 |
|destinationFilename| |
3441 |
||
3442 |
destinationFilename := destination asFilename. |
|
4148
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3443 |
|
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3444 |
self isDirectory ifTrue:[ |
19599 | 3445 |
destinationFilename exists ifFalse:[ |
3446 |
destinationFilename makeDirectory. |
|
3447 |
destinationFilename accessRights:self accessRights. |
|
3448 |
]. |
|
3449 |
||
3450 |
self directoryContentsDo:[:aFilenameString | |
|
3451 |
|src srcInfo dst info| |
|
3452 |
||
3453 |
src := self construct:aFilenameString. |
|
3454 |
dst := destinationFilename construct:aFilenameString. |
|
3455 |
||
3456 |
srcInfo := src linkInfo. |
|
3457 |
srcInfo isDirectory ifTrue:[ |
|
3458 |
src recursiveCopyWithoutOSCommandTo:dst |
|
3459 |
] ifFalse:[srcInfo isSymbolicLink ifTrue:[ |
|
3460 |
dst |
|
3461 |
remove; |
|
3462 |
createAsSymbolicLinkTo:src linkInfo path. |
|
3463 |
] ifFalse:[ |
|
3464 |
src copyTo:dst. |
|
3465 |
]]. |
|
3466 |
]. |
|
4148
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3467 |
] ifFalse:[ |
19599 | 3468 |
destinationFilename isDirectory ifTrue:[ |
3469 |
destinationFilename := destinationFilename construct:self baseName. |
|
3470 |
]. |
|
3471 |
self copyTo:destinationFilename. |
|
4148
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3472 |
] |
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3473 |
|
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3474 |
" |
18952 | 3475 |
'.' asFilename recursiveCopyWithoutOSCommandTo:'/temp/xxx'. |
4148
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3476 |
'smalltalk.rc' asFilename recursiveCopyWithoutOSCommandTo:'/tmp/xxx'. |
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3477 |
" |
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3478 |
|
4246 | 3479 |
"Modified: / 31.5.1999 / 18:12:31 / cg" |
615 | 3480 |
! |
3481 |
||
659 | 3482 |
recursiveMakeDirectory |
18490 | 3483 |
"create a directory with the receiver's name and all required intermediate |
659 | 3484 |
directories. |
4148
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3485 |
Raises an exception if not successful." |
659 | 3486 |
|
2922 | 3487 |
(OperatingSystem recursiveCreateDirectory:(self osNameForDirectory)) ifFalse:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3488 |
^ self fileCreationError:self |
659 | 3489 |
] |
3490 |
||
4148
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3491 |
"Created: / 27.11.1995 / 23:36:40 / cg" |
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3492 |
"Modified: / 5.5.1999 / 13:38:42 / cg" |
659 | 3493 |
! |
3494 |
||
6997 | 3495 |
recursiveMoveDirectoryTo:newName |
3496 |
"recursively copy the directory represented by the receiver, then delete it. |
|
3497 |
This is different to renaming in case of cross device moves. |
|
3498 |
Raise an exception if not successful. |
|
3499 |
(Notice, that a rename is tried first, in case of non-cross device move)" |
|
3500 |
||
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3501 |
[self renameTo:newName] |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3502 |
on:OsError |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3503 |
do:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3504 |
self recursiveCopyTo:newName. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3505 |
self recursiveRemove |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3506 |
]. |
6997 | 3507 |
! |
3508 |
||
615 | 3509 |
recursiveRemove |
3299
5abe74e42d94
recursiveRemove is now done without OS support.
Claus Gittinger <cg@exept.de>
parents:
3171
diff
changeset
|
3510 |
"if I represent a regular file, remove it. |
5abe74e42d94
recursiveRemove is now done without OS support.
Claus Gittinger <cg@exept.de>
parents:
3171
diff
changeset
|
3511 |
Otherwise, remove the directory and all of its subfiles/subdirectories. |
4148
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3512 |
Raise an exception if not successful." |
615 | 3513 |
|
3514 |
|ok| |
|
3515 |
||
3302 | 3516 |
"/ typically, an 'rm -rf' is faster and removes better; |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3517 |
"/ however, if the command fails (or the OS does not support it), |
4148
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3518 |
"/ fallBack doing a manual directory walk. |
3302 | 3519 |
|
3520 |
ok := OperatingSystem recursiveRemoveDirectory:(self osNameForDirectory). |
|
3521 |
ok ifFalse:[ |
|
19599 | 3522 |
self recursiveRemoveWithoutOSCommand |
18952 | 3523 |
]. |
3524 |
||
3525 |
" |
|
3526 |
'foo/bar' asFilename recursiveMakeDirectory. |
|
3527 |
'foo' asFilename remove. |
|
3528 |
self assert:('foo' asFilename exists not). |
|
3529 |
||
3530 |
||
3531 |
'foo' asFilename recursiveRemove. |
|
3532 |
'foo/bar' asFilename recursiveMakeDirectory. |
|
3533 |
'foo' asFilename recursiveRemove. |
|
3534 |
self assert:('foo' asFilename exists not). |
|
3302 | 3535 |
" |
3536 |
||
3537 |
"Created: / 14.11.1995 / 11:19:29 / cg" |
|
4148
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3538 |
"Modified: / 5.5.1999 / 13:43:35 / cg" |
3302 | 3539 |
! |
3540 |
||
13246 | 3541 |
recursiveRemoveAll |
13247
9e47a0e73ba4
comment/format in: #recursiveRemoveAll
Claus Gittinger <cg@exept.de>
parents:
13246
diff
changeset
|
3542 |
"Remove all of my subfiles/subdirectories. |
3302 | 3543 |
Raise an error if not successful. |
3544 |
This one walks down the directory hierarchy, not using any OS |
|
3545 |
command to do the remove." |
|
3299
5abe74e42d94
recursiveRemove is now done without OS support.
Claus Gittinger <cg@exept.de>
parents:
3171
diff
changeset
|
3546 |
|
18952 | 3547 |
|removeFailedError| |
4939 | 3548 |
|
3299
5abe74e42d94
recursiveRemove is now done without OS support.
Claus Gittinger <cg@exept.de>
parents:
3171
diff
changeset
|
3549 |
self isDirectory ifTrue:[ |
19599 | 3550 |
removeFailedError := OperatingSystem accessDeniedErrorSignal. |
3551 |
self directoryContentsAsFilenamesDo:[:eachFilename | |
|
3552 |
removeFailedError handle:[:ex | |
|
3553 |
eachFilename isDirectory ifFalse:[ ex reject ]. |
|
3554 |
eachFilename |
|
3555 |
recursiveRemoveAll; |
|
3556 |
removeDirectory. |
|
3557 |
] do:[ |
|
3558 |
eachFilename remove |
|
3559 |
]. |
|
18952 | 3560 |
|
3561 |
"/ eachFilename isDirectory ifTrue:[ |
|
3562 |
"/ eachFilename recursiveRemoveWithoutOSCommand |
|
3563 |
"/ ] ifFalse:[ |
|
3564 |
"/ eachFilename remove |
|
3565 |
"/ ]. |
|
19599 | 3566 |
] |
615 | 3567 |
]. |
13246 | 3568 |
|
3569 |
" |
|
3570 |
'foo' asFilename makeDirectory. |
|
3571 |
'foo/bar' asFilename writeStream close. |
|
3572 |
'foo' asFilename remove |
|
3573 |
" |
|
3574 |
" |
|
3575 |
'foo' asFilename makeDirectory. |
|
3576 |
'foo/bar' asFilename writeStream close. |
|
18952 | 3577 |
'foo' asFilename recursiveRemove. |
3578 |
self assert:('foo' asFilename exists not). |
|
13246 | 3579 |
" |
3580 |
||
3581 |
"Created: / 25-01-2011 / 16:42:15 / cg" |
|
3582 |
! |
|
3583 |
||
3584 |
recursiveRemoveWithoutOSCommand |
|
3585 |
"if I represent a regular file, remove it. |
|
3586 |
Otherwise, remove the directory and all of its subfiles/subdirectories. |
|
3587 |
Raise an error if not successful. |
|
3588 |
This one walks down the directory hierarchy, not using any OS |
|
3589 |
command to do the remove." |
|
3590 |
||
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3591 |
self |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3592 |
recursiveRemoveAll; |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3593 |
remove. |
615 | 3594 |
|
3595 |
" |
|
3596 |
'foo' asFilename makeDirectory. |
|
3597 |
'foo/bar' asFilename writeStream close. |
|
4940 | 3598 |
'foo' asFilename remove |
615 | 3599 |
" |
3600 |
" |
|
3601 |
'foo' asFilename makeDirectory. |
|
3602 |
'foo/bar' asFilename writeStream close. |
|
4940 | 3603 |
'foo' asFilename recursiveRemove |
615 | 3604 |
" |
3605 |
||
13246 | 3606 |
"Created: / 25-02-1998 / 19:50:40 / cg" |
13949 | 3607 |
"Modified: / 19-01-2012 / 17:18:28 / cg" |
615 | 3608 |
! |
3609 |
||
3610 |
remove |
|
845 | 3611 |
"remove the file/directory. |
4148
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3612 |
Raises an exception if not successful. |
845 | 3613 |
Use #recursiveRemove in order to (recursively) remove non empty directories." |
615 | 3614 |
|
8741 | 3615 |
|linkInfo osName ok| |
3616 |
||
18952 | 3617 |
osName := self osNameForAccess. |
3618 |
ok := OperatingSystem removeFile:osName. |
|
3619 |
ok ifFalse:[ |
|
19599 | 3620 |
linkInfo := self linkInfo. |
3621 |
linkInfo isNil ifTrue:[ |
|
3622 |
"file does not exist - no error" |
|
3623 |
^ self. |
|
3624 |
] ifFalse:[linkInfo isDirectory ifTrue:[ |
|
3625 |
ok := OperatingSystem removeDirectory:osName |
|
3626 |
]]. |
|
3627 |
ok ifFalse:[ |
|
3628 |
self exists ifTrue:[ |
|
3629 |
self removeError:self pathName |
|
3630 |
] |
|
3631 |
] |
|
615 | 3632 |
]. |
3633 |
||
3634 |
" |
|
3635 |
(FileStream newFileNamed:'foo') close. |
|
3636 |
'foo' asFilename remove |
|
3637 |
" |
|
3638 |
||
3639 |
" |
|
3640 |
'foo' asFilename makeDirectory. |
|
3641 |
'foo/bar' asFilename writeStream close. |
|
8738 | 3642 |
'foo' asFilename remove. 'expect an exception' |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3643 |
'foo' asFilename recursiveRemove. |
615 | 3644 |
" |
3645 |
||
13793
3f1c660956ce
added: #new_recursiveRemoveAll
Claus Gittinger <cg@exept.de>
parents:
13781
diff
changeset
|
3646 |
"Modified: / 20-11-1997 / 17:40:22 / stefan" |
3f1c660956ce
added: #new_recursiveRemoveAll
Claus Gittinger <cg@exept.de>
parents:
13781
diff
changeset
|
3647 |
"Modified: / 11-10-2011 / 10:20:01 / cg" |
615 | 3648 |
! |
3649 |
||
5595
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3650 |
removeDirectory |
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3651 |
"remove the directory. |
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3652 |
Raises an exception if not successful (or if its not a directory). |
5596 | 3653 |
Use #remove if it is not known if the receiver is a directory or file. |
5595
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3654 |
Use #recursiveRemove in order to (recursively) remove non empty directories." |
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3655 |
|
18952 | 3656 |
(OperatingSystem removeDirectory:(self osNameForAccess)) ifFalse:[ |
19599 | 3657 |
self exists ifFalse:[ ^ self]. |
3658 |
self removeError:self |
|
5595
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3659 |
]. |
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3660 |
|
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3661 |
" |
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3662 |
(FileStream newFileNamed:'foo') close. |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3663 |
'foo' asFilename removeDirectory |
5595
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3664 |
" |
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3665 |
|
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3666 |
" |
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3667 |
'foo' asFilename writeStream close. |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3668 |
'foo' asFilename removeDirectory |
5595
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3669 |
" |
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3670 |
|
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3671 |
" |
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3672 |
'foo' asFilename makeDirectory. |
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3673 |
'foo/bar' asFilename writeStream close. |
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3674 |
('foo' asFilename remove) ifFalse:[ |
19599 | 3675 |
Transcript showCR:'could not remove foo' |
5595
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3676 |
] |
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3677 |
" |
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3678 |
|
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3679 |
"Modified: / 20.11.1997 / 17:40:22 / stefan" |
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3680 |
"Modified: / 5.5.1999 / 13:41:12 / cg" |
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3681 |
! |
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3682 |
|
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3683 |
removeFile |
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3684 |
"remove the file. |
5596 | 3685 |
Raises an exception if not successful (or if its not a file). |
3686 |
Use #remove if it is not known if the receiver is a directory or file. |
|
3687 |
Use #recursiveRemove in order to (recursively) remove non empty directories." |
|
5595
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3688 |
|
18952 | 3689 |
(OperatingSystem removeFile:self osNameForAccess) ifFalse:[ |
19599 | 3690 |
self exists ifTrue:[ |
3691 |
self removeError:self |
|
3692 |
]. |
|
5595
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3693 |
]. |
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3694 |
|
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3695 |
" |
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3696 |
(FileStream newFileNamed:'foo') close. |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3697 |
'foo' asFilename removeFile |
5595
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3698 |
" |
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3699 |
|
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3700 |
" |
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3701 |
'foo' asFilename makeDirectory. |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3702 |
'foo' asFilename removeFile |
5595
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3703 |
" |
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3704 |
! |
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3705 |
|
16490 | 3706 |
renameTo:newNameArg |
671 | 3707 |
"rename the file - the argument must be convertable to a String. |
15823 | 3708 |
Raises an exception if not successful. |
3709 |
If newName already exists, it will be replaced by myself." |
|
615 | 3710 |
|
16490 | 3711 |
|errno newName| |
3712 |
||
3713 |
newName := newNameArg asFilename. |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3714 |
(OperatingSystem |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3715 |
renameFile:(self osNameForFile) |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3716 |
to:(newName osNameForFile) |
2922 | 3717 |
) ifFalse:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3718 |
errno := OperatingSystem lastErrorNumber. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3719 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3720 |
self exists ifFalse:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3721 |
^ self fileNotFoundError:self |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3722 |
]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3723 |
(OperatingSystem errorHolderForNumber:errno) |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3724 |
parameter:newName; |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3725 |
reportError. |
615 | 3726 |
]. |
3727 |
||
3728 |
" |
|
3729 |
'/tmp/foo' asFilename renameTo:'/tmp/bar' |
|
3730 |
" |
|
4148
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3731 |
|
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3732 |
"Modified: / 5.5.1999 / 13:41:27 / cg" |
932
f57ec42ceb44
added interface to truncate & ftruncate (req. by Mr. Olberding)
Claus Gittinger <cg@exept.de>
parents:
883
diff
changeset
|
3733 |
! |
f57ec42ceb44
added interface to truncate & ftruncate (req. by Mr. Olberding)
Claus Gittinger <cg@exept.de>
parents:
883
diff
changeset
|
3734 |
|
15819 | 3735 |
safeCopyTo:newNameArg |
16578 | 3736 |
"Copy the file's contents into another file. |
15819 | 3737 |
Do it safe in an atomic operation shich makes sure that no partially written file appears. |
3738 |
The argument must be convertable to a filename. |
|
3739 |
Raises an exception, if an error occurs." |
|
3740 |
||
15823 | 3741 |
|newName inStream accessRights tempStream| |
15819 | 3742 |
|
3743 |
newName := newNameArg asFilename. |
|
3744 |
||
3745 |
"Contents is not copied if newName represent same file as me." |
|
3746 |
newName asAbsoluteFilename = self asAbsoluteFilename ifTrue: [ ^ self ]. |
|
3747 |
||
3748 |
inStream := self readStream. |
|
15823 | 3749 |
newName exists ifTrue:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3750 |
accessRights := newName accessRights. |
15819 | 3751 |
] ifFalse:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3752 |
accessRights := self accessRights. |
15819 | 3753 |
]. |
3754 |
||
3755 |
[ |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3756 |
"let the temp filename start with a ~ to make it invisible" |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3757 |
tempStream := FileStream newTemporaryIn:newName directory osNameForFile nameTemplate:'~%1_%2'. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3758 |
[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3759 |
"would be nice to keep the access rights of the original file" |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3760 |
tempStream fileName accessRights:accessRights. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3761 |
] on:OperatingSystem accessDeniedErrorSignal do:[:ex| |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3762 |
"ignore the error - may occure when copying to a network drive" |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3763 |
]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3764 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3765 |
inStream binary; buffered:false. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3766 |
tempStream binary; buffered:false. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3767 |
[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3768 |
inStream copyToEndInto:tempStream. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3769 |
] ifCurtailed:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3770 |
tempStream close. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3771 |
tempStream fileName remove. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3772 |
tempStream := nil. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3773 |
]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3774 |
tempStream syncData. |
15819 | 3775 |
] ensure:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3776 |
inStream close. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3777 |
tempStream notNil ifTrue:[tempStream close]. |
15819 | 3778 |
]. |
3779 |
tempStream fileName renameTo:newName. |
|
3780 |
||
3781 |
" |
|
3782 |
'Make.proto' asFilename safeCopyTo:'/tmp/Makefile.foo' |
|
3783 |
'Make.proto' asFilename safeCopyTo:'/' |
|
3784 |
'smalltalk' asFilename safeCopyTo:'/xxxxxxxxxxxxxxxx/bla' |
|
3785 |
" |
|
3786 |
||
3787 |
"Modified: / 10-09-2004 / 09:49:28 / janfrog" |
|
3788 |
"Modified: / 29-09-2006 / 16:26:32 / cg" |
|
3789 |
! |
|
3790 |
||
932
f57ec42ceb44
added interface to truncate & ftruncate (req. by Mr. Olberding)
Claus Gittinger <cg@exept.de>
parents:
883
diff
changeset
|
3791 |
truncateTo:newSize |
16578 | 3792 |
"change the file's size. |
4148
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3793 |
This may not be supported on all operating systems |
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3794 |
(raises an exception, if not)" |
932
f57ec42ceb44
added interface to truncate & ftruncate (req. by Mr. Olberding)
Claus Gittinger <cg@exept.de>
parents:
883
diff
changeset
|
3795 |
|
7888
e76fa60251dc
Remove obsolete nil-checks after opening streams
Stefan Vogel <sv@exept.de>
parents:
7846
diff
changeset
|
3796 |
(OperatingSystem truncateFile:self osNameForFile to:newSize) ifFalse:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3797 |
^ self reportError:'unsupported operation' with:self |
932
f57ec42ceb44
added interface to truncate & ftruncate (req. by Mr. Olberding)
Claus Gittinger <cg@exept.de>
parents:
883
diff
changeset
|
3798 |
] |
f57ec42ceb44
added interface to truncate & ftruncate (req. by Mr. Olberding)
Claus Gittinger <cg@exept.de>
parents:
883
diff
changeset
|
3799 |
|
f57ec42ceb44
added interface to truncate & ftruncate (req. by Mr. Olberding)
Claus Gittinger <cg@exept.de>
parents:
883
diff
changeset
|
3800 |
" |
f57ec42ceb44
added interface to truncate & ftruncate (req. by Mr. Olberding)
Claus Gittinger <cg@exept.de>
parents:
883
diff
changeset
|
3801 |
|s| |
f57ec42ceb44
added interface to truncate & ftruncate (req. by Mr. Olberding)
Claus Gittinger <cg@exept.de>
parents:
883
diff
changeset
|
3802 |
|
f57ec42ceb44
added interface to truncate & ftruncate (req. by Mr. Olberding)
Claus Gittinger <cg@exept.de>
parents:
883
diff
changeset
|
3803 |
s := 'test' asFilename writeStream. |
f57ec42ceb44
added interface to truncate & ftruncate (req. by Mr. Olberding)
Claus Gittinger <cg@exept.de>
parents:
883
diff
changeset
|
3804 |
s next:1000 put:$1. |
f57ec42ceb44
added interface to truncate & ftruncate (req. by Mr. Olberding)
Claus Gittinger <cg@exept.de>
parents:
883
diff
changeset
|
3805 |
s close. |
7888
e76fa60251dc
Remove obsolete nil-checks after opening streams
Stefan Vogel <sv@exept.de>
parents:
7846
diff
changeset
|
3806 |
('test' asFilename fileSize) printCR. |
932
f57ec42ceb44
added interface to truncate & ftruncate (req. by Mr. Olberding)
Claus Gittinger <cg@exept.de>
parents:
883
diff
changeset
|
3807 |
'test' asFilename truncateTo:100. |
7888
e76fa60251dc
Remove obsolete nil-checks after opening streams
Stefan Vogel <sv@exept.de>
parents:
7846
diff
changeset
|
3808 |
('test' asFilename fileSize) printCR. |
932
f57ec42ceb44
added interface to truncate & ftruncate (req. by Mr. Olberding)
Claus Gittinger <cg@exept.de>
parents:
883
diff
changeset
|
3809 |
" |
4148
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3810 |
|
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3811 |
"Modified: / 5.5.1999 / 13:41:59 / cg" |
615 | 3812 |
! ! |
3813 |
||
3814 |
!Filename methodsFor:'file queries'! |
|
3815 |
||
1532
6b4c38b9090c
added #modificationTime & #accessTime (easier to use than #dates)
Claus Gittinger <cg@exept.de>
parents:
1523
diff
changeset
|
3816 |
accessTime |
16578 | 3817 |
"return a timeStamp containing the file's last access time." |
1532
6b4c38b9090c
added #modificationTime & #accessTime (easier to use than #dates)
Claus Gittinger <cg@exept.de>
parents:
1523
diff
changeset
|
3818 |
|
3768
4801b87c1cd7
care for non-existing info in #accessTime, #modTime and #fileSize
Claus Gittinger <cg@exept.de>
parents:
3763
diff
changeset
|
3819 |
| i | |
4801b87c1cd7
care for non-existing info in #accessTime, #modTime and #fileSize
Claus Gittinger <cg@exept.de>
parents:
3763
diff
changeset
|
3820 |
|
4801b87c1cd7
care for non-existing info in #accessTime, #modTime and #fileSize
Claus Gittinger <cg@exept.de>
parents:
3763
diff
changeset
|
3821 |
(i := self info) isNil ifTrue:[^ nil]. |
6793
0d3e3fd18a70
modified -> modificationTime
Claus Gittinger <cg@exept.de>
parents:
6776
diff
changeset
|
3822 |
^ i accessTime |
1532
6b4c38b9090c
added #modificationTime & #accessTime (easier to use than #dates)
Claus Gittinger <cg@exept.de>
parents:
1523
diff
changeset
|
3823 |
|
6b4c38b9090c
added #modificationTime & #accessTime (easier to use than #dates)
Claus Gittinger <cg@exept.de>
parents:
1523
diff
changeset
|
3824 |
" |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3825 |
Filename currentDirectory accessTime |
1532
6b4c38b9090c
added #modificationTime & #accessTime (easier to use than #dates)
Claus Gittinger <cg@exept.de>
parents:
1523
diff
changeset
|
3826 |
" |
6b4c38b9090c
added #modificationTime & #accessTime (easier to use than #dates)
Claus Gittinger <cg@exept.de>
parents:
1523
diff
changeset
|
3827 |
|
3768
4801b87c1cd7
care for non-existing info in #accessTime, #modTime and #fileSize
Claus Gittinger <cg@exept.de>
parents:
3763
diff
changeset
|
3828 |
"Created: / 9.7.1996 / 10:19:15 / cg" |
4801b87c1cd7
care for non-existing info in #accessTime, #modTime and #fileSize
Claus Gittinger <cg@exept.de>
parents:
3763
diff
changeset
|
3829 |
"Modified: / 26.9.1997 / 13:05:51 / stefan" |
4801b87c1cd7
care for non-existing info in #accessTime, #modTime and #fileSize
Claus Gittinger <cg@exept.de>
parents:
3763
diff
changeset
|
3830 |
"Modified: / 17.8.1998 / 10:23:44 / cg" |
1532
6b4c38b9090c
added #modificationTime & #accessTime (easier to use than #dates)
Claus Gittinger <cg@exept.de>
parents:
1523
diff
changeset
|
3831 |
! |
6b4c38b9090c
added #modificationTime & #accessTime (easier to use than #dates)
Claus Gittinger <cg@exept.de>
parents:
1523
diff
changeset
|
3832 |
|
6977 | 3833 |
creationTime |
16578 | 3834 |
"return a timeStamp containing the file's creation time. |
6977 | 3835 |
NOTICE: only windoof distinguishes creation from modification; |
6978 | 3836 |
under unix, nil is returned (callers should fall back and use mod-time then" |
6977 | 3837 |
|
3838 |
|i| |
|
3839 |
||
3840 |
(i := self info) isNil ifTrue:[^ nil]. "/ non-existing |
|
6978 | 3841 |
^ i creationTime |
3842 |
||
3843 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3844 |
Filename currentDirectory creationTime |
6977 | 3845 |
" |
3846 |
||
3847 |
"Created: / 9.7.1996 / 10:18:59 / cg" |
|
3848 |
"Modified: / 26.9.1997 / 13:05:39 / stefan" |
|
3849 |
"Modified: / 14.8.1998 / 17:42:50 / cg" |
|
3850 |
! |
|
3851 |
||
615 | 3852 |
dates |
16578 | 3853 |
"return the file's modification and access times as an object (currently a dictionary) |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3854 |
that responds to the at: message with arguments |
615 | 3855 |
#modified, #accessed or #statusChanged." |
3856 |
||
2922 | 3857 |
|info dates osName| |
3858 |
||
2947 | 3859 |
osName := self osNameForAccess. |
2922 | 3860 |
info := OperatingSystem infoOf:osName. |
615 | 3861 |
info isNil ifTrue:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3862 |
"maybe this is a symbolic link with a broken link target. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3863 |
Answer the dates of the link itself" |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3864 |
info := OperatingSystem linkInfoOf:osName. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3865 |
info isNil ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3866 |
^ nil |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3867 |
] |
615 | 3868 |
]. |
3869 |
dates := IdentityDictionary new. |
|
6978 | 3870 |
dates at:#created put:(info creationTime). |
6793
0d3e3fd18a70
modified -> modificationTime
Claus Gittinger <cg@exept.de>
parents:
6776
diff
changeset
|
3871 |
dates at:#modified put:(info modificationTime). |
0d3e3fd18a70
modified -> modificationTime
Claus Gittinger <cg@exept.de>
parents:
6776
diff
changeset
|
3872 |
dates at:#accessed put:(info accessTime). |
0d3e3fd18a70
modified -> modificationTime
Claus Gittinger <cg@exept.de>
parents:
6776
diff
changeset
|
3873 |
dates at:#statusChanged put:(info statusChangeTime). |
615 | 3874 |
^ dates |
3875 |
||
3876 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3877 |
Filename currentDirectory dates |
615 | 3878 |
'../regression' asFilename dates |
3879 |
" |
|
1859
7f6040320daf
changes for new return from OS>>infoOf:
Claus Gittinger <cg@exept.de>
parents:
1614
diff
changeset
|
3880 |
|
7f6040320daf
changes for new return from OS>>infoOf:
Claus Gittinger <cg@exept.de>
parents:
1614
diff
changeset
|
3881 |
"Modified: 1.11.1996 / 20:19:24 / cg" |
615 | 3882 |
! |
3883 |
||
3884 |
fileSize |
|
3885 |
"return the size of the file in bytes" |
|
3886 |
||
3768
4801b87c1cd7
care for non-existing info in #accessTime, #modTime and #fileSize
Claus Gittinger <cg@exept.de>
parents:
3763
diff
changeset
|
3887 |
|i| |
4801b87c1cd7
care for non-existing info in #accessTime, #modTime and #fileSize
Claus Gittinger <cg@exept.de>
parents:
3763
diff
changeset
|
3888 |
|
4801b87c1cd7
care for non-existing info in #accessTime, #modTime and #fileSize
Claus Gittinger <cg@exept.de>
parents:
3763
diff
changeset
|
3889 |
(i := self info) isNil ifTrue:[^ nil]. |
6794
498d85323172
use #fileSize instead of #size
Claus Gittinger <cg@exept.de>
parents:
6793
diff
changeset
|
3890 |
^ i fileSize |
3768
4801b87c1cd7
care for non-existing info in #accessTime, #modTime and #fileSize
Claus Gittinger <cg@exept.de>
parents:
3763
diff
changeset
|
3891 |
|
4801b87c1cd7
care for non-existing info in #accessTime, #modTime and #fileSize
Claus Gittinger <cg@exept.de>
parents:
3763
diff
changeset
|
3892 |
"Modified: / 17.8.1998 / 10:23:46 / cg" |
615 | 3893 |
! |
3894 |
||
3895 |
fileType |
|
3896 |
"this returns a string describing the type of contents of |
|
3897 |
the file. This is done using the unix 'file' command, |
|
3898 |
(which usually is configurable by /etc/magic). |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3899 |
On non-unix systems, this may simply return 'file', |
2922 | 3900 |
not knowning about the contents. |
3901 |
Warning: |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3902 |
Since the returned string differs among systems (and language settings), |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3903 |
it is only useful for user-information; |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3904 |
NOT as a tag to be used by a program." |
3665 | 3905 |
|
16755 | 3906 |
|suffix baseNm info mime| |
3665 | 3907 |
|
3908 |
"/ since we cannot depend on a 'file' command being available, |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3909 |
"/ do the most obvious ones here. |
3665 | 3910 |
"/ (also useful since the 'file' command takes some time, and the code |
3911 |
"/ below is faster for common things like directories) |
|
1601
1d57e1047323
avoid calling 'file' for symbolic links & directories
Claus Gittinger <cg@exept.de>
parents:
1540
diff
changeset
|
3912 |
|
8477
c962d56c1973
#linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents:
8280
diff
changeset
|
3913 |
info := self linkInfo. |
9060 | 3914 |
info isNil ifTrue:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3915 |
^ 'removed' "/ could happen, when coming from a snapshot image |
9060 | 3916 |
]. |
3917 |
||
8477
c962d56c1973
#linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents:
8280
diff
changeset
|
3918 |
info isSymbolicLink ifTrue:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3919 |
^ 'symbolic link to ' , info path |
1601
1d57e1047323
avoid calling 'file' for symbolic links & directories
Claus Gittinger <cg@exept.de>
parents:
1540
diff
changeset
|
3920 |
]. |
8477
c962d56c1973
#linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents:
8280
diff
changeset
|
3921 |
info isDirectory ifTrue:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3922 |
self isReadable ifFalse:[^ 'directory, unreadable']. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3923 |
self isExecutable ifFalse:[^ 'directory, locked']. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3924 |
^ 'directory' |
2573 | 3925 |
]. |
8477
c962d56c1973
#linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents:
8280
diff
changeset
|
3926 |
info isCharacterSpecial ifTrue:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3927 |
^ 'character device special file' |
3665 | 3928 |
]. |
8477
c962d56c1973
#linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents:
8280
diff
changeset
|
3929 |
info isBlockSpecial ifTrue:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3930 |
^ 'block device special file' |
3665 | 3931 |
]. |
8477
c962d56c1973
#linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents:
8280
diff
changeset
|
3932 |
info isSocket ifTrue:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3933 |
^ 'socket' |
3665 | 3934 |
]. |
8477
c962d56c1973
#linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents:
8280
diff
changeset
|
3935 |
info isFifo ifTrue:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3936 |
^ 'fifo' |
8477
c962d56c1973
#linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents:
8280
diff
changeset
|
3937 |
]. |
3665 | 3938 |
|
1602 | 3939 |
self isReadable ifFalse:[^ 'unreadable']. |
8477
c962d56c1973
#linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents:
8280
diff
changeset
|
3940 |
info fileSize == 0 ifTrue:[^ 'empty']. |
1602 | 3941 |
|
17112 | 3942 |
"/ suffix := self suffix asLowercase. |
3943 |
"/ baseNm := self withoutSuffix baseName asLowercase. |
|
2922 | 3944 |
|
16755 | 3945 |
mime := self mimeTypeOfContents. |
3946 |
mime notNil ifTrue:[ |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3947 |
"/ kludge to avoid making libview a prereq. of libbasic |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3948 |
(Smalltalk at:#MIMETypes) notNil ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3949 |
info := (Smalltalk at:#MIMETypes) fileInfoForMimeType:mime. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3950 |
info notNil ifTrue:[^ info]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3951 |
]. |
1602 | 3952 |
]. |
2906 | 3953 |
^ 'file' |
615 | 3954 |
|
3955 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3956 |
'Makefile' asFilename fileType |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3957 |
'.' asFilename fileType |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3958 |
'/dev/null' asFilename fileType |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3959 |
'/usr/tmp' asFilename fileType |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3960 |
'/tmp/.X11-unix/X0' asFilename fileType |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3961 |
'smalltalk.rc' asFilename fileType |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3962 |
'bitmaps/SBrowser.xbm' asFilename fileType |
615 | 3963 |
" |
1601
1d57e1047323
avoid calling 'file' for symbolic links & directories
Claus Gittinger <cg@exept.de>
parents:
1540
diff
changeset
|
3964 |
|
3665 | 3965 |
"Modified: / 21.7.1998 / 11:25:56 / cg" |
615 | 3966 |
! |
3967 |
||
2836 | 3968 |
id |
16578 | 3969 |
"return the file's/directory's file-id (inode number)" |
2836 | 3970 |
|
2947 | 3971 |
^ OperatingSystem idOf:(self osNameForAccess) |
2836 | 3972 |
|
3973 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3974 |
Filename currentDirectory id |
2836 | 3975 |
" |
3976 |
||
3977 |
"Modified: 9.7.1996 / 10:19:27 / cg" |
|
3978 |
"Created: 5.8.1997 / 19:26:01 / cg" |
|
3979 |
! |
|
3980 |
||
615 | 3981 |
info |
16578 | 3982 |
"return some object filled with the file's info; |
1859
7f6040320daf
changes for new return from OS>>infoOf:
Claus Gittinger <cg@exept.de>
parents:
1614
diff
changeset
|
3983 |
the info (for which corresponding access methods are understood by |
7f6040320daf
changes for new return from OS>>infoOf:
Claus Gittinger <cg@exept.de>
parents:
1614
diff
changeset
|
3984 |
the returned object) is: |
7f6040320daf
changes for new return from OS>>infoOf:
Claus Gittinger <cg@exept.de>
parents:
1614
diff
changeset
|
3985 |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3986 |
type - a symbol giving the files fileType |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3987 |
mode - numeric access mode |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3988 |
uid - owners user id |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3989 |
gid - owners group id |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3990 |
size - files size |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3991 |
id - files number (i.e. inode number) |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3992 |
accessed - last access time (as osTime-stamp) |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3993 |
modified - last modification time (as osTime-stamp) |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3994 |
statusChangeTime - last staus change (as osTime-stamp) |
615 | 3995 |
|
1859
7f6040320daf
changes for new return from OS>>infoOf:
Claus Gittinger <cg@exept.de>
parents:
1614
diff
changeset
|
3996 |
Some of the fields may be returned as nil on systems which do not provide |
7f6040320daf
changes for new return from OS>>infoOf:
Claus Gittinger <cg@exept.de>
parents:
1614
diff
changeset
|
3997 |
all of the information. |
7f6040320daf
changes for new return from OS>>infoOf:
Claus Gittinger <cg@exept.de>
parents:
1614
diff
changeset
|
3998 |
The minimum returned info (i.e. on all OS's) will consist of at least: |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3999 |
modified |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4000 |
size |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4001 |
type |
615 | 4002 |
|
1859
7f6040320daf
changes for new return from OS>>infoOf:
Claus Gittinger <cg@exept.de>
parents:
1614
diff
changeset
|
4003 |
Dont expect things like uid/gid/mode to be non-nil; write your application |
7f6040320daf
changes for new return from OS>>infoOf:
Claus Gittinger <cg@exept.de>
parents:
1614
diff
changeset
|
4004 |
to either handle nil values, |
615 | 4005 |
or (better) use one of isXXXX query methods. (Be prepared for DOS ...) |
1859
7f6040320daf
changes for new return from OS>>infoOf:
Claus Gittinger <cg@exept.de>
parents:
1614
diff
changeset
|
4006 |
(i.e. instead of: |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4007 |
someFilename type == #directory |
1859
7f6040320daf
changes for new return from OS>>infoOf:
Claus Gittinger <cg@exept.de>
parents:
1614
diff
changeset
|
4008 |
use |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4009 |
someFilename isDirectory |
615 | 4010 |
" |
4011 |
||
2947 | 4012 |
^ OperatingSystem infoOf:(self osNameForAccess) |
615 | 4013 |
|
4014 |
" |
|
4015 |
Filename currentDirectory info |
|
3768
4801b87c1cd7
care for non-existing info in #accessTime, #modTime and #fileSize
Claus Gittinger <cg@exept.de>
parents:
3763
diff
changeset
|
4016 |
'/dev/null' asFilename info |
615 | 4017 |
'Make.proto' asFilename info |
3768
4801b87c1cd7
care for non-existing info in #accessTime, #modTime and #fileSize
Claus Gittinger <cg@exept.de>
parents:
3763
diff
changeset
|
4018 |
'source/Point.st' asFilename info |
4801b87c1cd7
care for non-existing info in #accessTime, #modTime and #fileSize
Claus Gittinger <cg@exept.de>
parents:
3763
diff
changeset
|
4019 |
'source/Point.st' asFilename linkInfo |
4801b87c1cd7
care for non-existing info in #accessTime, #modTime and #fileSize
Claus Gittinger <cg@exept.de>
parents:
3763
diff
changeset
|
4020 |
'../../libbasic/Point.st' asFilename info |
4801b87c1cd7
care for non-existing info in #accessTime, #modTime and #fileSize
Claus Gittinger <cg@exept.de>
parents:
3763
diff
changeset
|
4021 |
'.' asFilename info |
4801b87c1cd7
care for non-existing info in #accessTime, #modTime and #fileSize
Claus Gittinger <cg@exept.de>
parents:
3763
diff
changeset
|
4022 |
'..' asFilename info |
4801b87c1cd7
care for non-existing info in #accessTime, #modTime and #fileSize
Claus Gittinger <cg@exept.de>
parents:
3763
diff
changeset
|
4023 |
'..\..' asFilename info |
4801b87c1cd7
care for non-existing info in #accessTime, #modTime and #fileSize
Claus Gittinger <cg@exept.de>
parents:
3763
diff
changeset
|
4024 |
'..\..\..' asFilename info |
4801b87c1cd7
care for non-existing info in #accessTime, #modTime and #fileSize
Claus Gittinger <cg@exept.de>
parents:
3763
diff
changeset
|
4025 |
'..\..\..\..' asFilename info |
4801b87c1cd7
care for non-existing info in #accessTime, #modTime and #fileSize
Claus Gittinger <cg@exept.de>
parents:
3763
diff
changeset
|
4026 |
'c:\' asFilename info |
615 | 4027 |
" |
1859
7f6040320daf
changes for new return from OS>>infoOf:
Claus Gittinger <cg@exept.de>
parents:
1614
diff
changeset
|
4028 |
|
16272 | 4029 |
"Modified: / 17-08-1998 / 10:24:10 / cg" |
4030 |
"Modified (comment): / 21-03-2014 / 00:35:30 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
615 | 4031 |
! |
4032 |
||
4033 |
linkInfo |
|
16578 | 4034 |
"return the file's info. If it is a symbolic link return the info of the link itself |
8477
c962d56c1973
#linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents:
8280
diff
changeset
|
4035 |
instead of the link's target. |
615 | 4036 |
The information is the same as returned by #info, except that if the |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4037 |
receiver represents a symbolic link, the links information |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4038 |
is returned |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4039 |
(while in this case, #info returns the info of the target file, |
615 | 4040 |
which is accessed via the symbolic link). |
4041 |
||
4042 |
In addition to the normal entries, Unix returns an additional entry: |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4043 |
path -> the target files pathname |
615 | 4044 |
|
4045 |
See the comment in #info for more details." |
|
4046 |
||
2947 | 4047 |
^ OperatingSystem linkInfoOf:(self osNameForAccess) |
615 | 4048 |
|
4049 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4050 |
Filename currentDirectory linkInfo |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4051 |
'/dev/null' asFilename linkInfo |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4052 |
'Make.proto' asFilename linkInfo |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4053 |
'Make.proto' asFilename linkInfo path |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4054 |
'source/Point.st' asFilename linkInfo |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4055 |
'../../libbasic/Point.st' asFilename linkInfo |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4056 |
'/usr/tmp' asFilename linkInfo |
615 | 4057 |
" |
1862
e8f44f10f1ab
changes for new #infoOf: / #linkInfoOf: return
Claus Gittinger <cg@exept.de>
parents:
1859
diff
changeset
|
4058 |
|
e8f44f10f1ab
changes for new #infoOf: / #linkInfoOf: return
Claus Gittinger <cg@exept.de>
parents:
1859
diff
changeset
|
4059 |
"Modified: 1.11.1996 / 20:49:09 / cg" |
1532
6b4c38b9090c
added #modificationTime & #accessTime (easier to use than #dates)
Claus Gittinger <cg@exept.de>
parents:
1523
diff
changeset
|
4060 |
! |
6b4c38b9090c
added #modificationTime & #accessTime (easier to use than #dates)
Claus Gittinger <cg@exept.de>
parents:
1523
diff
changeset
|
4061 |
|
6b4c38b9090c
added #modificationTime & #accessTime (easier to use than #dates)
Claus Gittinger <cg@exept.de>
parents:
1523
diff
changeset
|
4062 |
modificationTime |
16578 | 4063 |
"return a timeStamp containing the file's modification time." |
1532
6b4c38b9090c
added #modificationTime & #accessTime (easier to use than #dates)
Claus Gittinger <cg@exept.de>
parents:
1523
diff
changeset
|
4064 |
|
3763
31d58d04ac15
care for nil-info in #modificationTime
Claus Gittinger <cg@exept.de>
parents:
3753
diff
changeset
|
4065 |
|i| |
31d58d04ac15
care for nil-info in #modificationTime
Claus Gittinger <cg@exept.de>
parents:
3753
diff
changeset
|
4066 |
|
31d58d04ac15
care for nil-info in #modificationTime
Claus Gittinger <cg@exept.de>
parents:
3753
diff
changeset
|
4067 |
(i := self info) isNil ifTrue:[^ nil]. "/ non-existing |
6793
0d3e3fd18a70
modified -> modificationTime
Claus Gittinger <cg@exept.de>
parents:
6776
diff
changeset
|
4068 |
^ i modificationTime |
1532
6b4c38b9090c
added #modificationTime & #accessTime (easier to use than #dates)
Claus Gittinger <cg@exept.de>
parents:
1523
diff
changeset
|
4069 |
|
6b4c38b9090c
added #modificationTime & #accessTime (easier to use than #dates)
Claus Gittinger <cg@exept.de>
parents:
1523
diff
changeset
|
4070 |
" |
6b4c38b9090c
added #modificationTime & #accessTime (easier to use than #dates)
Claus Gittinger <cg@exept.de>
parents:
1523
diff
changeset
|
4071 |
Filename currentDirectory modificationTime |
6b4c38b9090c
added #modificationTime & #accessTime (easier to use than #dates)
Claus Gittinger <cg@exept.de>
parents:
1523
diff
changeset
|
4072 |
" |
6b4c38b9090c
added #modificationTime & #accessTime (easier to use than #dates)
Claus Gittinger <cg@exept.de>
parents:
1523
diff
changeset
|
4073 |
|
3763
31d58d04ac15
care for nil-info in #modificationTime
Claus Gittinger <cg@exept.de>
parents:
3753
diff
changeset
|
4074 |
"Created: / 9.7.1996 / 10:18:59 / cg" |
31d58d04ac15
care for nil-info in #modificationTime
Claus Gittinger <cg@exept.de>
parents:
3753
diff
changeset
|
4075 |
"Modified: / 26.9.1997 / 13:05:39 / stefan" |
31d58d04ac15
care for nil-info in #modificationTime
Claus Gittinger <cg@exept.de>
parents:
3753
diff
changeset
|
4076 |
"Modified: / 14.8.1998 / 17:42:50 / cg" |
2836 | 4077 |
! |
4078 |
||
4079 |
type |
|
4080 |
"return the symbolic type of the file" |
|
4081 |
||
2947 | 4082 |
^ OperatingSystem typeOf:(self osNameForAccess) |
2836 | 4083 |
|
4084 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4085 |
Filename currentDirectory type |
2836 | 4086 |
" |
4087 |
||
4088 |
"Modified: 9.7.1996 / 10:19:27 / cg" |
|
4089 |
"Created: 5.8.1997 / 19:31:26 / cg" |
|
615 | 4090 |
! ! |
4091 |
||
4092 |
!Filename methodsFor:'file utilities'! |
|
4093 |
||
4094 |
edit |
|
4095 |
"start an editView on the file represented by the receiver" |
|
4096 |
||
4097 |
EditTextView openOn:self asString |
|
4098 |
||
4099 |
" |
|
4100 |
'smalltalk.rc' asFilename edit |
|
4101 |
" |
|
4102 |
! |
|
4103 |
||
4104 |
fileIn |
|
13424 | 4105 |
"load source code from the file" |
4106 |
||
4107 |
^ (ProgrammingLanguage forFile: self) fileIn: self |
|
4108 |
||
4109 |
"Modified: / 16-08-2009 / 13:27:36 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
542 | 4110 |
! ! |
4111 |
||
2 | 4112 |
!Filename methodsFor:'instance creation'! |
4113 |
||
10969
046b204c6ea2
New method: #/ as synonym of #construct:. Thanks to Jan Vrany, see Bug 823.
Stefan Vogel <sv@exept.de>
parents:
10902
diff
changeset
|
4114 |
/ subname |
046b204c6ea2
New method: #/ as synonym of #construct:. Thanks to Jan Vrany, see Bug 823.
Stefan Vogel <sv@exept.de>
parents:
10902
diff
changeset
|
4115 |
"Same as construct: Taking the receiver as a directory name, construct a new |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4116 |
filename for an entry within this directory |
10969
046b204c6ea2
New method: #/ as synonym of #construct:. Thanks to Jan Vrany, see Bug 823.
Stefan Vogel <sv@exept.de>
parents:
10902
diff
changeset
|
4117 |
(i.e. for a file or a subdirectory in that directory). |
046b204c6ea2
New method: #/ as synonym of #construct:. Thanks to Jan Vrany, see Bug 823.
Stefan Vogel <sv@exept.de>
parents:
10902
diff
changeset
|
4118 |
The argument may not specify an absolute path name. |
046b204c6ea2
New method: #/ as synonym of #construct:. Thanks to Jan Vrany, see Bug 823.
Stefan Vogel <sv@exept.de>
parents:
10902
diff
changeset
|
4119 |
Please do not use this to create filenames with suffixes, |
046b204c6ea2
New method: #/ as synonym of #construct:. Thanks to Jan Vrany, see Bug 823.
Stefan Vogel <sv@exept.de>
parents:
10902
diff
changeset
|
4120 |
since some systems require special naming conventions. |
046b204c6ea2
New method: #/ as synonym of #construct:. Thanks to Jan Vrany, see Bug 823.
Stefan Vogel <sv@exept.de>
parents:
10902
diff
changeset
|
4121 |
See also: #withSuffix: (which is different, but often needed). |
046b204c6ea2
New method: #/ as synonym of #construct:. Thanks to Jan Vrany, see Bug 823.
Stefan Vogel <sv@exept.de>
parents:
10902
diff
changeset
|
4122 |
Thanks to Jan Vrany for this idea." |
046b204c6ea2
New method: #/ as synonym of #construct:. Thanks to Jan Vrany, see Bug 823.
Stefan Vogel <sv@exept.de>
parents:
10902
diff
changeset
|
4123 |
|
046b204c6ea2
New method: #/ as synonym of #construct:. Thanks to Jan Vrany, see Bug 823.
Stefan Vogel <sv@exept.de>
parents:
10902
diff
changeset
|
4124 |
^ self construct:subname |
046b204c6ea2
New method: #/ as synonym of #construct:. Thanks to Jan Vrany, see Bug 823.
Stefan Vogel <sv@exept.de>
parents:
10902
diff
changeset
|
4125 |
|
046b204c6ea2
New method: #/ as synonym of #construct:. Thanks to Jan Vrany, see Bug 823.
Stefan Vogel <sv@exept.de>
parents:
10902
diff
changeset
|
4126 |
" |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4127 |
'/tmp' asFilename / 'foo' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4128 |
'/' asFilename / 'foo' / 'bar' / 'baz' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4129 |
'/foo/bar' asFilename / ('baz' asFilename) |
10969
046b204c6ea2
New method: #/ as synonym of #construct:. Thanks to Jan Vrany, see Bug 823.
Stefan Vogel <sv@exept.de>
parents:
10902
diff
changeset
|
4130 |
|
046b204c6ea2
New method: #/ as synonym of #construct:. Thanks to Jan Vrany, see Bug 823.
Stefan Vogel <sv@exept.de>
parents:
10902
diff
changeset
|
4131 |
Bad example; works on UNIX, but may not on others: |
046b204c6ea2
New method: #/ as synonym of #construct:. Thanks to Jan Vrany, see Bug 823.
Stefan Vogel <sv@exept.de>
parents:
10902
diff
changeset
|
4132 |
'foo/bar.baz' / '.suff' |
046b204c6ea2
New method: #/ as synonym of #construct:. Thanks to Jan Vrany, see Bug 823.
Stefan Vogel <sv@exept.de>
parents:
10902
diff
changeset
|
4133 |
" |
046b204c6ea2
New method: #/ as synonym of #construct:. Thanks to Jan Vrany, see Bug 823.
Stefan Vogel <sv@exept.de>
parents:
10902
diff
changeset
|
4134 |
! |
046b204c6ea2
New method: #/ as synonym of #construct:. Thanks to Jan Vrany, see Bug 823.
Stefan Vogel <sv@exept.de>
parents:
10902
diff
changeset
|
4135 |
|
615 | 4136 |
construct:subname |
4137 |
"taking the receiver as a directory name, construct a new |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4138 |
filename for an entry within this directory |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4139 |
(i.e. for a file or a subdirectory in that directory). |
2922 | 4140 |
The argument may not specify an absolute path name. |
4141 |
Please do not use this to create filenames with suffixes, |
|
4142 |
since some systems require special naming conventions. |
|
4143 |
See also: #withSuffix: (which is different, but often needed)." |
|
615 | 4144 |
|
11784 | 4145 |
|constructedName| |
4146 |
||
4147 |
constructedName := self constructString:subname. |
|
15811 | 4148 |
^ self species named:constructedName. |
615 | 4149 |
|
4150 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4151 |
'/tmp' asFilename construct:'foo' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4152 |
'/' asFilename construct:'foo' |
615 | 4153 |
'/usr/tmp' asFilename construct:'foo' |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4154 |
'/foo/bar' asFilename construct:'baz' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4155 |
'/foo/bar' asFilename construct:'baz' asFilename |
2922 | 4156 |
|
4157 |
Bad example; works on UNIX, but may not on others: |
|
11784 | 4158 |
'foo/bar.baz' asFilename construct:'.suff' |
615 | 4159 |
" |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4160 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4161 |
"Modified: 29.2.1996 / 20:55:06 / cg" |
2911 | 4162 |
! |
4163 |
||
2922 | 4164 |
constructDirectory:subname |
4165 |
"same as #construct: on most systems. |
|
4166 |
(may allow different/relaxed name syntax of the argument on some systems)" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4167 |
|
15811 | 4168 |
^ self species named:(self constructDirectoryString:subname) |
2922 | 4169 |
! |
4170 |
||
4171 |
constructDirectoryString:subName |
|
4172 |
"same as #constructString: on most systems. |
|
4173 |
(may allow different/relaxed name syntax of the argument on some systems)" |
|
4174 |
||
4175 |
^ self constructString:subName |
|
4176 |
! |
|
4177 |
||
4178 |
constructString:subName |
|
2911 | 4179 |
"taking the receiver as a directory name, construct a new |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4180 |
filename-string for an entry within this directory |
2922 | 4181 |
(i.e. for a file or a subdirectory in that directory). |
2960 | 4182 |
The argument may not specify an absolute path name. |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4183 |
The code below works for UNIX & MSDOS; |
2960 | 4184 |
other filename classes (i.e. VMS) may want to redefine this method." |
4185 |
||
4186 |
|sepString sub| |
|
4187 |
||
4188 |
sub := subName asString. |
|
15811 | 4189 |
sepString := self species separatorString. |
8243 | 4190 |
nameString size == 0 ifTrue:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4191 |
^ sub |
2911 | 4192 |
]. |
3677
51542c86ba2a
md's changes for msdos compatibility.
Claus Gittinger <cg@exept.de>
parents:
3666
diff
changeset
|
4193 |
(nameString endsWith:sepString) ifTrue:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4194 |
^ nameString , sub |
6247 | 4195 |
]. |
2960 | 4196 |
^ nameString , sepString , sub |
2911 | 4197 |
|
4198 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4199 |
'/tmp' asFilename constructString:'foo' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4200 |
'/' asFilename constructString:'foo' |
2911 | 4201 |
'/usr/tmp' asFilename constructString:'foo' |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4202 |
'/foo/bar' asFilename constructString:'baz' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4203 |
'' asFilename constructString:'baz' |
2911 | 4204 |
" |
4205 |
||
3677
51542c86ba2a
md's changes for msdos compatibility.
Claus Gittinger <cg@exept.de>
parents:
3666
diff
changeset
|
4206 |
"Modified: / 7.9.1995 / 10:15:22 / claus" |
51542c86ba2a
md's changes for msdos compatibility.
Claus Gittinger <cg@exept.de>
parents:
3666
diff
changeset
|
4207 |
"Created: / 9.9.1997 / 08:57:08 / cg" |
51542c86ba2a
md's changes for msdos compatibility.
Claus Gittinger <cg@exept.de>
parents:
3666
diff
changeset
|
4208 |
"Modified: / 20.1.1998 / 15:58:23 / md" |
51542c86ba2a
md's changes for msdos compatibility.
Claus Gittinger <cg@exept.de>
parents:
3666
diff
changeset
|
4209 |
"Modified: / 27.7.1998 / 19:47:51 / cg" |
2944
e1f1111afa12
Add #isImplicit to check for builtin dir names such as '.' and '..'.
Stefan Vogel <sv@exept.de>
parents:
2939
diff
changeset
|
4210 |
! |
e1f1111afa12
Add #isImplicit to check for builtin dir names such as '.' and '..'.
Stefan Vogel <sv@exept.de>
parents:
2939
diff
changeset
|
4211 |
|
e1f1111afa12
Add #isImplicit to check for builtin dir names such as '.' and '..'.
Stefan Vogel <sv@exept.de>
parents:
2939
diff
changeset
|
4212 |
filenameFor:fileName |
6973 | 4213 |
"return a filename representing the argument, fileName |
4214 |
either in myself (if the arg is a releative path) or absolute otherwise." |
|
2944
e1f1111afa12
Add #isImplicit to check for builtin dir names such as '.' and '..'.
Stefan Vogel <sv@exept.de>
parents:
2939
diff
changeset
|
4215 |
|
e1f1111afa12
Add #isImplicit to check for builtin dir names such as '.' and '..'.
Stefan Vogel <sv@exept.de>
parents:
2939
diff
changeset
|
4216 |
|f| |
e1f1111afa12
Add #isImplicit to check for builtin dir names such as '.' and '..'.
Stefan Vogel <sv@exept.de>
parents:
2939
diff
changeset
|
4217 |
|
e1f1111afa12
Add #isImplicit to check for builtin dir names such as '.' and '..'.
Stefan Vogel <sv@exept.de>
parents:
2939
diff
changeset
|
4218 |
f := fileName asFilename. |
e1f1111afa12
Add #isImplicit to check for builtin dir names such as '.' and '..'.
Stefan Vogel <sv@exept.de>
parents:
2939
diff
changeset
|
4219 |
f isAbsolute ifTrue:[^ f]. |
e1f1111afa12
Add #isImplicit to check for builtin dir names such as '.' and '..'.
Stefan Vogel <sv@exept.de>
parents:
2939
diff
changeset
|
4220 |
^ (self construct:fileName) |
e1f1111afa12
Add #isImplicit to check for builtin dir names such as '.' and '..'.
Stefan Vogel <sv@exept.de>
parents:
2939
diff
changeset
|
4221 |
|
e1f1111afa12
Add #isImplicit to check for builtin dir names such as '.' and '..'.
Stefan Vogel <sv@exept.de>
parents:
2939
diff
changeset
|
4222 |
" |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4223 |
'/tmp' asFilename filenameFor:'foo' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4224 |
'/tmp' asFilename filenameFor:'/foo' |
2944
e1f1111afa12
Add #isImplicit to check for builtin dir names such as '.' and '..'.
Stefan Vogel <sv@exept.de>
parents:
2939
diff
changeset
|
4225 |
" |
e1f1111afa12
Add #isImplicit to check for builtin dir names such as '.' and '..'.
Stefan Vogel <sv@exept.de>
parents:
2939
diff
changeset
|
4226 |
|
e1f1111afa12
Add #isImplicit to check for builtin dir names such as '.' and '..'.
Stefan Vogel <sv@exept.de>
parents:
2939
diff
changeset
|
4227 |
"Created: 18.9.1997 / 14:34:14 / stefan" |
9263 | 4228 |
! |
4229 |
||
4230 |
secureConstruct:subname |
|
4231 |
"taking the receiver as a directory name, construct a new |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4232 |
filename for an entry within this directory |
9263 | 4233 |
(i.e. for a file or a subdirectory in that directory). |
4234 |
The argument may not specify an absolute path name. |
|
4235 |
Please do not use this to create filenames with suffixes, |
|
4236 |
since some systems require special naming conventions. |
|
4237 |
See also: #withSuffix: (which is different, but often needed). |
|
4238 |
||
4239 |
This method differs from #construct:, by not permitting subName |
|
4240 |
to navigate above (via ..) the current filename." |
|
4241 |
||
15811 | 4242 |
^ self species named:(self secureConstructString:subname) |
9263 | 4243 |
|
4244 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4245 |
'/tmp' asFilename secureConstruct:'foo' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4246 |
'/tmp' asFilename secureConstruct:'../foo' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4247 |
'/tmp' asFilename secureConstruct:'/./foo' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4248 |
'/tmp' asFilename secureConstruct:'foo/../bar' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4249 |
'/' asFilename secureConstruct:'foo' |
9263 | 4250 |
'/usr/tmp' asFilename secureConstruct:'foo' |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4251 |
'/foo/bar' asFilename secureConstruct:'baz' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4252 |
'/foo/bar' asFilename secureConstruct:'baz' asFilename |
9263 | 4253 |
|
4254 |
Bad example; works on UNIX, but may not on others: |
|
4255 |
'foo/bar.baz' secureConstruct:'.suff' |
|
4256 |
" |
|
4257 |
||
4258 |
"Modified: 29.2.1996 / 20:55:06 / cg" |
|
4259 |
! |
|
4260 |
||
4261 |
secureConstructString:subName |
|
4262 |
"taking the receiver as a directory name, construct a new |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4263 |
filename-string for an entry within this directory |
9263 | 4264 |
(i.e. for a file or a subdirectory in that directory). |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4265 |
|
9263 | 4266 |
This method differs from #constructString, by not permitting subName |
4267 |
to navigate above (via ..) the current filename. |
|
4268 |
||
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4269 |
The code below works for UNIX & MSDOS; |
9263 | 4270 |
other filename classes (i.e. VMS) may want to redefine this method." |
4271 |
||
4272 |
|sepString sub normalizedPath pathStream| |
|
4273 |
||
15811 | 4274 |
sepString := self species separatorString. |
9263 | 4275 |
sub := subName asString. |
4276 |
||
4277 |
sub := sub asCollectionOfSubstringsSeparatedByAll:sepString. |
|
4278 |
normalizedPath := OrderedCollection new:sub size. |
|
4279 |
sub do:[:eachPathComponent| |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4280 |
eachPathComponent = '..' ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4281 |
normalizedPath isEmpty ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4282 |
self error:'secureConstruct: - trying to escape from: ', nameString. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4283 |
]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4284 |
normalizedPath removeLast. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4285 |
] ifFalse:[(eachPathComponent notEmpty and:[eachPathComponent ~= '.']) ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4286 |
normalizedPath add:eachPathComponent. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4287 |
]] |
9263 | 4288 |
]. |
18272 | 4289 |
pathStream := CharacterWriteStream with:nameString. |
9263 | 4290 |
(nameString notEmpty and:[(nameString endsWith:sepString) not]) ifTrue:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4291 |
pathStream nextPutAll:sepString. |
9263 | 4292 |
]. |
4293 |
normalizedPath do:[:eachPathComponent| |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4294 |
pathStream nextPutAll:eachPathComponent. |
9263 | 4295 |
] separatedBy:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4296 |
pathStream nextPutAll:sepString. |
9263 | 4297 |
]. |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4298 |
|
9263 | 4299 |
^ pathStream contents. |
4300 |
||
4301 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4302 |
'/tmp' asFilename secureConstructString:'fooÅ ' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4303 |
'/tmp' asFilename secureConstructString:'../foo' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4304 |
'/tmp' asFilename secureConstructString:'foo/../bla' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4305 |
'/tmp' asFilename secureConstructString:'foo/./bla' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4306 |
'/tmp' asFilename secureConstructString:'/bla/foo/../../foo' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4307 |
'/' asFilename secureConstructString:'foo' |
9263 | 4308 |
'/usr/tmp' asFilename secureConstructString:'foo' |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4309 |
'/foo/bar' asFilename secureConstructString:'baz' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4310 |
'' asFilename secureConstructString:'baz' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4311 |
'' asFilename secureConstructString:'/baz' |
9263 | 4312 |
" |
2 | 4313 |
! ! |
4314 |
||
195 | 4315 |
!Filename methodsFor:'misc'! |
4316 |
||
4317 |
, aString |
|
4318 |
"this allows filenames to understand how names are concatenated. |
|
14072 | 4319 |
Returns a string consisting of the receiver's name, concatenated |
195 | 4320 |
by aString. Notice this is NOT the same as construct:, which inserts |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4321 |
a directory delimiter and returns a new fileName instance. |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4322 |
See also: #withSuffix: which is new and better." |
195 | 4323 |
|
5866 | 4324 |
<resource:#obsolete> |
4325 |
||
2906 | 4326 |
self obsoleteMethodWarning:'use #construct:'. |
308 | 4327 |
^ (nameString , aString asString) |
195 | 4328 |
|
4329 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4330 |
'Makefile' asFilename , '.bak' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4331 |
('Makefile' asFilename , '.bak') asFilename |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4332 |
'Makefile' asFilename withSuffix:'bak' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4333 |
'Makefile' asFilename construct:'.bak' |
195 | 4334 |
" |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4335 |
|
14072 | 4336 |
"Modified: / 07-09-1997 / 23:45:36 / cg" |
4337 |
"Modified (comment): / 01-04-2012 / 13:18:21 / cg" |
|
9263 | 4338 |
! |
4339 |
||
4340 |
canonicalize |
|
4341 |
"normalize a filename by removing all empty path components or dots, |
|
4342 |
and by resolving parent directory '..' references. |
|
4343 |
||
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4344 |
The code below works for UNIX & MSDOS; |
9263 | 4345 |
other filename classes (i.e. VMS) may want to redefine this method." |
4346 |
||
15811 | 4347 |
nameString := self species canonicalize:nameString. |
9263 | 4348 |
|
4349 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4350 |
'/tmp/bla' asFilename canonicalize. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4351 |
'/tmp/bla/../fasel' asFilename canonicalize. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4352 |
'/tmp/bla/.././/fasel' asFilename canonicalize. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4353 |
'..' asFilename canonicalize. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4354 |
'bla/../fasel' asFilename canonicalize. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4355 |
'//bla/../fasel' asFilename canonicalize. |
9263 | 4356 |
" |
195 | 4357 |
! ! |
4358 |
||
14232 | 4359 |
!Filename methodsFor:'os shell'! |
4360 |
||
4361 |
openExplorer |
|
4362 |
"open a file-explorer on the directory represented by the receiver. |
|
4363 |
On non-windows systems, an error is raised" |
|
4364 |
||
4365 |
OperatingSystem isMSWINDOWSlike ifFalse:[ |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4366 |
self warn:'sorry - this operation is only available under windows'. |
14232 | 4367 |
]. |
4368 |
||
4369 |
OperatingSystem |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4370 |
openApplicationForDocument:self pathName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4371 |
operation:#explore. |
14232 | 4372 |
|
4373 |
"Created: / 21-07-2012 / 12:28:18 / cg" |
|
14804 | 4374 |
! |
4375 |
||
4376 |
openFinder |
|
4377 |
"open a finder on the directory represented by the receiver. |
|
4378 |
On non-osx systems, an error is raised" |
|
4379 |
||
4380 |
OperatingSystem isOSXlike ifFalse:[ |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4381 |
self warn:'sorry - this operation is only available under osx'. |
14804 | 4382 |
]. |
4383 |
||
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4384 |
OperatingSystem executeCommand:'open "',self pathName,'"' |
14804 | 4385 |
! |
4386 |
||
4387 |
openTerminal |
|
16545 | 4388 |
"open a terminal window on the directory represented by the receiver; |
4389 |
on osx, a terminal app is opened, |
|
4390 |
on windows a cmd.exe window, |
|
4391 |
on unix, an xterm is opened." |
|
4392 |
||
4393 |
OperatingSystem isOSXlike ifTrue:[ |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4394 |
"/ I dont know yet how to tell the terminal to |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4395 |
"/ go to a particular directory. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4396 |
"/ therefore, use the built in terminal |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4397 |
VT100TerminalView openShellIn:self pathName. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4398 |
^ self. |
16545 | 4399 |
]. |
14804 | 4400 |
|
14941 | 4401 |
[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4402 |
|cmd| |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4403 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4404 |
OperatingSystem isOSXlike ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4405 |
cmd := '/Applications/Utilities/Terminal.app/Contents/MacOS/Terminal ' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4406 |
] ifFalse:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4407 |
OperatingSystem isMSWINDOWSlike ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4408 |
cmd := 'c:\windows\System32\cmd.exe' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4409 |
] ifFalse:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4410 |
"/ VT100TerminalView openShellIn:self pathName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4411 |
cmd := 'xterm' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4412 |
] |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4413 |
]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4414 |
OperatingSystem |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4415 |
executeCommand:cmd |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4416 |
inDirectory:self pathName. |
14941 | 4417 |
] fork |
14232 | 4418 |
! ! |
4419 |
||
615 | 4420 |
!Filename methodsFor:'printing & storing'! |
174 | 4421 |
|
615 | 4422 |
printOn:aStream |
4392 | 4423 |
"append a user printed representation of the receiver to aStream. |
4424 |
The format is suitable for a human - not meant to be read back." |
|
174 | 4425 |
|
2906 | 4426 |
aStream nextPutAll:(self class name). |
4427 |
aStream nextPutAll:'('''. |
|
615 | 4428 |
nameString printOn:aStream. |
4429 |
aStream nextPutAll:''')' |
|
2906 | 4430 |
|
4431 |
"Modified: 7.9.1997 / 23:46:20 / cg" |
|
1 | 4432 |
! |
4433 |
||
615 | 4434 |
storeOn:aStream |
4435 |
"append a printed representation of the receiver to aStream, |
|
4436 |
which allows reconstructing it via readFrom:" |
|
328 | 4437 |
|
615 | 4438 |
aStream nextPut:$(. |
4439 |
nameString storeOn:aStream. |
|
4440 |
aStream nextPutAll:' asFilename)' |
|
1 | 4441 |
! ! |
4442 |
||
7258 | 4443 |
!Filename methodsFor:'private-accessing'! |
1 | 4444 |
|
6227 | 4445 |
getName |
4446 |
"get the raw filename" |
|
4447 |
||
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4448 |
^ nameString |
6227 | 4449 |
! |
4450 |
||
68 | 4451 |
setName:aString |
38 | 4452 |
"set the filename" |
4453 |
||
14220
2a3457b016be
Fix the '~/dir/name' resolution fow windows
Stefan Vogel <sv@exept.de>
parents:
14218
diff
changeset
|
4454 |
nameString := aString. |
3666 | 4455 |
|
4456 |
"Modified: / 21.7.1998 / 10:44:18 / cg" |
|
1 | 4457 |
! ! |
4458 |
||
2 | 4459 |
!Filename methodsFor:'queries'! |
4460 |
||
68 | 4461 |
exists |
92 | 4462 |
"return true, if such a file exists." |
68 | 4463 |
|
2947 | 4464 |
^ OperatingSystem isValidPath:(self osNameForAccess) |
68 | 4465 |
|
85 | 4466 |
" |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4467 |
'/foo/bar' asFilename exists |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4468 |
'/tmp' asFilename exists |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4469 |
'Makefile' asFilename exists |
85 | 4470 |
" |
77 | 4471 |
! |
4472 |
||
5928 | 4473 |
filenamesMatching:aPattern |
4474 |
"VW compatibility" |
|
4475 |
||
15811 | 4476 |
^ (self filesMatching:aPattern) |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4477 |
collect:[:eachName | self construct:eachName]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4478 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4479 |
" |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4480 |
'/etc' asFilename filenamesMatching:'a*;c*' |
5928 | 4481 |
" |
4482 |
||
4483 |
"Created: / 15.4.1997 / 15:40:02 / cg" |
|
4484 |
"Modified: / 3.8.1998 / 21:22:15 / cg" |
|
4485 |
! |
|
4486 |
||
2548
b6182b559ea2
made filesMatching ST-80 compatible.
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4487 |
filesMatching:aPattern |
2550 | 4488 |
"given the receiver, representing a directory; |
4489 |
return a collection of files matching a pattern. |
|
4490 |
The pattern may be a simple matchPattern, or a set of |
|
4491 |
multiple patterns separated by semicolons." |
|
4492 |
||
19821 | 4493 |
^ OrderedCollection withCollectedContents:[:coll | |
4494 |
self filesMatching:aPattern do:[:fn | coll add:fn]] |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4495 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4496 |
" |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4497 |
'/etc' asFilename filesMatching:'a*;c*' |
2548
b6182b559ea2
made filesMatching ST-80 compatible.
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4498 |
" |
b6182b559ea2
made filesMatching ST-80 compatible.
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4499 |
|
3719
ce88c6f64d37
ignore case for PC-filenames when searching for matches.
Claus Gittinger <cg@exept.de>
parents:
3713
diff
changeset
|
4500 |
"Created: / 15.4.1997 / 15:40:02 / cg" |
ce88c6f64d37
ignore case for PC-filenames when searching for matches.
Claus Gittinger <cg@exept.de>
parents:
3713
diff
changeset
|
4501 |
"Modified: / 3.8.1998 / 21:22:15 / cg" |
2550 | 4502 |
! |
4503 |
||
19821 | 4504 |
filesMatching:aPattern caseSensitive:caseSensitive do:aBlock |
4505 |
"given the receiver, representing a directory; |
|
4506 |
evaluate aBlock for files which match a pattern. |
|
4507 |
The pattern may be a simple matchPattern, or a set of |
|
4508 |
multiple patterns separated by semicolons." |
|
4509 |
||
4510 |
|matchers| |
|
4511 |
||
4512 |
matchers := aPattern asCollectionOfSubstringsSeparatedBy:$;. |
|
4513 |
self directoryContentsDo:[:name | |
|
4514 |
(matchers contains:[:p | p match:name caseSensitive:caseSensitive]) ifTrue:[ |
|
4515 |
aBlock value:name |
|
4516 |
] |
|
4517 |
]. |
|
4518 |
||
4519 |
" |
|
4520 |
'/etc' asFilename filesMatching:'a*;c*' do:[:f | Transcript showCR:f] |
|
4521 |
" |
|
4522 |
||
4523 |
"Created: / 15.4.1997 / 15:40:02 / cg" |
|
4524 |
"Modified: / 3.8.1998 / 21:22:15 / cg" |
|
4525 |
! |
|
4526 |
||
4527 |
filesMatching:aPattern do:aBlock |
|
4528 |
"given the receiver, representing a directory; |
|
4529 |
evaluate aBlock for files which match a pattern. |
|
4530 |
The pattern may be a simple matchPattern, or a set of |
|
4531 |
multiple patterns separated by semicolons." |
|
4532 |
||
4533 |
self filesMatching:aPattern caseSensitive:self species isCaseSensitive do:aBlock |
|
4534 |
||
4535 |
" |
|
4536 |
'/etc' asFilename filesMatching:'a*;c*' do:[:f | Transcript showCR:f] |
|
4537 |
" |
|
4538 |
||
4539 |
"Created: / 15.4.1997 / 15:40:02 / cg" |
|
4540 |
"Modified: / 3.8.1998 / 21:22:15 / cg" |
|
4541 |
! |
|
4542 |
||
2550 | 4543 |
filesMatchingWithoutDotDirs:aPattern |
4544 |
"given the receiver, representing a directory; |
|
4545 |
return a collection of files matching a pattern. |
|
4546 |
Exclude '.' and '..' from the returned list. |
|
4547 |
The pattern may be a simple matchPattern, or a set of |
|
4548 |
multiple patterns separated by semicolons." |
|
4549 |
||
19821 | 4550 |
^ OrderedCollection withCollectedContents:[:coll | |
4551 |
self filesMatchingWithoutDotDirs:aPattern do:[:fn | coll add:fn]] |
|
4552 |
||
4553 |
" |
|
4554 |
Filename currentDirectory filesMatching:'.*' |
|
4555 |
Filename currentDirectory filesMatchingWithoutDotDirs:'*.*' |
|
4556 |
'/etc' asFilename filesMatchingWithoutDotDirs:'*' |
|
4557 |
" |
|
4558 |
||
4559 |
"Created: / 15.4.1997 / 12:52:10 / cg" |
|
4560 |
"Modified: / 3.8.1998 / 21:22:30 / cg" |
|
4561 |
! |
|
4562 |
||
4563 |
filesMatchingWithoutDotDirs:aPattern caseSensitive:caseSensitive do:aBlock |
|
4564 |
"given the receiver, representing a directory; |
|
4565 |
evaluate aBlock for files matching a pattern. |
|
4566 |
Exclude '.' and '..'. |
|
4567 |
The pattern may be a simple matchPattern, or a set of |
|
4568 |
multiple patterns separated by semicolons." |
|
4569 |
||
4570 |
|matchers| |
|
2550 | 4571 |
|
4572 |
matchers := aPattern asCollectionOfSubstringsSeparatedBy:$;. |
|
19821 | 4573 |
|
4574 |
self directoryContentsDo:[:name | |
|
4575 |
(name ~= '.' |
|
4576 |
and:[ name ~= '..' |
|
4577 |
and:[ (matchers contains:[:p | p match:name caseSensitive:caseSensitive]) ]]) |
|
4578 |
ifTrue:[ |
|
4579 |
aBlock value:name |
|
4580 |
] |
|
4581 |
]. |
|
4582 |
||
4583 |
" |
|
4584 |
Filename currentDirectory filesMatching:'M*' |
|
4585 |
'/etc' asFilename filesMatching:'[a-z]*' |
|
4586 |
'../../libbasic' asFilename filesMatching:'[A-D]*.st' |
|
4587 |
" |
|
4588 |
||
4589 |
"Created: / 15.4.1997 / 12:52:10 / cg" |
|
4590 |
"Modified: / 3.8.1998 / 21:22:30 / cg" |
|
4591 |
! |
|
4592 |
||
4593 |
filesMatchingWithoutDotDirs:aPattern do:aBlock |
|
4594 |
"given the receiver, representing a directory; |
|
4595 |
evaluate aBlock for files matching a pattern. |
|
4596 |
Exclude '.' and '..'. |
|
4597 |
The pattern may be a simple matchPattern, or a set of |
|
4598 |
multiple patterns separated by semicolons." |
|
4599 |
||
4600 |
self filesMatchingWithoutDotDirs:aPattern caseSensitive:self species isCaseSensitive do:aBlock |
|
2550 | 4601 |
|
4602 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4603 |
Filename currentDirectory filesMatching:'M*' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4604 |
'/etc' asFilename filesMatching:'[a-z]*' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4605 |
'../../libbasic' asFilename filesMatching:'[A-D]*.st' |
2550 | 4606 |
" |
4607 |
||
3719
ce88c6f64d37
ignore case for PC-filenames when searching for matches.
Claus Gittinger <cg@exept.de>
parents:
3713
diff
changeset
|
4608 |
"Created: / 15.4.1997 / 12:52:10 / cg" |
ce88c6f64d37
ignore case for PC-filenames when searching for matches.
Claus Gittinger <cg@exept.de>
parents:
3713
diff
changeset
|
4609 |
"Modified: / 3.8.1998 / 21:22:30 / cg" |
2548
b6182b559ea2
made filesMatching ST-80 compatible.
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4610 |
! |
b6182b559ea2
made filesMatching ST-80 compatible.
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4611 |
|
9206 | 4612 |
fullAlternativePathName |
19821 | 4613 |
"some filesystems (aka: windows) have alternative (short) filenames. |
4614 |
Those systems redefine this method to return it. |
|
4615 |
Otherwise, the same as the regular name is returned here" |
|
4616 |
||
9206 | 4617 |
^ nameString |
4618 |
! |
|
4619 |
||
615 | 4620 |
isExecutable |
4621 |
"return true, if such a file exists and is executable (by Unix's definition). |
|
4622 |
For directories, true is returned if the directory can be entered. |
|
4623 |
See isExecutableProgram for a related check." |
|
4624 |
||
2947 | 4625 |
^ OperatingSystem isExecutable:(self osNameForAccess) |
615 | 4626 |
|
4627 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4628 |
'/foo/bar' asFilename isExecutable |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4629 |
'/tmp' asFilename isExecutable |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4630 |
'Makefile' asFilename isExecutable |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4631 |
'/bin/ls' asFilename isExecutable |
356 | 4632 |
" |
4633 |
! |
|
4634 |
||
615 | 4635 |
isExecutableProgram |
4636 |
"return true, if such a file exists and is an executable program. |
|
4637 |
(i.e. for directories, false is returned.)" |
|
356 | 4638 |
|
2922 | 4639 |
|osName| |
4640 |
||
2947 | 4641 |
osName := self osNameForAccess. |
2922 | 4642 |
^ (OperatingSystem isExecutable:osName) |
4643 |
and:[(OperatingSystem isDirectory:osName) not] |
|
356 | 4644 |
|
4645 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4646 |
'/tmp' asFilename isExecutable |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4647 |
'/bin/ls' asFilename isExecutable |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4648 |
'/tmp' asFilename isExecutableProgram |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4649 |
'/bin/ls' asFilename isExecutableProgram |
615 | 4650 |
" |
4651 |
! |
|
4652 |
||
2922 | 4653 |
isHidden |
4654 |
"return true, if the receiver represents a hidden file. |
|
4655 |
The definitions of hidden files depends on the OS used; |
|
4656 |
on UNIX, a name starting with a period is considered hidden; |
|
16578 | 4657 |
on MSDOS, the file's hidden attribute is also used. |
2922 | 4658 |
VMS has no concept of hidden files." |
4659 |
||
4660 |
^ false |
|
4661 |
! |
|
4662 |
||
6773
26415b61ad09
isMountPoint & isParentDirectoryOf & allParentDirsDo:
penk
parents:
6771
diff
changeset
|
4663 |
isMountPoint:aPathName |
26415b61ad09
isMountPoint & isParentDirectoryOf & allParentDirsDo:
penk
parents:
6771
diff
changeset
|
4664 |
"return true, if I represent a mount-point. |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4665 |
Warning: |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4666 |
the receiver must be an absolute pathname, |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4667 |
because a realPath is not used/generated for the query (to avoid automounting). |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4668 |
Aka: do not ask: '../../' asFilename isMountPoint; |
6773
26415b61ad09
isMountPoint & isParentDirectoryOf & allParentDirsDo:
penk
parents:
6771
diff
changeset
|
4669 |
" |
26415b61ad09
isMountPoint & isParentDirectoryOf & allParentDirsDo:
penk
parents:
6771
diff
changeset
|
4670 |
|
26415b61ad09
isMountPoint & isParentDirectoryOf & allParentDirsDo:
penk
parents:
6771
diff
changeset
|
4671 |
self isAbsolute ifFalse:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4672 |
self error:'this query must be done on an absolute pathname'. |
6773
26415b61ad09
isMountPoint & isParentDirectoryOf & allParentDirsDo:
penk
parents:
6771
diff
changeset
|
4673 |
]. |
26415b61ad09
isMountPoint & isParentDirectoryOf & allParentDirsDo:
penk
parents:
6771
diff
changeset
|
4674 |
^ OperatingSystem isMountPoint:(self name) |
26415b61ad09
isMountPoint & isParentDirectoryOf & allParentDirsDo:
penk
parents:
6771
diff
changeset
|
4675 |
! |
26415b61ad09
isMountPoint & isParentDirectoryOf & allParentDirsDo:
penk
parents:
6771
diff
changeset
|
4676 |
|
615 | 4677 |
isReadable |
4678 |
"return true, if such a file exists and is readable." |
|
4679 |
||
2947 | 4680 |
^ OperatingSystem isReadable:(self osNameForFile) |
615 | 4681 |
|
4682 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4683 |
'/foo/bar' asFilename isReadable |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4684 |
'/tmp' asFilename isReadable |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4685 |
'Makefile' asFilename isReadable |
328 | 4686 |
" |
4687 |
! |
|
4688 |
||
11529 | 4689 |
isSharedLibrary |
4690 |
"return true, if such a file exists and is a shared library." |
|
4691 |
||
4692 |
ObjectFileLoader isNil ifTrue:[ |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4693 |
"we cannot handle shared libraries, so there are no shared libraries" |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4694 |
^ false. |
11529 | 4695 |
]. |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4696 |
^ (ObjectFileLoader validBinaryExtensions includes:self suffix) |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4697 |
and:[self isRegularFile]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4698 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4699 |
" |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4700 |
'libstx_libbasic.so' asFilename isSharedLibrary |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4701 |
'libstx_libbasic.dll' asFilename isSharedLibrary |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4702 |
'/tmp' asFilename isSharedLibrary |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4703 |
'/tmp.dll' asFilename isSharedLibrary |
11529 | 4704 |
" |
4705 |
! |
|
4706 |
||
615 | 4707 |
isWritable |
4708 |
"return true, if such a file exists and is writable." |
|
4709 |
||
2947 | 4710 |
^ OperatingSystem isWritable:(self osNameForFile) |
615 | 4711 |
|
4712 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4713 |
'/foo/bar' asFilename isWritable |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4714 |
'/tmp' asFilename isWritable |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4715 |
'Makefile' asFilename isWritable |
328 | 4716 |
" |
174 | 4717 |
! |
4718 |
||
15574 | 4719 |
isWritableDirectory |
4720 |
"return true, if such a directory exists and is writable. |
|
4721 |
Don't believe #isWritable, since on an NFS mounted filesystem |
|
4722 |
with UID mapping and attribute cache enabled, there may be false negatives." |
|
4723 |
||
4724 |
self isDirectory ifFalse:[ |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4725 |
^ false. |
15574 | 4726 |
]. |
4727 |
||
4728 |
self isWritable ifFalse:[ |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4729 |
"/ on an NFS mounted filesystem with UID mapping and |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4730 |
"/ attribute cache enabled, |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4731 |
"/ this query may fail, but creation may work actually. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4732 |
"/ check again... |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4733 |
[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4734 |
|tempFile| |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4735 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4736 |
tempFile := FileStream newTemporaryIn:self. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4737 |
tempFile close. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4738 |
tempFile fileName remove. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4739 |
] on:OpenError do:[:ex| |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4740 |
^ false. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4741 |
]. |
15574 | 4742 |
]. |
4743 |
^ true. |
|
4744 |
||
4745 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4746 |
'/foo/bar' asFilename isWritableDirectory |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4747 |
'/tmp' asFilename isWritableDirectory |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4748 |
'/etc' asFilename isWritableDirectory |
15574 | 4749 |
'Makefile' asFilename isWritableDirectory |
4750 |
'/net/exeptn/home2/office' asFilename isWritable |
|
4751 |
'/net/exeptn/home2/office' asFilename isWritableDirectory |
|
4752 |
" |
|
4753 |
! |
|
4754 |
||
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4755 |
separator |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4756 |
"return the directory-separator character" |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4757 |
|
15811 | 4758 |
^ self species separator |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4759 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4760 |
"Modified: 29.2.1996 / 20:52:01 / cg" |
8947 | 4761 |
! |
4762 |
||
11781
6488fd6cc498
Make AutoDeletedFilename work like Filename
Stefan Vogel <sv@exept.de>
parents:
11763
diff
changeset
|
4763 |
species |
15811 | 4764 |
"create only new instances of the concrete OS specific class. |
4765 |
Redefined in AutoDeletedFilename, to not create AutoDeleted instances |
|
4766 |
per default (from directories etc.)" |
|
4767 |
||
4768 |
self == Filename ifTrue:[ |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4769 |
^ ConcreteClass. |
15811 | 4770 |
] ifFalse:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4771 |
^ self class. |
15811 | 4772 |
]. |
11781
6488fd6cc498
Make AutoDeletedFilename work like Filename
Stefan Vogel <sv@exept.de>
parents:
11763
diff
changeset
|
4773 |
! |
6488fd6cc498
Make AutoDeletedFilename work like Filename
Stefan Vogel <sv@exept.de>
parents:
11763
diff
changeset
|
4774 |
|
8947 | 4775 |
withSpecialExpansions |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4776 |
"return a new filename, expanding any OS specific macros. |
15811 | 4777 |
Here, a ~/ prefix is expanded to the users home dir (as in bash)" |
8947 | 4778 |
|
4779 |
|newName| |
|
4780 |
||
15811 | 4781 |
newName := self species nameWithSpecialExpansions:nameString. |
4782 |
newName = nameString ifTrue:[ |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4783 |
^ self. |
8947 | 4784 |
]. |
15811 | 4785 |
^ self species named:newName. |
8947 | 4786 |
|
4787 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4788 |
'~' asFilename withSpecialExpansions |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4789 |
'~/Desktop' asFilename withSpecialExpansions |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4790 |
'~stefan' asFilename withSpecialExpansions |
15811 | 4791 |
'~stefan/Desktop' asFilename withSpecialExpansions |
8947 | 4792 |
" |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4793 |
! ! |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4794 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4795 |
!Filename methodsFor:'queries-contents'! |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4796 |
|
7291 | 4797 |
mimeTypeFromName |
16578 | 4798 |
"return the mimeType as guessed from the file's name/and or extension. |
7291 | 4799 |
This could be less accurate than mimeTypeOfContents, but avoids |
4800 |
reading the file (is therefore much faster). |
|
4801 |
Also it works with non-existing files. |
|
4802 |
Returns nil for directories and other non-regular files." |
|
4803 |
||
17112 | 4804 |
|mimeTypes| |
4805 |
||
16755 | 4806 |
"/ kludge to avoid making libview a prereq. of libbasic |
17112 | 4807 |
(mimeTypes := Smalltalk at:#MIMETypes) notNil ifTrue:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4808 |
^ mimeTypes mimeTypeForFilename:(self name) |
16755 | 4809 |
]. |
4810 |
^ nil |
|
7291 | 4811 |
|
4812 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4813 |
'Makefile' asFilename mimeTypeFromName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4814 |
'.' asFilename mimeTypeFromName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4815 |
'/dev/null' asFilename mimeTypeFromName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4816 |
'/tmp/.X11-unix/X0' asFilename mimeTypeFromName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4817 |
'smalltalk.rc' asFilename mimeTypeFromName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4818 |
'bitmaps/SBrowser.xbm' asFilename mimeTypeFromName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4819 |
'../../rules/stmkmf' asFilename mimeTypeFromName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4820 |
'/bläh' asFilename mimeTypeFromName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4821 |
'/x.zip' asFilename mimeTypeFromName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4822 |
'/x.gz' asFilename mimeTypeFromName |
7291 | 4823 |
" |
4824 |
! |
|
4825 |
||
5011 | 4826 |
mimeTypeOfContents |
4827 |
"this tries to guess the mime type of contents of |
|
4828 |
the file. Returns nil, if the file is unreadable, not a plain file |
|
4829 |
or the contents is unknown. |
|
4830 |
This is done using some heuristics, and may need some improvement" |
|
4831 |
||
17111 | 4832 |
|type buffer s size mimeTypes| |
5011 | 4833 |
|
7088
cc3233554827
Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents:
7075
diff
changeset
|
4834 |
type := self type. |
11406
af2c2118e164
refactored - mimetypeofdata now where it belongs to
Claus Gittinger <cg@exept.de>
parents:
11397
diff
changeset
|
4835 |
type isNil ifTrue:[ ^ nil ]. |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4836 |
type == #directory ifTrue:[ ^ nil ]. |
11406
af2c2118e164
refactored - mimetypeofdata now where it belongs to
Claus Gittinger <cg@exept.de>
parents:
11397
diff
changeset
|
4837 |
type == #characterSpecial ifTrue:[ ^ nil ]. |
af2c2118e164
refactored - mimetypeofdata now where it belongs to
Claus Gittinger <cg@exept.de>
parents:
11397
diff
changeset
|
4838 |
type == #blockSpecial ifTrue:[ ^ nil ]. |
af2c2118e164
refactored - mimetypeofdata now where it belongs to
Claus Gittinger <cg@exept.de>
parents:
11397
diff
changeset
|
4839 |
type == #socket ifTrue:[ ^ nil ]. |
5011 | 4840 |
self fileSize == 0 ifTrue:[^ nil]. |
4841 |
||
7088
cc3233554827
Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents:
7075
diff
changeset
|
4842 |
s := self readStreamOrNil. |
cc3233554827
Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents:
7075
diff
changeset
|
4843 |
s isNil ifTrue:[^ nil]. |
cc3233554827
Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents:
7075
diff
changeset
|
4844 |
|
5011 | 4845 |
"/ read some data from the file ... |
7685
535a69a7cd69
String new -> uninitializedNew: / basicNew:
Claus Gittinger <cg@exept.de>
parents:
7680
diff
changeset
|
4846 |
buffer := String new:2048. |
5011 | 4847 |
|
6943
910f4b17c342
care for unreadable contents in mimeTypeOfContents
Claus Gittinger <cg@exept.de>
parents:
6908
diff
changeset
|
4848 |
s errorSignal handle:[:ex | |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4849 |
size := 0. |
6943
910f4b17c342
care for unreadable contents in mimeTypeOfContents
Claus Gittinger <cg@exept.de>
parents:
6908
diff
changeset
|
4850 |
] do:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4851 |
size := s nextBytes:buffer size into:buffer. |
6943
910f4b17c342
care for unreadable contents in mimeTypeOfContents
Claus Gittinger <cg@exept.de>
parents:
6908
diff
changeset
|
4852 |
]. |
5011 | 4853 |
s close. |
11406
af2c2118e164
refactored - mimetypeofdata now where it belongs to
Claus Gittinger <cg@exept.de>
parents:
11397
diff
changeset
|
4854 |
|
16755 | 4855 |
"/ kludge to avoid making libview a prereq. of libbasic |
17111 | 4856 |
(mimeTypes := Smalltalk at:#MIMETypes) notNil ifTrue:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4857 |
^ mimeTypes mimeTypeOfData:buffer suffix:self suffix. |
16755 | 4858 |
]. |
4859 |
^ nil |
|
5011 | 4860 |
|
4861 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4862 |
'Makefile' asFilename mimeTypeOfContents |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4863 |
'.' asFilename mimeTypeOfContents |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4864 |
'/dev/null' asFilename mimeTypeOfContents |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4865 |
'/tmp/.X11-unix/X0' asFilename mimeTypeOfContents |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4866 |
'smalltalk.rc' asFilename mimeTypeOfContents |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4867 |
'bitmaps/SBrowser.xbm' asFilename mimeTypeOfContents |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4868 |
'../../rules/stmkmf' asFilename mimeTypeOfContents |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4869 |
'/bläh' asFilename mimeTypeOfContents |
10153 | 4870 |
'C:\Dokumente und Einstellungen\cg\Favoriten\languages.lnk' asFilename mimeTypeOfContents |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4871 |
'G:\A\A01.TOP' asFilename mimeTypeOfContents |
10153 | 4872 |
" |
4873 |
||
4874 |
"Modified: / 06-11-2006 / 11:44:58 / cg" |
|
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4875 |
! ! |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4876 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4877 |
!Filename methodsFor:'queries-path & name'! |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4878 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4879 |
baseName |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4880 |
"return my baseName as a string. |
2012 | 4881 |
- thats the file/directory name without leading parent-dirs. |
2922 | 4882 |
(i.e. '/usr/lib/st/file' asFilename baseName -> 'file' |
4883 |
and '/usr/lib' asFilename baseName -> lib). |
|
7075 | 4884 |
This method does not check if the path is valid. |
4885 |
The code here should work for Unix and MSDOS, but needs to be redefined |
|
4886 |
for VMS (and maybe others as well). |
|
2911 | 4887 |
See also: #pathName, #directoryName and #directoryPathName. |
4888 |
Compatibility note: use #tail for ST-80 compatibility." |
|
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4889 |
|
2922 | 4890 |
|len index sep endIdx| |
4891 |
||
4892 |
sep := self separator. |
|
4893 |
len := nameString size. |
|
4894 |
((len == 1) and:[(nameString at:1) == sep]) ifTrue:[ |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4895 |
^ nameString |
2922 | 4896 |
]. |
4897 |
||
4898 |
endIdx := len. |
|
4899 |
len > 1 ifTrue:[ |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4900 |
(nameString at:len) == sep ifTrue:[endIdx := endIdx - 1]. |
2922 | 4901 |
]. |
4902 |
index := nameString lastIndexOf:sep startingAt:len-1. |
|
4903 |
^ nameString copyFrom:(index+1) to:endIdx |
|
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4904 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4905 |
" |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4906 |
'/foo/bar' asFilename baseName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4907 |
'/foo/bar.cc' asFilename baseName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4908 |
'.' asFilename baseName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4909 |
'..' asFilename baseName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4910 |
'../..' asFilename baseName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4911 |
'../../libbasic' asFilename baseName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4912 |
'../../libpr' asFilename baseName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4913 |
'../../libbasic/Object.st' asFilename baseName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4914 |
'/' asFilename baseName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4915 |
'\' asFilename baseName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4916 |
'c:\' asFilename baseName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4917 |
'\\idefix' asFilename baseName |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4918 |
" |
2012 | 4919 |
|
3851 | 4920 |
"Modified: / 24.9.1998 / 13:06:23 / cg" |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4921 |
! |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4922 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4923 |
directory |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4924 |
"return the directory name part of the file/directory as a new filename. |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4925 |
- thats a filename for the directory where the file/dir represented by |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4926 |
the receiver is contained in. |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4927 |
(this is almost equivalent to #directoryName or #head, but returns |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4928 |
a Filename instance instead of a string )." |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4929 |
|
15811 | 4930 |
^ self species named:(self directoryName) |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4931 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4932 |
" |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4933 |
'/foo/bar' asFilename directory |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4934 |
'/foo/bar' asFilename directoryName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4935 |
'/foo/bar' asFilename head |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4936 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4937 |
'.' asFilename directory |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4938 |
'..' asFilename directory |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4939 |
'../..' asFilename directory |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4940 |
" |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4941 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4942 |
"Modified: 29.2.1996 / 20:50:14 / cg" |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4943 |
! |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4944 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4945 |
directoryName |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4946 |
"return the directory name part of the file/directory as a string. |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4947 |
- thats the name of the directory where the file/dir represented by |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4948 |
the receiver is contained in. |
3888
a528db31e5c0
had to change #directoryName again - it did not work.
Claus Gittinger <cg@exept.de>
parents:
3886
diff
changeset
|
4949 |
This method does not check if the path is valid. |
2922 | 4950 |
|
4951 |
(i.e. '/usr/lib/st/file' asFilename directoryName -> '/usr/lib/st' |
|
4952 |
and '/usr/lib' asFilename directoryName -> /usr'). |
|
4953 |
||
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4954 |
(this is almost equivalent to #directory, but returns |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4955 |
a string instead of a Filename instance). |
2922 | 4956 |
|
2012 | 4957 |
See also: #pathName, #directoryPathName and #baseName. |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4958 |
Compatibility note: use #head for ST-80 compatibility." |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4959 |
|
16389 | 4960 |
|index sep sepString p rest parentDirectoryString| |
2922 | 4961 |
|
4962 |
sep := self separator. |
|
4963 |
sepString := sep asString. |
|
4964 |
(nameString = sepString) ifTrue:[ |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4965 |
"/ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4966 |
"/ the trivial '/' case |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4967 |
"/ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4968 |
^ sepString |
2922 | 4969 |
]. |
4970 |
||
4971 |
"/ |
|
3893 | 4972 |
"/ strip off multiple trailing slashes |
2922 | 4973 |
"/ |
4974 |
p := nameString. |
|
16389 | 4975 |
[p endsWith:sep] whileTrue:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4976 |
(p = sepString) ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4977 |
^ sepString |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4978 |
]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4979 |
p := p copyButLast:1 |
2922 | 4980 |
]. |
4981 |
||
16389 | 4982 |
parentDirectoryString := self class parentDirectoryName. |
4983 |
||
3886
e6efeb877eda
fixed #directory & #directoryName for
Claus Gittinger <cg@exept.de>
parents:
3876
diff
changeset
|
4984 |
"/ strip off trailing components |
3888
a528db31e5c0
had to change #directoryName again - it did not work.
Claus Gittinger <cg@exept.de>
parents:
3886
diff
changeset
|
4985 |
index := p lastIndexOf:sep startingAt:p size. |
a528db31e5c0
had to change #directoryName again - it did not work.
Claus Gittinger <cg@exept.de>
parents:
3886
diff
changeset
|
4986 |
index == 0 ifTrue:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4987 |
"/ no separator found |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4988 |
p = '.' ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4989 |
^ parentDirectoryString |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4990 |
]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4991 |
p = '..' ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4992 |
^ parentDirectoryString, sepString, parentDirectoryString |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4993 |
]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4994 |
^ '.' |
2922 | 4995 |
]. |
3888
a528db31e5c0
had to change #directoryName again - it did not work.
Claus Gittinger <cg@exept.de>
parents:
3886
diff
changeset
|
4996 |
rest := p copyFrom:(index+1). |
7342
4e9ff418113f
fixed for directory name ending with '/..'
Claus Gittinger <cg@exept.de>
parents:
7332
diff
changeset
|
4997 |
(rest = '.') ifTrue:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4998 |
^ p copyTo:index-1. |
7342
4e9ff418113f
fixed for directory name ending with '/..'
Claus Gittinger <cg@exept.de>
parents:
7332
diff
changeset
|
4999 |
]. |
16389 | 5000 |
(rest = parentDirectoryString) ifTrue:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5001 |
^ (self species named:(p copyTo:(index-1))) directoryName |
3888
a528db31e5c0
had to change #directoryName again - it did not work.
Claus Gittinger <cg@exept.de>
parents:
3886
diff
changeset
|
5002 |
]. |
3893 | 5003 |
index == 1 ifTrue:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5004 |
^ sepString |
3893 | 5005 |
]. |
3888
a528db31e5c0
had to change #directoryName again - it did not work.
Claus Gittinger <cg@exept.de>
parents:
3886
diff
changeset
|
5006 |
^ p copyTo:(index - 1) |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5007 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5008 |
" |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5009 |
'/home' asFilename directoryName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5010 |
'/foo/bar/' asFilename directoryName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5011 |
'/foo/bar/' asFilename directory |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5012 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5013 |
'/foo/bar' asFilename directoryName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5014 |
'bitmaps' asFilename directoryName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5015 |
'bitmaps' asFilename directoryPathName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5016 |
'.' asFilename directoryName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5017 |
'.' asFilename directoryPathName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5018 |
'..' asFilename directoryName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5019 |
'..' asFilename directoryPathName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5020 |
'../..' asFilename directoryName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5021 |
'../..' asFilename directoryPathName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5022 |
'/foo/bar/baz/..' asFilename directoryName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5023 |
'/foo/bar/baz/.' asFilename directoryName |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5024 |
" |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5025 |
|
3886
e6efeb877eda
fixed #directory & #directoryName for
Claus Gittinger <cg@exept.de>
parents:
3876
diff
changeset
|
5026 |
"Modified: / 7.9.1995 / 10:42:03 / claus" |
3888
a528db31e5c0
had to change #directoryName again - it did not work.
Claus Gittinger <cg@exept.de>
parents:
3886
diff
changeset
|
5027 |
"Modified: / 21.10.1998 / 22:52:25 / cg" |
3893 | 5028 |
"Modified: / 27.10.1998 / 13:19:26 / ps" |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5029 |
! |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5030 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5031 |
directoryPathName |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5032 |
"return the full directory pathname part of the file/directory as a string. |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5033 |
- thats the full pathname of the directory where the file/dir represented by |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5034 |
the receiver is contained in. |
2012 | 5035 |
See also: #pathName, #directoryName, #directory and #baseName" |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5036 |
|
15811 | 5037 |
^ (self species named:self pathName) directoryName |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5038 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5039 |
" |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5040 |
'/foo/bar/' asFilename directoryPathName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5041 |
'/foo/bar' asFilename directoryPathName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5042 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5043 |
'.' asFilename directoryPathName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5044 |
'.' asFilename directoryName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5045 |
'.' asFilename directory |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5046 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5047 |
'..' asFilename directoryPathName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5048 |
'..' asFilename directoryName |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5049 |
'..' asFilename directory |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5050 |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5051 |
'../..' asFilename directoryPathName |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5052 |
" |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5053 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5054 |
"Modified: 7.9.1995 / 10:42:13 / claus" |
2012 | 5055 |
"Modified: 21.12.1996 / 15:21:57 / cg" |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5056 |
! |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5057 |
|
14567 | 5058 |
encodedNameString |
5059 |
"answer the name as passed to OS system calls" |
|
5060 |
||
5061 |
^ OperatingSystem encodePath:nameString |
|
5062 |
! |
|
5063 |
||
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5064 |
filenameCompletion |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5065 |
"try to complete the receiver filename. |
6556
367bc84f51fc
filename completion better if an empty basename is shown
Claus Gittinger <cg@exept.de>
parents:
6529
diff
changeset
|
5066 |
BAD DESIGN: has side effect on the receiver. |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5067 |
This method has both a return value and a side effect on the receiver: |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5068 |
it returns a collection of matching filename objects, |
19440 | 5069 |
and changes the receiver's filename-string to the longest common |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5070 |
match. |
19440 | 5071 |
If none matches, the returned collection is empty and the receiver is unchanged. |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5072 |
If there is only one match, the size of the returned collection is exactly 1, |
19752 | 5073 |
containing the fully expanded filename and the receiver's name is changed to it." |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5074 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5075 |
^ self filenameCompletionIn:nil |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5076 |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5077 |
" |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5078 |
'mak' asFilename filenameCompletion |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5079 |
'Make' asFilename filenameCompletion |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5080 |
'Makef' asFilename filenameCompletion;yourself |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5081 |
'/u' asFilename filenameCompletion |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5082 |
'../../libpr' asFilename inspect filenameCompletion |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5083 |
" |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5084 |
|
1517 | 5085 |
"Modified: 3.7.1996 / 10:53:51 / cg" |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5086 |
! |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5087 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5088 |
filenameCompletionIn:aDirectory |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5089 |
"try to complete the receiver filename. |
11341
22494c109161
fixed filename completion for root directories (added another sep-char)
Claus Gittinger <cg@exept.de>
parents:
11192
diff
changeset
|
5090 |
|
6556
367bc84f51fc
filename completion better if an empty basename is shown
Claus Gittinger <cg@exept.de>
parents:
6529
diff
changeset
|
5091 |
BAD DESIGN: has side effect on the receiver. |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5092 |
This method has both a return value and a side effect on the receiver: |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5093 |
it returns a collection of matching filename objects, |
11341
22494c109161
fixed filename completion for root directories (added another sep-char)
Claus Gittinger <cg@exept.de>
parents:
11192
diff
changeset
|
5094 |
and changes the receiver's filename-string to the longest common match. |
22494c109161
fixed filename completion for root directories (added another sep-char)
Claus Gittinger <cg@exept.de>
parents:
11192
diff
changeset
|
5095 |
If none matches, the returned collection is empty and the receiver is unchanged. |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5096 |
If there is only one match, the size of the returned collection is exactly 1, |
11341
22494c109161
fixed filename completion for root directories (added another sep-char)
Claus Gittinger <cg@exept.de>
parents:
11192
diff
changeset
|
5097 |
containing the fully expanded filename and the receiver's name is changed to it. |
22494c109161
fixed filename completion for root directories (added another sep-char)
Claus Gittinger <cg@exept.de>
parents:
11192
diff
changeset
|
5098 |
An empty baseName pattern (i.e. giving the name of a directory) will also return an empty matchset." |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5099 |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5100 |
|mySpecies dir baseName matching matchLen try allMatching |
3774
e2a75c79c625
ignore case in fileNameCompletion, on systems where case is ignored
Claus Gittinger <cg@exept.de>
parents:
3768
diff
changeset
|
5101 |
sepString parentString prefix nMatch nm caseless lcBaseName| |
3666 | 5102 |
|
15811 | 5103 |
mySpecies := self species. |
5104 |
||
5105 |
caseless := mySpecies isCaseSensitive not. |
|
6556
367bc84f51fc
filename completion better if an empty basename is shown
Claus Gittinger <cg@exept.de>
parents:
6529
diff
changeset
|
5106 |
matching := OrderedCollection new. |
367bc84f51fc
filename completion better if an empty basename is shown
Claus Gittinger <cg@exept.de>
parents:
6529
diff
changeset
|
5107 |
|
15811 | 5108 |
nm := mySpecies nameWithSpecialExpansions:nameString. |
5109 |
nm := mySpecies canonicalize:nm. |
|
5110 |
||
5111 |
sepString := mySpecies separatorString. |
|
3666 | 5112 |
(nm endsWith:sepString) ifTrue:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5113 |
"/ two exceptions here: |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5114 |
"/ if there is only one file in the directory, that one must be it. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5115 |
"/ otherwise, return the longest common prefix of all files. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5116 |
self isDirectory ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5117 |
|first longest| |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5118 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5119 |
first := nil. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5120 |
OpenError catch:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5121 |
self directoryContentsDo:[:fileName | |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5122 |
((fileName ~= '.') and:[fileName ~= parentString]) ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5123 |
matching add:fileName. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5124 |
first isNil ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5125 |
first := longest := fileName. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5126 |
] ifFalse:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5127 |
"/ more than one file |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5128 |
longest := longest commonPrefixWith:fileName ignoreCase:caseless. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5129 |
longest isEmpty ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5130 |
^ #() |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5131 |
]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5132 |
] |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5133 |
] |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5134 |
]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5135 |
]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5136 |
longest notNil ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5137 |
nameString := (self constructString:longest). |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5138 |
^ matching |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5139 |
]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5140 |
]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5141 |
^ #() |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5142 |
]. |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5143 |
|
15811 | 5144 |
parentString := mySpecies parentDirectoryName. |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5145 |
baseName := self baseName. |
3666 | 5146 |
baseName ~= nm ifTrue:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5147 |
prefix := self directoryName. |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5148 |
]. |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5149 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5150 |
self isAbsolute ifTrue:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5151 |
dir := self directory |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5152 |
] ifFalse:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5153 |
aDirectory isNil ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5154 |
dir := self directory |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5155 |
] ifFalse:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5156 |
dir := (aDirectory asFilename construct:nm) directory |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5157 |
] |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5158 |
]. |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5159 |
|
3774
e2a75c79c625
ignore case in fileNameCompletion, on systems where case is ignored
Claus Gittinger <cg@exept.de>
parents:
3768
diff
changeset
|
5160 |
caseless ifTrue:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5161 |
lcBaseName := baseName asLowercase |
3774
e2a75c79c625
ignore case in fileNameCompletion, on systems where case is ignored
Claus Gittinger <cg@exept.de>
parents:
3768
diff
changeset
|
5162 |
]. |
e2a75c79c625
ignore case in fileNameCompletion, on systems where case is ignored
Claus Gittinger <cg@exept.de>
parents:
3768
diff
changeset
|
5163 |
|
2978
e466e478fa43
Handle errors in #filenameCompletion:
Stefan Vogel <sv@exept.de>
parents:
2977
diff
changeset
|
5164 |
dir class errorReporter openErrorSignal handle:[:ex| |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5165 |
^ #(). |
2978
e466e478fa43
Handle errors in #filenameCompletion:
Stefan Vogel <sv@exept.de>
parents:
2977
diff
changeset
|
5166 |
] do:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5167 |
dir directoryContents do:[:fileName | |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5168 |
((fileName ~= '.') and:[fileName ~= parentString]) ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5169 |
((caseless and:[fileName asLowercase startsWith:lcBaseName]) |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5170 |
or:[caseless not and:[fileName startsWith:baseName]]) ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5171 |
matching add:fileName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5172 |
] |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5173 |
] |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5174 |
]. |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5175 |
]. |
6556
367bc84f51fc
filename completion better if an empty basename is shown
Claus Gittinger <cg@exept.de>
parents:
6529
diff
changeset
|
5176 |
|
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5177 |
(nMatch := matching size) > 1 ifTrue:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5178 |
" |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5179 |
find the longest common prefix |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5180 |
" |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5181 |
matchLen := baseName size. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5182 |
matchLen > matching first size ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5183 |
try := baseName. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5184 |
allMatching := false |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5185 |
] ifFalse:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5186 |
try := matching first copyTo:matchLen. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5187 |
allMatching := true. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5188 |
]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5189 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5190 |
[allMatching] whileTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5191 |
matching do:[:aName | |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5192 |
((caseless and:[aName asLowercase startsWith:try asLowercase]) |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5193 |
or:[caseless not and:[aName startsWith:try]]) ifFalse:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5194 |
allMatching := false |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5195 |
] |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5196 |
]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5197 |
allMatching ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5198 |
matchLen < matching first size ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5199 |
matchLen := matchLen + 1. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5200 |
try := matching first copyTo:matchLen. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5201 |
] ifFalse:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5202 |
allMatching := false |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5203 |
] |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5204 |
] ifFalse:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5205 |
try := matching first copyTo:matchLen - 1. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5206 |
] |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5207 |
]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5208 |
" |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5209 |
and set my name to the last full match |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5210 |
" |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5211 |
nameString := nm := try |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5212 |
]. |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5213 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5214 |
" |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5215 |
if I had a directory-prefix, change names in collection ... |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5216 |
" |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5217 |
prefix notNil ifTrue:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5218 |
(prefix endsWith:sepString) ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5219 |
"/ avoid introducing double slashes |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5220 |
prefix := prefix copyButLast:(sepString size). |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5221 |
]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5222 |
matching := matching collect:[:n | prefix , sepString , n]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5223 |
nMatch == 1 ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5224 |
nameString := nm := matching first |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5225 |
] ifFalse:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5226 |
nMatch > 1 ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5227 |
nameString := nm := prefix , sepString , nm |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5228 |
] |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5229 |
] |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5230 |
] ifFalse:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5231 |
nMatch == 1 ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5232 |
nameString := nm := matching first |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5233 |
] |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5234 |
]. |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5235 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5236 |
" |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5237 |
return the match-set, so caller can decide what to do |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5238 |
(i.e. show the matches, output a warning etc ...) |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5239 |
" |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5240 |
^ matching |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5241 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5242 |
" trivial cases: |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5243 |
|
11341
22494c109161
fixed filename completion for root directories (added another sep-char)
Claus Gittinger <cg@exept.de>
parents:
11192
diff
changeset
|
5244 |
'../' asFilename filenameCompletion -> empty |
22494c109161
fixed filename completion for root directories (added another sep-char)
Claus Gittinger <cg@exept.de>
parents:
11192
diff
changeset
|
5245 |
'/' asFilename filenameCompletion -> empty |
22494c109161
fixed filename completion for root directories (added another sep-char)
Claus Gittinger <cg@exept.de>
parents:
11192
diff
changeset
|
5246 |
'/usr/' asFilename filenameCompletion -> empty |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5247 |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5248 |
'mak' asFilename filenameCompletion |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5249 |
'Make' asFilename filenameCompletion |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5250 |
'Makef' asFilename filenameCompletion |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5251 |
'/u' asFilename filenameCompletion |
7088
cc3233554827
Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents:
7075
diff
changeset
|
5252 |
'../../libpr' asFilename filenameCompletion |
cc3233554827
Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents:
7075
diff
changeset
|
5253 |
'/etc/mail/auth/xx' asFilename filenameCompletion |
11341
22494c109161
fixed filename completion for root directories (added another sep-char)
Claus Gittinger <cg@exept.de>
parents:
11192
diff
changeset
|
5254 |
|
22494c109161
fixed filename completion for root directories (added another sep-char)
Claus Gittinger <cg@exept.de>
parents:
11192
diff
changeset
|
5255 |
'c:\pr' asFilename filenameCompletion -> matching names |
22494c109161
fixed filename completion for root directories (added another sep-char)
Claus Gittinger <cg@exept.de>
parents:
11192
diff
changeset
|
5256 |
'c:\pr' asFilename filenameCompletion; yourself -> side effect: name changed to longest match |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5257 |
'c:\p' asFilename filenameCompletion |
11341
22494c109161
fixed filename completion for root directories (added another sep-char)
Claus Gittinger <cg@exept.de>
parents:
11192
diff
changeset
|
5258 |
'c:\' asFilename filenameCompletion -> empty |
22494c109161
fixed filename completion for root directories (added another sep-char)
Claus Gittinger <cg@exept.de>
parents:
11192
diff
changeset
|
5259 |
'c:' asFilename filenameCompletion -> empty |
22494c109161
fixed filename completion for root directories (added another sep-char)
Claus Gittinger <cg@exept.de>
parents:
11192
diff
changeset
|
5260 |
'\' asFilename filenameCompletion -> empty |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5261 |
" |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5262 |
|
10793
0475c364e80a
care for bad (non-filename) arg in fileNameCompletion:
Claus Gittinger <cg@exept.de>
parents:
10780
diff
changeset
|
5263 |
"Modified: / 22-09-1997 / 18:03:33 / stefan" |
0475c364e80a
care for bad (non-filename) arg in fileNameCompletion:
Claus Gittinger <cg@exept.de>
parents:
10780
diff
changeset
|
5264 |
"Modified: / 17-11-2007 / 14:31:08 / cg" |
2903 | 5265 |
! |
5266 |
||
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5267 |
head |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5268 |
"return the directory name as a string. |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5269 |
An alias for directoryName, for ST-80 compatiblity. |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5270 |
(this is almost equivalent to #directory, but returns |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5271 |
a string instead of a Filename instance)" |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5272 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5273 |
^ self directoryName |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5274 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5275 |
" |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5276 |
Filename currentDirectory head |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5277 |
'Makefile' asFilename head |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5278 |
'/foo/bar/baz.st' asFilename head |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5279 |
" |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5280 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5281 |
"Modified: 29.2.1996 / 20:21:25 / cg" |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5282 |
! |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5283 |
|
7120 | 5284 |
isAbsolute |
5285 |
"return true, if the receiver represents an absolute pathname |
|
5286 |
(in contrast to one relative to the current directory)." |
|
5287 |
||
19670 | 5288 |
((nameString startsWith:self species separator) or:[nameString startsWith:$~]) ifTrue:[^ true]. |
7120 | 5289 |
^ self isVolumeAbsolute |
5290 |
||
5291 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5292 |
'/foo/bar' asFilename isAbsolute |
14220
2a3457b016be
Fix the '~/dir/name' resolution fow windows
Stefan Vogel <sv@exept.de>
parents:
14218
diff
changeset
|
5293 |
'~/bla' asFilename isAbsolute |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5294 |
'..' asFilename isAbsolute |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5295 |
'..' asAbsoluteFilename isAbsolute |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5296 |
'source/SBrowser.st' asFilename isAbsolute |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5297 |
'source/SBrowser.st' asFilename isRelative |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5298 |
'SBrowser.st' asFilename isRelative |
7120 | 5299 |
" |
5300 |
! |
|
5301 |
||
5302 |
isExplicitRelative |
|
5303 |
"return true, if this name is an explicit relative name |
|
5304 |
(i.e. starts with './' or '../', to avoid path-prepending)" |
|
5305 |
||
5306 |
^ false |
|
5307 |
! |
|
5308 |
||
5309 |
isImplicit |
|
5310 |
"return true, if the receiver represents a builtin file. |
|
5311 |
The definitions of builtin files depends on the OS used; |
|
5312 |
on UNIX, '.' and '..' are builtin names." |
|
5313 |
||
5314 |
^ false |
|
5315 |
||
5316 |
"Created: 18.9.1997 / 18:04:51 / stefan" |
|
5317 |
! |
|
5318 |
||
6773
26415b61ad09
isMountPoint & isParentDirectoryOf & allParentDirsDo:
penk
parents:
6771
diff
changeset
|
5319 |
isParentDirectoryOf:aFilenameOrString |
16389 | 5320 |
"Answer true, if myself is a parent directory of aFilenameOrString. |
5321 |
Unexpected results may be returned, if one of myself or aFilenameOrString does |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5322 |
not exist and relative and absolute path names are mixed |
18686 | 5323 |
('/' asFilename isParentDirectoryOf:'../noExistent' -> false) |
16389 | 5324 |
|
5325 |
Warning: maybe symbolic links must be resolved which could lead to automounting" |
|
5326 |
||
5327 |
|filenameArg otherNames myNames myName| |
|
6773
26415b61ad09
isMountPoint & isParentDirectoryOf & allParentDirsDo:
penk
parents:
6771
diff
changeset
|
5328 |
|
7236
2b8b8680f5b9
isParentDirectoryOf - fix for directories
Claus Gittinger <cg@exept.de>
parents:
7134
diff
changeset
|
5329 |
filenameArg := aFilenameOrString asFilename. |
16389 | 5330 |
|
5331 |
"first do a simple comparison" |
|
5332 |
otherNames := self class canonicalizedNameComponents:filenameArg name. |
|
5333 |
myNames := self class canonicalizedNameComponents:self name. |
|
5334 |
((otherNames startsWith:myNames) and:[myNames first ~= self class parentDirectoryName]) ifTrue:[ |
|
19599 | 5335 |
^ otherNames ~= myNames |
7236
2b8b8680f5b9
isParentDirectoryOf - fix for directories
Claus Gittinger <cg@exept.de>
parents:
7134
diff
changeset
|
5336 |
]. |
6773
26415b61ad09
isMountPoint & isParentDirectoryOf & allParentDirsDo:
penk
parents:
6771
diff
changeset
|
5337 |
|
16389 | 5338 |
"fall back - try it again with ~ substitution and symbolic links resolved" |
5339 |
otherNames := self class canonicalizedNameComponents:filenameArg pathName. |
|
5340 |
myNames := self class canonicalizedNameComponents:self pathName. |
|
5341 |
(otherNames startsWith:myNames) ifTrue:[ |
|
19599 | 5342 |
^ otherNames ~= myNames |
6773
26415b61ad09
isMountPoint & isParentDirectoryOf & allParentDirsDo:
penk
parents:
6771
diff
changeset
|
5343 |
]. |
26415b61ad09
isMountPoint & isParentDirectoryOf & allParentDirsDo:
penk
parents:
6771
diff
changeset
|
5344 |
|
16389 | 5345 |
myName := self class nameFromComponents:myNames. |
6773
26415b61ad09
isMountPoint & isParentDirectoryOf & allParentDirsDo:
penk
parents:
6771
diff
changeset
|
5346 |
filenameArg allParentDirectoriesDo:[:parent | |
19599 | 5347 |
parent pathName = myName ifTrue:[^ true]. |
6773
26415b61ad09
isMountPoint & isParentDirectoryOf & allParentDirsDo:
penk
parents:
6771
diff
changeset
|
5348 |
]. |
26415b61ad09
isMountPoint & isParentDirectoryOf & allParentDirsDo:
penk
parents:
6771
diff
changeset
|
5349 |
^ false. |
26415b61ad09
isMountPoint & isParentDirectoryOf & allParentDirsDo:
penk
parents:
6771
diff
changeset
|
5350 |
|
26415b61ad09
isMountPoint & isParentDirectoryOf & allParentDirsDo:
penk
parents:
6771
diff
changeset
|
5351 |
" |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5352 |
'/etc' asFilename isParentDirectoryOf:'/etc/passwd' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5353 |
'etc' asFilename isParentDirectoryOf:'etc/passwd' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5354 |
'/etc' asFilename isParentDirectoryOf:'/etc/' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5355 |
'/etc' asFilename isParentDirectoryOf:'/etc' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5356 |
'/et' asFilename isParentDirectoryOf:'/etc' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5357 |
'/home' asFilename isParentDirectoryOf:Filename currentDirectory |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5358 |
'~' asFilename isParentDirectoryOf:Filename currentDirectory |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5359 |
'~' asFilename isParentDirectoryOf:'.' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5360 |
'~' asFilename isParentDirectoryOf:'..' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5361 |
'~' asFilename isParentDirectoryOf:'../smalltalk' |
18686 | 5362 |
'../..' asFilename isParentDirectoryOf:'../nonExistent' |
5363 |
'..' asFilename isParentDirectoryOf:'../../nonExistent' |
|
5364 |
'/' asFilename isParentDirectoryOf:'../nonExistent' |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5365 |
'/' asFilename isParentDirectoryOf:'/phys/qnx' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5366 |
" |
6773
26415b61ad09
isMountPoint & isParentDirectoryOf & allParentDirsDo:
penk
parents:
6771
diff
changeset
|
5367 |
! |
26415b61ad09
isMountPoint & isParentDirectoryOf & allParentDirsDo:
penk
parents:
6771
diff
changeset
|
5368 |
|
7120 | 5369 |
isRelative |
5370 |
"return true, if this name is interpreted relative to some |
|
5371 |
directory (opposite of absolute)" |
|
5372 |
||
5373 |
^ self isAbsolute not |
|
5374 |
||
5375 |
" |
|
5376 |
'./foo/bar' asFilename isRelative |
|
5377 |
'../../foo/bar' asFilename isRelative |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5378 |
'/foo/bar' asFilename isRelative |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5379 |
'bar' asFilename isRelative |
7120 | 5380 |
" |
5381 |
||
5382 |
"Modified: 16.1.1997 / 01:19:14 / cg" |
|
5383 |
! |
|
5384 |
||
5385 |
isRootDirectory |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5386 |
"return true, if I represent the root directory |
7120 | 5387 |
(i.e. I have no parentDir)" |
5388 |
||
5389 |
"/ mhmh - should we use: |
|
5390 |
"/ |
|
5391 |
"/ parentDir := self construct:'..'. |
|
5392 |
"/ (parentDir exists |
|
5393 |
"/ and:[parentDir isDirectory |
|
5394 |
"/ and:[parentDir id ~= self id]]) ifTrue:[ |
|
5395 |
"/ ^ false |
|
5396 |
"/ ]. |
|
5397 |
"/ ^ true |
|
5398 |
"/ |
|
5399 |
||
5400 |
^ self pathName = Filename rootDirectory pathName |
|
5401 |
||
5402 |
"Modified: 23.10.1997 / 00:38:35 / cg" |
|
5403 |
! |
|
5404 |
||
5405 |
isVolumeAbsolute |
|
5406 |
"return true, if the receiver represents an absolute pathname |
|
5407 |
on some disk volume (MSDOS only)" |
|
5408 |
||
5409 |
^ false |
|
5410 |
||
5411 |
"Modified: 7.9.1997 / 23:54:33 / cg" |
|
5412 |
! |
|
5413 |
||
2987
87a7ad1f4519
Simplify #accessTime and #modificationTime
Stefan Vogel <sv@exept.de>
parents:
2982
diff
changeset
|
5414 |
localPathName |
87a7ad1f4519
Simplify #accessTime and #modificationTime
Stefan Vogel <sv@exept.de>
parents:
2982
diff
changeset
|
5415 |
"return the full pathname of the file represented by the receiver, |
87a7ad1f4519
Simplify #accessTime and #modificationTime
Stefan Vogel <sv@exept.de>
parents:
2982
diff
changeset
|
5416 |
but without any volume information. |
87a7ad1f4519
Simplify #accessTime and #modificationTime
Stefan Vogel <sv@exept.de>
parents:
2982
diff
changeset
|
5417 |
Only makes a difference on MSDOS & VMS systems." |
87a7ad1f4519
Simplify #accessTime and #modificationTime
Stefan Vogel <sv@exept.de>
parents:
2982
diff
changeset
|
5418 |
|
87a7ad1f4519
Simplify #accessTime and #modificationTime
Stefan Vogel <sv@exept.de>
parents:
2982
diff
changeset
|
5419 |
^ self pathName |
87a7ad1f4519
Simplify #accessTime and #modificationTime
Stefan Vogel <sv@exept.de>
parents:
2982
diff
changeset
|
5420 |
! |
87a7ad1f4519
Simplify #accessTime and #modificationTime
Stefan Vogel <sv@exept.de>
parents:
2982
diff
changeset
|
5421 |
|
615 | 5422 |
name |
5423 |
"return the name of the file represented by the receiver as a string. |
|
883 | 5424 |
This may or may not be a relative name (i.e. include ..'s). |
615 | 5425 |
See also: pathName" |
174 | 5426 |
|
6773
26415b61ad09
isMountPoint & isParentDirectoryOf & allParentDirsDo:
penk
parents:
6771
diff
changeset
|
5427 |
"/ self isAbsolute ifTrue:[^ self pathName]. |
615 | 5428 |
^ nameString |
174 | 5429 |
|
5430 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5431 |
'/foo/bar' asFilename name |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5432 |
'/foo/bar' asFilename pathName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5433 |
'.' asFilename name |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5434 |
'.' asFilename pathName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5435 |
'../..' asFilename name |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5436 |
'../..' asFilename pathName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5437 |
'bitmaps' asFilename name |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5438 |
'bitmaps' asFilename pathName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5439 |
'/tmp/../usr' asFilename name |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5440 |
'/tmp/../usr' asFilename pathName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5441 |
'source/..' asFilename name |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5442 |
'source/..' asFilename pathName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5443 |
'/tmp/..' asFilename name |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5444 |
'/tmp/..' asFilename pathName |
92 | 5445 |
" |
538
b9337c6c55bb
added recursiveRemove; remove now also removes directories
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
5446 |
|
883 | 5447 |
"Modified: 18.1.1996 / 21:36:27 / cg" |
538
b9337c6c55bb
added recursiveRemove; remove now also removes directories
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
5448 |
! |
b9337c6c55bb
added recursiveRemove; remove now also removes directories
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
5449 |
|
7308 | 5450 |
nameString |
5451 |
"raw access to nameString - req'd for xml-store/reload" |
|
5452 |
||
5453 |
^ nameString |
|
5454 |
! |
|
5455 |
||
5456 |
nameString:aString |
|
5457 |
"raw access to nameString - req'd for xml-store/reload" |
|
5458 |
||
5459 |
nameString := aString |
|
5460 |
! |
|
5461 |
||
615 | 5462 |
pathName |
5463 |
"return the full pathname of the file represented by the receiver, |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5464 |
as a string. This will not include ..'s. |
1317 | 5465 |
If the path represented by the receiver does NOT represent a valid path, |
5466 |
no compression will be done (for now; this may change). |
|
5467 |
See also: name" |
|
538
b9337c6c55bb
added recursiveRemove; remove now also removes directories
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
5468 |
|
b9337c6c55bb
added recursiveRemove; remove now also removes directories
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
5469 |
|
1317 | 5470 |
"/ sep := self class separator. |
5471 |
"/ (nameString startsWith:sep) ifTrue:[ |
|
5472 |
"/ parentName := self class parentDirectoryName. |
|
5473 |
"/ (nameString findString:parentName) == 0 ifTrue:[ |
|
5474 |
"/ ^ nameString |
|
5475 |
"/ ] |
|
5476 |
"/ ]. |
|
15811 | 5477 |
^ OperatingSystem pathNameOf:(self species nameWithSpecialExpansions:nameString). |
2 | 5478 |
|
92 | 5479 |
" |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5480 |
'/foo/bar' asFilename pathName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5481 |
'.' asFilename pathName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5482 |
'../..' asFilename pathName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5483 |
'../..' asFilename name |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5484 |
'/tmp/../usr' asFilename pathName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5485 |
'/././usr' asFilename pathName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5486 |
'~/..' asFilename pathName |
92 | 5487 |
" |
159 | 5488 |
|
1317 | 5489 |
"Modified: 27.4.1996 / 18:19:52 / cg" |
174 | 5490 |
! |
5491 |
||
11658 | 5492 |
physicalFilename |
5493 |
"return the fileName representing the physical file as represented by the receiver, |
|
5494 |
If the receiver represents a symbolic link, thats the fileName of the |
|
19440 | 5495 |
final target. Otherwise, its the receiver's pathName itself. |
11658 | 5496 |
If any file along the symbolic path does not exist (i.e. is a broken link), |
5497 |
nil is returned." |
|
5498 |
||
5499 |
|pathOrNil| |
|
5500 |
||
5501 |
pathOrNil := self physicalPathName. |
|
5502 |
pathOrNil isNil ifTrue:[ |
|
19599 | 5503 |
^ nil |
11658 | 5504 |
]. |
5505 |
^ pathOrNil asFilename |
|
5506 |
||
5507 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5508 |
'/foo/bar' asFilename physicalFileName |
11658 | 5509 |
" |
5510 |
! |
|
5511 |
||
2013
5053effe0156
commentary; added #physicalPathName
Claus Gittinger <cg@exept.de>
parents:
2012
diff
changeset
|
5512 |
physicalPathName |
5053effe0156
commentary; added #physicalPathName
Claus Gittinger <cg@exept.de>
parents:
2012
diff
changeset
|
5513 |
"return the full pathname of the physical file represented by the receiver, |
5053effe0156
commentary; added #physicalPathName
Claus Gittinger <cg@exept.de>
parents:
2012
diff
changeset
|
5514 |
If the receiver represents a symbolic link, thats the fileName of the |
19440 | 5515 |
final target. Otherwise, its the receiver's pathName itself. |
2013
5053effe0156
commentary; added #physicalPathName
Claus Gittinger <cg@exept.de>
parents:
2012
diff
changeset
|
5516 |
If any file along the symbolic path does not exist (i.e. is a broken link), |
5053effe0156
commentary; added #physicalPathName
Claus Gittinger <cg@exept.de>
parents:
2012
diff
changeset
|
5517 |
nil is returned." |
5053effe0156
commentary; added #physicalPathName
Claus Gittinger <cg@exept.de>
parents:
2012
diff
changeset
|
5518 |
|
8477
c962d56c1973
#linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents:
8280
diff
changeset
|
5519 |
|t path info| |
c962d56c1973
#linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents:
8280
diff
changeset
|
5520 |
|
c962d56c1973
#linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents:
8280
diff
changeset
|
5521 |
info := self linkInfo. |
c962d56c1973
#linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents:
8280
diff
changeset
|
5522 |
info isNil ifTrue:[ |
19599 | 5523 |
" I do not exist" |
5524 |
^ nil. |
|
2013
5053effe0156
commentary; added #physicalPathName
Claus Gittinger <cg@exept.de>
parents:
2012
diff
changeset
|
5525 |
]. |
8477
c962d56c1973
#linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents:
8280
diff
changeset
|
5526 |
info isSymbolicLink ifFalse:[ |
19599 | 5527 |
^ self pathName |
8477
c962d56c1973
#linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents:
8280
diff
changeset
|
5528 |
]. |
c962d56c1973
#linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents:
8280
diff
changeset
|
5529 |
|
2013
5053effe0156
commentary; added #physicalPathName
Claus Gittinger <cg@exept.de>
parents:
2012
diff
changeset
|
5530 |
t := self. |
8477
c962d56c1973
#linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents:
8280
diff
changeset
|
5531 |
[ |
19599 | 5532 |
path := info path. |
5533 |
path isNil ifTrue:[ |
|
5534 |
"/ cannot happen |
|
5535 |
^ nil |
|
5536 |
]. |
|
5537 |
path asFilename isAbsolute ifTrue:[ |
|
5538 |
t := path asFilename |
|
5539 |
] ifFalse:[ |
|
5540 |
t := (self species named:t directoryName) construct:path. |
|
5541 |
]. |
|
5542 |
info := t linkInfo. |
|
5543 |
info isNil ifTrue:[ |
|
5544 |
"t does not exist" |
|
5545 |
^ nil |
|
5546 |
]. |
|
8477
c962d56c1973
#linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents:
8280
diff
changeset
|
5547 |
] doWhile:[info isSymbolicLink]. |
c962d56c1973
#linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents:
8280
diff
changeset
|
5548 |
|
2013
5053effe0156
commentary; added #physicalPathName
Claus Gittinger <cg@exept.de>
parents:
2012
diff
changeset
|
5549 |
^ t pathName |
5053effe0156
commentary; added #physicalPathName
Claus Gittinger <cg@exept.de>
parents:
2012
diff
changeset
|
5550 |
|
5053effe0156
commentary; added #physicalPathName
Claus Gittinger <cg@exept.de>
parents:
2012
diff
changeset
|
5551 |
" |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5552 |
'/foo/bar' asFilename physicalPathName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5553 |
'.' asFilename physicalPathName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5554 |
'../..' asFilename physicalPathName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5555 |
'/usr/tmp' asFilename physicalPathName |
2013
5053effe0156
commentary; added #physicalPathName
Claus Gittinger <cg@exept.de>
parents:
2012
diff
changeset
|
5556 |
" |
5053effe0156
commentary; added #physicalPathName
Claus Gittinger <cg@exept.de>
parents:
2012
diff
changeset
|
5557 |
|
5053effe0156
commentary; added #physicalPathName
Claus Gittinger <cg@exept.de>
parents:
2012
diff
changeset
|
5558 |
"Modified: 21.12.1996 / 15:29:50 / cg" |
5053effe0156
commentary; added #physicalPathName
Claus Gittinger <cg@exept.de>
parents:
2012
diff
changeset
|
5559 |
! |
5053effe0156
commentary; added #physicalPathName
Claus Gittinger <cg@exept.de>
parents:
2012
diff
changeset
|
5560 |
|
615 | 5561 |
tail |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5562 |
"the file's name without directory prefix as a string. |
615 | 5563 |
An alias for baseName, for ST-80 compatiblity." |
174 | 5564 |
|
615 | 5565 |
^ self baseName |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5566 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5567 |
" |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5568 |
Filename currentDirectory tail |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5569 |
'Makefile' asFilename tail |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5570 |
'/foo/bar/baz.st' asFilename tail |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5571 |
" |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5572 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5573 |
"Modified: 29.2.1996 / 20:19:50 / cg" |
2629 | 5574 |
! |
5575 |
||
7307
9cae11d1fea1
new tail: to get the last n path components (as String)
Stefan Vogel <sv@exept.de>
parents:
7291
diff
changeset
|
5576 |
tail:nComponents |
9cae11d1fea1
new tail: to get the last n path components (as String)
Stefan Vogel <sv@exept.de>
parents:
7291
diff
changeset
|
5577 |
"return the last n components of myself. |
9cae11d1fea1
new tail: to get the last n path components (as String)
Stefan Vogel <sv@exept.de>
parents:
7291
diff
changeset
|
5578 |
- thats the file/directory name without leading parent-dirs. |
9cae11d1fea1
new tail: to get the last n path components (as String)
Stefan Vogel <sv@exept.de>
parents:
7291
diff
changeset
|
5579 |
(i.e. '/usr/lib/st/file' asFilename tail:2 -> 'st/file' |
9cae11d1fea1
new tail: to get the last n path components (as String)
Stefan Vogel <sv@exept.de>
parents:
7291
diff
changeset
|
5580 |
and '/usr/lib' asFilename tail:1 -> lib). |
9cae11d1fea1
new tail: to get the last n path components (as String)
Stefan Vogel <sv@exept.de>
parents:
7291
diff
changeset
|
5581 |
This method does not check if the path is valid. |
9cae11d1fea1
new tail: to get the last n path components (as String)
Stefan Vogel <sv@exept.de>
parents:
7291
diff
changeset
|
5582 |
The code here should work for Unix and MSDOS, but needs to be redefined |
9cae11d1fea1
new tail: to get the last n path components (as String)
Stefan Vogel <sv@exept.de>
parents:
7291
diff
changeset
|
5583 |
for VMS (and maybe others as well). |
9cae11d1fea1
new tail: to get the last n path components (as String)
Stefan Vogel <sv@exept.de>
parents:
7291
diff
changeset
|
5584 |
See also: #pathName, #directoryName and #directoryPathName." |
9cae11d1fea1
new tail: to get the last n path components (as String)
Stefan Vogel <sv@exept.de>
parents:
7291
diff
changeset
|
5585 |
|
9cae11d1fea1
new tail: to get the last n path components (as String)
Stefan Vogel <sv@exept.de>
parents:
7291
diff
changeset
|
5586 |
|sep components tail start| |
9cae11d1fea1
new tail: to get the last n path components (as String)
Stefan Vogel <sv@exept.de>
parents:
7291
diff
changeset
|
5587 |
|
15811 | 5588 |
sep := self species separator. |
7307
9cae11d1fea1
new tail: to get the last n path components (as String)
Stefan Vogel <sv@exept.de>
parents:
7291
diff
changeset
|
5589 |
components := self components. |
9cae11d1fea1
new tail: to get the last n path components (as String)
Stefan Vogel <sv@exept.de>
parents:
7291
diff
changeset
|
5590 |
start := components size - nComponents + 1. |
9cae11d1fea1
new tail: to get the last n path components (as String)
Stefan Vogel <sv@exept.de>
parents:
7291
diff
changeset
|
5591 |
start < 1 ifTrue:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5592 |
start := 1. |
7307
9cae11d1fea1
new tail: to get the last n path components (as String)
Stefan Vogel <sv@exept.de>
parents:
7291
diff
changeset
|
5593 |
]. |
9cae11d1fea1
new tail: to get the last n path components (as String)
Stefan Vogel <sv@exept.de>
parents:
7291
diff
changeset
|
5594 |
start = 1 ifTrue:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5595 |
tail := '' |
7307
9cae11d1fea1
new tail: to get the last n path components (as String)
Stefan Vogel <sv@exept.de>
parents:
7291
diff
changeset
|
5596 |
] ifFalse:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5597 |
tail := components at:start. |
7307
9cae11d1fea1
new tail: to get the last n path components (as String)
Stefan Vogel <sv@exept.de>
parents:
7291
diff
changeset
|
5598 |
]. |
9cae11d1fea1
new tail: to get the last n path components (as String)
Stefan Vogel <sv@exept.de>
parents:
7291
diff
changeset
|
5599 |
start+1 to:components size do:[:i| |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5600 |
tail := tail, sep, (components at:i). |
7307
9cae11d1fea1
new tail: to get the last n path components (as String)
Stefan Vogel <sv@exept.de>
parents:
7291
diff
changeset
|
5601 |
]. |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5602 |
^ tail. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5603 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5604 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5605 |
" |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5606 |
'/foo/bar' asFilename tail:1 |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5607 |
'/foo/bar' asFilename tail:2 |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5608 |
'/foo/bar' asFilename tail:3 |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5609 |
'/foo/bar.cc' asFilename tail:2 |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5610 |
'.' asFilename tail:3 |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5611 |
'..' asFilename tail:3 |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5612 |
'../..' asFilename tail:2 |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5613 |
'../../libbasic' asFilename tail:2 |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5614 |
'../../libbasic' asFilename asCanonicalizedFilename tail:2 |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5615 |
'../../libpr' asFilename tail:2 |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5616 |
'../../libbasic/Object.st' asFilename asCanonicalizedFilename tail:2 |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5617 |
'/' asFilename tail:2 |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5618 |
'\' asFilename tail:2 |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5619 |
'c:\' asFilename tail:2 |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5620 |
'\\idefix' asFilename tail:2 |
7307
9cae11d1fea1
new tail: to get the last n path components (as String)
Stefan Vogel <sv@exept.de>
parents:
7291
diff
changeset
|
5621 |
" |
9cae11d1fea1
new tail: to get the last n path components (as String)
Stefan Vogel <sv@exept.de>
parents:
7291
diff
changeset
|
5622 |
! |
9cae11d1fea1
new tail: to get the last n path components (as String)
Stefan Vogel <sv@exept.de>
parents:
7291
diff
changeset
|
5623 |
|
2629 | 5624 |
volume |
5625 |
"return the disc volume part of the name or an empty string. |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5626 |
This is only used with MSDOS and VMS filenames |
2906 | 5627 |
- by default (and on unix), an empty string is returned" |
5628 |
||
2629 | 5629 |
^ '' |
2906 | 5630 |
|
5631 |
"Modified: 8.9.1997 / 00:37:33 / cg" |
|
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5632 |
! ! |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5633 |
|
7120 | 5634 |
!Filename methodsFor:'queries-type'! |
5635 |
||
5636 |
isDirectory |
|
5637 |
"return true, if the receiver represents an existing, |
|
5638 |
readable directories pathname." |
|
5639 |
||
5640 |
^ OperatingSystem isDirectory:(self osNameForAccess) |
|
5641 |
||
5642 |
" |
|
5643 |
'/foo/bar' asFilename isDirectory |
|
5644 |
'/tmp' asFilename isDirectory |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5645 |
'Makefile' asFilename isDirectory |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5646 |
'c:\' asFilename isDirectory |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5647 |
'd:\' asFilename isDirectory |
7120 | 5648 |
" |
5649 |
||
5650 |
"Modified: / 21.9.1998 / 15:53:10 / cg" |
|
5651 |
! |
|
5652 |
||
5653 |
isNonEmptyDirectory |
|
5654 |
"return true, if the receiver represents an existing, |
|
5655 |
readable directories pathname, and the directory is not empty." |
|
5656 |
||
8280
0caa2f092e45
avoid expensive full-blocks (which return)
Claus Gittinger <cg@exept.de>
parents:
8243
diff
changeset
|
5657 |
FileStream openErrorSignal |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5658 |
handle:[:ex| ] |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5659 |
do:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5660 |
self directoryContentsDo:[:pathString|^ true]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5661 |
]. |
7120 | 5662 |
^ false. |
5663 |
||
5664 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5665 |
'/foo/bar' asFilename isNonEmptyDirectory |
7120 | 5666 |
'/tmp' asFilename isNonEmptyDirectory |
5667 |
'/tmp/empty' asFilename makeDirectory; isNonEmptyDirectory. |
|
5668 |
'/tmp/empty' asFilename removeDirectory. |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5669 |
'Makefile' asFilename isNonEmptyDirectory |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5670 |
'c:\' asFilename isNonEmptyDirectory |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5671 |
'd:\' asFilename isNonEmptyDirectory |
7120 | 5672 |
" |
5673 |
||
5674 |
"Modified: / 21.9.1998 / 15:53:10 / cg" |
|
5675 |
! |
|
5676 |
||
8836 | 5677 |
isRegularFile |
5678 |
"return true, if the receiver represents a plain, regular file" |
|
5679 |
||
5680 |
^ self type == #regular |
|
5681 |
||
5682 |
" |
|
5683 |
'/foo/bar' asFilename isRegularFile |
|
5684 |
'/tmp' asFilename isRegularFile |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5685 |
'Makefile' asFilename isRegularFile |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5686 |
'c:\' asFilename isRegularFile |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5687 |
'd:\' asFilename isRegularFile |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5688 |
'/dev/null' asFilename isRegularFile |
8836 | 5689 |
" |
5690 |
! |
|
5691 |
||
7120 | 5692 |
isSpecialFile |
5693 |
"return true, if the receiver represents a socket, named pipe, fifo |
|
5694 |
or device special file (i.e. anything non regular and non-directory)" |
|
5695 |
||
5696 |
|t| |
|
5697 |
||
5698 |
t := self type. |
|
5699 |
^ (t ~= #directory and:[t ~~ #regular and:[t ~~ #symbolicLink]]) |
|
5700 |
||
5701 |
" |
|
5702 |
'/foo/bar' asFilename isSpecialFile |
|
5703 |
'/tmp' asFilename isSpecialFile |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5704 |
'Makefile' asFilename isSpecialFile |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5705 |
'c:\' asFilename isSpecialFile |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5706 |
'd:\' asFilename isSpecialFile |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5707 |
'/dev/null' asFilename isSpecialFile |
7120 | 5708 |
" |
5709 |
! |
|
5710 |
||
5711 |
isSymbolicLink |
|
5712 |
"return true, if the file represented by the receiver is a symbolic |
|
5713 |
link. Notice that not all OS's support symbolic links; those that do |
|
5714 |
not will always return false." |
|
5715 |
||
5716 |
^ OperatingSystem isSymbolicLink:(self osNameForFile) |
|
5717 |
||
5718 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5719 |
'Make.proto' asFilename isSymbolicLink |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5720 |
'Makefile' asFilename isSymbolicLink |
7120 | 5721 |
" |
5722 |
! ! |
|
5723 |
||
6529 | 5724 |
!Filename methodsFor:'reading-directories'! |
5725 |
||
5726 |
directoryContents |
|
5727 |
"return the contents of the directory as a collection of strings. |
|
5728 |
This excludes any entries for '.' or '..'. |
|
5729 |
Returns nil for non-existing directories; however, this behavior |
|
5730 |
may be changed in the near future, to raise an exception instead. |
|
5731 |
So users of this method better test for existing directory before. |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5732 |
Notice: |
19821 | 5733 |
this returns the file-names as strings; |
5734 |
see also #directoryContentsAsFilenames, which returns fileName instances." |
|
5735 |
||
5736 |
^ OrderedCollection withCollectedContents:[:coll | |
|
5737 |
self directoryContentsDo:[:each | coll add:each]] |
|
6529 | 5738 |
|
5739 |
" |
|
5740 |
'.' asFilename directoryContents |
|
5741 |
'/XXXdoesNotExist' asFilename directoryContents |
|
5742 |
" |
|
5743 |
||
5744 |
"Modified: / 18.9.1997 / 18:42:23 / stefan" |
|
5745 |
"Modified: / 3.8.1998 / 21:36:21 / cg" |
|
5746 |
! |
|
5747 |
||
5748 |
directoryContentsAsFilenames |
|
5749 |
"return the contents of the directory as a collection of filenames. |
|
5750 |
This excludes any entries for '.' or '..'. |
|
5751 |
Returns nil for non-existing directories; however, this behavior |
|
5752 |
may be changed in the near future, to raise an exception instead. |
|
5753 |
So users of this method better test for existing directory before. |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5754 |
Notice: |
19821 | 5755 |
this returns the file-names as fileName instances; |
5756 |
see also #directoryContents, which returns strings." |
|
5757 |
||
5758 |
^ OrderedCollection withCollectedContents:[:coll | |
|
5759 |
self directoryContentsAsFilenamesDo:[:each | coll add:each]] |
|
6529 | 5760 |
|
5761 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5762 |
'.' asFilename directoryContentsAsFilenames |
6529 | 5763 |
'/XXXdoesNotExist' asFilename directoryContentsAsFilenames |
5764 |
" |
|
5765 |
! |
|
5766 |
||
5767 |
fullDirectoryContents |
|
5768 |
"return the full contents of the directory as a collection of strings. |
|
5769 |
This is much like #directoryContents, but includes an entry for the |
|
5770 |
parent directory, if there is one. |
|
5771 |
Returns nil for non-existing directories; however, this behavior |
|
5772 |
may be changed in the near future, to raise an exception instead. |
|
5773 |
So users of this method better test for existing directory before." |
|
5774 |
||
5775 |
|files| |
|
5776 |
||
12910 | 5777 |
"here we get the files without '.' and '..'" |
6529 | 5778 |
files := self directoryContents. |
5779 |
files isNil ifTrue:[ |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5780 |
"/ mhmh - that one does not exist |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5781 |
^ files |
6529 | 5782 |
]. |
5783 |
||
12910 | 5784 |
files addFirst:'..'. |
6529 | 5785 |
^ files |
5786 |
||
5787 |
" |
|
5788 |
'.' asFilename fullDirectoryContents |
|
5789 |
'/XXXdoesNotExist' asFilename fullDirectoryContents |
|
5790 |
'd:\FET' asFilename fullDirectoryContents |
|
5791 |
" |
|
5792 |
||
5793 |
"Modified: / 21.9.1998 / 15:33:07 / cg" |
|
5794 |
! |
|
5795 |
||
5796 |
recursiveDirectoryContents |
|
5797 |
"return the contents of the directory and all subdirectories |
|
5798 |
as a collection of strings. |
|
5799 |
This excludes any entries for '.' or '..'. |
|
5800 |
Subdirectory files are included with a relative pathname. |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5801 |
Notice: |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5802 |
this returns the file-names as strings; |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5803 |
see also #recursiveDirectoryContentsAsFilenames, which returns fileName instances. |
7697
1cb1a31cd2c2
recursiveDirectoryContentsAsFilenames
Claus Gittinger <cg@exept.de>
parents:
7685
diff
changeset
|
5804 |
|
6529 | 5805 |
Warning: this may take a long time to execute." |
5806 |
||
5807 |
|fileNames dirNames| |
|
5808 |
||
5809 |
fileNames := OrderedCollection new. |
|
5810 |
dirNames := OrderedCollection new. |
|
5811 |
self directoryContents do:[:f | |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5812 |
(self construct:f) isDirectory ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5813 |
dirNames add:f |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5814 |
] ifFalse:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5815 |
fileNames add:f |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5816 |
] |
6529 | 5817 |
]. |
5818 |
||
5819 |
dirNames do:[:dN | |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5820 |
|dd subFiles| |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5821 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5822 |
dd := dN asFilename. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5823 |
subFiles := (self construct:dN) recursiveDirectoryContents. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5824 |
fileNames addAll:(subFiles collect:[:f | dd constructString:f]) |
6529 | 5825 |
]. |
5826 |
^ fileNames. |
|
5827 |
||
5828 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5829 |
'.' asFilename recursiveDirectoryContents |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5830 |
'../../clients' asFilename recursiveDirectoryContents |
6529 | 5831 |
" |
7697
1cb1a31cd2c2
recursiveDirectoryContentsAsFilenames
Claus Gittinger <cg@exept.de>
parents:
7685
diff
changeset
|
5832 |
! |
1cb1a31cd2c2
recursiveDirectoryContentsAsFilenames
Claus Gittinger <cg@exept.de>
parents:
7685
diff
changeset
|
5833 |
|
1cb1a31cd2c2
recursiveDirectoryContentsAsFilenames
Claus Gittinger <cg@exept.de>
parents:
7685
diff
changeset
|
5834 |
recursiveDirectoryContentsAsFilenames |
1cb1a31cd2c2
recursiveDirectoryContentsAsFilenames
Claus Gittinger <cg@exept.de>
parents:
7685
diff
changeset
|
5835 |
"return the contents of the directory and all subdirectories |
1cb1a31cd2c2
recursiveDirectoryContentsAsFilenames
Claus Gittinger <cg@exept.de>
parents:
7685
diff
changeset
|
5836 |
as a collection of filenames. |
1cb1a31cd2c2
recursiveDirectoryContentsAsFilenames
Claus Gittinger <cg@exept.de>
parents:
7685
diff
changeset
|
5837 |
This excludes any entries for '.' or '..'. |
1cb1a31cd2c2
recursiveDirectoryContentsAsFilenames
Claus Gittinger <cg@exept.de>
parents:
7685
diff
changeset
|
5838 |
Returns nil for non-existing directories; however, this behavior |
1cb1a31cd2c2
recursiveDirectoryContentsAsFilenames
Claus Gittinger <cg@exept.de>
parents:
7685
diff
changeset
|
5839 |
may be changed in the near future, to raise an exception instead. |
1cb1a31cd2c2
recursiveDirectoryContentsAsFilenames
Claus Gittinger <cg@exept.de>
parents:
7685
diff
changeset
|
5840 |
So users of this method better test for existing directory before. |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5841 |
Notice: |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5842 |
this returns the file-names as fileName instances; |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5843 |
see also #recursiveDirectoryContents, which returns strings. |
7697
1cb1a31cd2c2
recursiveDirectoryContentsAsFilenames
Claus Gittinger <cg@exept.de>
parents:
7685
diff
changeset
|
5844 |
|
1cb1a31cd2c2
recursiveDirectoryContentsAsFilenames
Claus Gittinger <cg@exept.de>
parents:
7685
diff
changeset
|
5845 |
Warning: this may take a long time to execute." |
1cb1a31cd2c2
recursiveDirectoryContentsAsFilenames
Claus Gittinger <cg@exept.de>
parents:
7685
diff
changeset
|
5846 |
|
1cb1a31cd2c2
recursiveDirectoryContentsAsFilenames
Claus Gittinger <cg@exept.de>
parents:
7685
diff
changeset
|
5847 |
|names| |
1cb1a31cd2c2
recursiveDirectoryContentsAsFilenames
Claus Gittinger <cg@exept.de>
parents:
7685
diff
changeset
|
5848 |
|
1cb1a31cd2c2
recursiveDirectoryContentsAsFilenames
Claus Gittinger <cg@exept.de>
parents:
7685
diff
changeset
|
5849 |
names := self recursiveDirectoryContents. |
1cb1a31cd2c2
recursiveDirectoryContentsAsFilenames
Claus Gittinger <cg@exept.de>
parents:
7685
diff
changeset
|
5850 |
names isNil ifTrue:[^ nil]. |
12910 | 5851 |
^ names collect:[:entry | self construct:entry]. |
7697
1cb1a31cd2c2
recursiveDirectoryContentsAsFilenames
Claus Gittinger <cg@exept.de>
parents:
7685
diff
changeset
|
5852 |
|
1cb1a31cd2c2
recursiveDirectoryContentsAsFilenames
Claus Gittinger <cg@exept.de>
parents:
7685
diff
changeset
|
5853 |
" |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5854 |
'.' asFilename recursiveDirectoryContentsAsFilenames |
7697
1cb1a31cd2c2
recursiveDirectoryContentsAsFilenames
Claus Gittinger <cg@exept.de>
parents:
7685
diff
changeset
|
5855 |
'/XXXdoesNotExist' asFilename recursiveDirectoryContentsAsFilenames |
1cb1a31cd2c2
recursiveDirectoryContentsAsFilenames
Claus Gittinger <cg@exept.de>
parents:
7685
diff
changeset
|
5856 |
" |
6529 | 5857 |
! ! |
5858 |
||
5859 |
!Filename methodsFor:'reading-files'! |
|
5860 |
||
5861 |
binaryContentsOfEntireFile |
|
5862 |
"return the binary contents of the file (as a byteArray); |
|
7680 | 5863 |
Raises an error, if the file is unreadable/non-existing." |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5864 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5865 |
^ self |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5866 |
readingFileDo:[:s | |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5867 |
|nBytes bytes n result| |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5868 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5869 |
s binary. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5870 |
nBytes := self fileSize. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5871 |
(nBytes notNil and:[ nBytes ~~ 0 ]) ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5872 |
bytes := ByteArray uninitializedNew:nBytes. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5873 |
n := s nextBytes:nBytes into:bytes startingAt:1. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5874 |
n == nBytes ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5875 |
result := bytes |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5876 |
] ifFalse:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5877 |
result := bytes copyTo:n |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5878 |
] |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5879 |
] ifFalse:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5880 |
result := s contentsOfEntireFile |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5881 |
]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5882 |
result |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5883 |
] |
6529 | 5884 |
|
5885 |
" |
|
5886 |
'Makefile' asFilename binaryContentsOfEntireFile |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5887 |
'foobar' asFilename binaryContentsOfEntireFile |
6529 | 5888 |
" |
14446
479f02b4c705
changed: #binaryContentsOfEntireFile
Claus Gittinger <cg@exept.de>
parents:
14306
diff
changeset
|
5889 |
|
479f02b4c705
changed: #binaryContentsOfEntireFile
Claus Gittinger <cg@exept.de>
parents:
14306
diff
changeset
|
5890 |
"Modified: / 27-10-2012 / 19:42:07 / cg" |
6529 | 5891 |
! |
5892 |
||
5893 |
contents |
|
5894 |
"return the contents of the file as a collection of lines; |
|
7680 | 5895 |
Raises an error, if the file is unreadable/non-existing. |
6529 | 5896 |
See also #contentsOfEntireFile, which returns a string for textFiles. |
5897 |
CAVEAT: bad naming - but req'd for VW compatibility." |
|
5898 |
||
7888
e76fa60251dc
Remove obsolete nil-checks after opening streams
Stefan Vogel <sv@exept.de>
parents:
7846
diff
changeset
|
5899 |
^ self readingFileDo:[:s | s contents]. |
6529 | 5900 |
|
5901 |
" |
|
5902 |
'Makefile' asFilename contents |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5903 |
'foobar' asFilename contents |
6529 | 5904 |
" |
5905 |
||
5906 |
"Modified: / 2.7.1996 / 12:49:45 / stefan" |
|
5907 |
"Created: / 11.7.1996 / 14:09:11 / cg" |
|
5908 |
"Modified: / 15.10.1998 / 11:41:45 / cg" |
|
5909 |
! |
|
5910 |
||
10780 | 5911 |
contentsAsString |
5912 |
"to compensate for the bad naming, use this to make things explicit. |
|
5913 |
See also #contents, which returns the lines as stringCollection for textFiles." |
|
5914 |
||
11397
872cd41bbe05
oops - contentsAsString was endlessly recursive
Claus Gittinger <cg@exept.de>
parents:
11341
diff
changeset
|
5915 |
^ self contentsOfEntireFile |
872cd41bbe05
oops - contentsAsString was endlessly recursive
Claus Gittinger <cg@exept.de>
parents:
11341
diff
changeset
|
5916 |
|
872cd41bbe05
oops - contentsAsString was endlessly recursive
Claus Gittinger <cg@exept.de>
parents:
11341
diff
changeset
|
5917 |
" |
872cd41bbe05
oops - contentsAsString was endlessly recursive
Claus Gittinger <cg@exept.de>
parents:
11341
diff
changeset
|
5918 |
'Makefile' asFilename contentsAsString |
872cd41bbe05
oops - contentsAsString was endlessly recursive
Claus Gittinger <cg@exept.de>
parents:
11341
diff
changeset
|
5919 |
'foobar' asFilename contentsAsString |
10780 | 5920 |
" |
5921 |
||
5922 |
"Modified: / 02-07-1996 / 12:49:45 / stefan" |
|
5923 |
"Created: / 08-11-2007 / 13:29:59 / cg" |
|
5924 |
! |
|
5925 |
||
6529 | 5926 |
contentsOfEntireFile |
5927 |
"return the contents of the file as a string; |
|
7680 | 5928 |
Raises an error, if the file is unreadable/non-existing. |
6529 | 5929 |
See also #contents, which returns the lines as stringCollection for textFiles. |
5930 |
CAVEAT: bad naming - but req'd for VW compatibility." |
|
5931 |
||
7888
e76fa60251dc
Remove obsolete nil-checks after opening streams
Stefan Vogel <sv@exept.de>
parents:
7846
diff
changeset
|
5932 |
^ self readingFileDo:[:s | s contentsOfEntireFile]. |
6529 | 5933 |
|
5934 |
" |
|
5935 |
'Makefile' asFilename contentsOfEntireFile |
|
19043 | 5936 |
'smalltalk.rc' asFilename contentsOfEntireFile |
6529 | 5937 |
'foobar' asFilename contentsOfEntireFile |
5938 |
" |
|
5939 |
||
5940 |
"Modified: / 2.7.1996 / 12:49:45 / stefan" |
|
5941 |
"Modified: / 15.10.1998 / 11:42:05 / cg" |
|
5942 |
! |
|
5943 |
||
5944 |
readingFileDo:aBlock |
|
5945 |
"create a read-stream on the receiver file, evaluate aBlock, passing that stream as arg, |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5946 |
and return the blocks value. |
7088
cc3233554827
Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents:
7075
diff
changeset
|
5947 |
If the file cannot be opened, an exception is raised or |
cc3233554827
Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents:
7075
diff
changeset
|
5948 |
(old behavior, will vanish:)the block is evaluated with a nil argument. |
6529 | 5949 |
Ensures that the stream is closed." |
5950 |
||
5951 |
|stream result| |
|
5952 |
||
5953 |
stream := self readStream. |
|
5954 |
[ |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5955 |
result := aBlock value:stream |
6529 | 5956 |
] ensure:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5957 |
stream notNil ifTrue:[stream close] |
6529 | 5958 |
]. |
5959 |
^ result |
|
5960 |
||
5961 |
" |
|
5962 |
read the first line from some file: |
|
5963 |
||
5964 |
|rslt| |
|
5965 |
||
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5966 |
rslt := |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5967 |
'/etc/passwd' asFilename |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5968 |
readingFileDo:[:s | |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5969 |
s nextLine |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5970 |
]. |
6529 | 5971 |
Transcript showCR:rslt. |
5972 |
" |
|
5973 |
||
5974 |
" |
|
5975 |
find all used shells in /etc/passwd and count their usage: |
|
5976 |
||
5977 |
|rslt| |
|
5978 |
||
5979 |
rslt := |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5980 |
'/etc/passwd' asFilename |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5981 |
readingFileDo: |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5982 |
[:s | |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5983 |
|shells| |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5984 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5985 |
shells := Bag new. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5986 |
s linesDo: |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5987 |
[:line | |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5988 |
|parts| |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5989 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5990 |
parts := line asCollectionOfSubstringsSeparatedBy:$:. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5991 |
shells add:(parts seventh). |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5992 |
]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5993 |
shells contents |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5994 |
]. |
6529 | 5995 |
Transcript showCR:rslt. |
5996 |
" |
|
6771 | 5997 |
! |
5998 |
||
5999 |
readingLinesDo:aBlock |
|
6000 |
"create a read-stream on the receiver file, |
|
6001 |
evaluate aBlock for each line read from the stream. |
|
6002 |
If the file cannot be opened, an error is raised. |
|
6003 |
Ensures that the stream is closed." |
|
6004 |
||
6005 |
self readingFileDo:[:stream | |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6006 |
stream linesDo:aBlock |
6771 | 6007 |
]. |
6008 |
||
6009 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6010 |
'/etc/passwd' asFilename |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6011 |
readingLinesDo:[:eachLine | |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6012 |
Transcript showCR:eachLine. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6013 |
]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6014 |
" |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6015 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6016 |
" |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6017 |
'/etc/xxxxx' asFilename |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6018 |
readingLinesDo:[:eachLine | |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6019 |
Transcript showCR:eachLine. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6020 |
]. |
6771 | 6021 |
" |
6529 | 6022 |
! ! |
6023 |
||
2922 | 6024 |
!Filename methodsFor:'special accessing'! |
6025 |
||
6026 |
osName |
|
6027 |
"special - return the OS's name for the receiver." |
|
6028 |
||
6029 |
self isDirectory ifTrue:[ |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6030 |
^ self osNameForDirectory |
2922 | 6031 |
]. |
6032 |
^ self osNameForFile |
|
6033 |
! |
|
6034 |
||
2978
e466e478fa43
Handle errors in #filenameCompletion:
Stefan Vogel <sv@exept.de>
parents:
2977
diff
changeset
|
6035 |
osNameForAccess |
e466e478fa43
Handle errors in #filenameCompletion:
Stefan Vogel <sv@exept.de>
parents:
2977
diff
changeset
|
6036 |
"internal - return the OS's name for the receiver to |
3665 | 6037 |
access its fileInfo. |
6038 |
This may be redefined for systems, where a special suffix must be |
|
6039 |
added in order to access directories (or others) as a file. |
|
6040 |
(i.e. under VMS, a '.dir' suffix is added to access directories)" |
|
2978
e466e478fa43
Handle errors in #filenameCompletion:
Stefan Vogel <sv@exept.de>
parents:
2977
diff
changeset
|
6041 |
|
7064 | 6042 |
^ self osNameForFile |
3665 | 6043 |
|
6044 |
"Modified: / 21.7.1998 / 10:40:40 / cg" |
|
2978
e466e478fa43
Handle errors in #filenameCompletion:
Stefan Vogel <sv@exept.de>
parents:
2977
diff
changeset
|
6045 |
! |
e466e478fa43
Handle errors in #filenameCompletion:
Stefan Vogel <sv@exept.de>
parents:
2977
diff
changeset
|
6046 |
|
2922 | 6047 |
osNameForDirectory |
3753 | 6048 |
"internal - return the OS's name for the receiver to |
2922 | 6049 |
access it as a directory." |
6050 |
||
14218 | 6051 |
^ self osNameForFile |
3753 | 6052 |
|
6053 |
"Modified: / 12.8.1998 / 14:44:32 / cg" |
|
2922 | 6054 |
! |
6055 |
||
3720
d2529646d235
oops - needed a kludge to read the top directory under win32
Claus Gittinger <cg@exept.de>
parents:
3719
diff
changeset
|
6056 |
osNameForDirectoryContents |
3753 | 6057 |
"internal - return the OS's name for the receiver to |
3720
d2529646d235
oops - needed a kludge to read the top directory under win32
Claus Gittinger <cg@exept.de>
parents:
3719
diff
changeset
|
6058 |
access it as a directory when reading its contents." |
d2529646d235
oops - needed a kludge to read the top directory under win32
Claus Gittinger <cg@exept.de>
parents:
3719
diff
changeset
|
6059 |
|
d2529646d235
oops - needed a kludge to read the top directory under win32
Claus Gittinger <cg@exept.de>
parents:
3719
diff
changeset
|
6060 |
^ self osNameForDirectory |
d2529646d235
oops - needed a kludge to read the top directory under win32
Claus Gittinger <cg@exept.de>
parents:
3719
diff
changeset
|
6061 |
|
d2529646d235
oops - needed a kludge to read the top directory under win32
Claus Gittinger <cg@exept.de>
parents:
3719
diff
changeset
|
6062 |
"Created: / 3.8.1998 / 21:36:06 / cg" |
3753 | 6063 |
"Modified: / 12.8.1998 / 14:44:34 / cg" |
3720
d2529646d235
oops - needed a kludge to read the top directory under win32
Claus Gittinger <cg@exept.de>
parents:
3719
diff
changeset
|
6064 |
! |
d2529646d235
oops - needed a kludge to read the top directory under win32
Claus Gittinger <cg@exept.de>
parents:
3719
diff
changeset
|
6065 |
|
2922 | 6066 |
osNameForFile |
6067 |
"internal - return the OS's name for the receiver to |
|
6068 |
access it as a file." |
|
6069 |
||
19670 | 6070 |
(nameString startsWith:$~) ifFalse:[ |
6071 |
^ nameString. |
|
14220
2a3457b016be
Fix the '~/dir/name' resolution fow windows
Stefan Vogel <sv@exept.de>
parents:
14218
diff
changeset
|
6072 |
]. |
2a3457b016be
Fix the '~/dir/name' resolution fow windows
Stefan Vogel <sv@exept.de>
parents:
14218
diff
changeset
|
6073 |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6074 |
^ self species nameWithSpecialExpansions:nameString. |
2922 | 6075 |
! ! |
6076 |
||
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
6077 |
!Filename methodsFor:'suffixes'! |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
6078 |
|
11748 | 6079 |
addSuffix:aSuffix |
19440 | 6080 |
"return a new filename for the receiver's name with a additional suffix. |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6081 |
The new suffix is simply appended to the name, |
14306
f41ca29d9b54
comment/format in: #addSuffix:
Stefan Vogel <sv@exept.de>
parents:
14232
diff
changeset
|
6082 |
regardless whether there is already an existing suffix. |
f41ca29d9b54
comment/format in: #addSuffix:
Stefan Vogel <sv@exept.de>
parents:
14232
diff
changeset
|
6083 |
See also #withSuffix:" |
11748 | 6084 |
|
6085 |
|prefixName| |
|
6086 |
||
6087 |
prefixName := self name. |
|
6088 |
aSuffix isEmptyOrNil ifTrue:[ |
|
19599 | 6089 |
^ self species named:prefixName |
11748 | 6090 |
]. |
6091 |
||
15811 | 6092 |
^ self species named: |
19599 | 6093 |
(prefixName |
6094 |
, self species suffixSeparator asString |
|
6095 |
, aSuffix asString) |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6096 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6097 |
" |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6098 |
'abc.st' asFilename addSuffix:nil |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6099 |
'a.b.c' asFilename addSuffix:nil |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6100 |
'.b.c.' asFilename addSuffix:nil |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6101 |
'.b.c' asFilename addSuffix:nil |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6102 |
'.c.' asFilename addSuffix:nil |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6103 |
'.c' asFilename addSuffix:nil |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6104 |
'c.' asFilename addSuffix:nil |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6105 |
'.' asFilename addSuffix:nil |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6106 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6107 |
'abc.st' asFilename addSuffix:'o' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6108 |
'abc' asFilename addSuffix:'o' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6109 |
'a.b.c' asFilename addSuffix:'o' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6110 |
'a.b.c.' asFilename addSuffix:'o' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6111 |
'.b.c.' asFilename addSuffix:'o' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6112 |
'.c.' asFilename addSuffix:'o' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6113 |
'.c' asFilename addSuffix:'o' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6114 |
'c.' asFilename addSuffix:'o' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6115 |
'.' asFilename addSuffix:'o' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6116 |
'/foo/bar/baz.st' asFilename addSuffix:'c' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6117 |
'/foo/bar/baz.c' asFilename addSuffix:'st' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6118 |
'/foo/bar.c/baz.c' asFilename addSuffix:'st' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6119 |
'/foo/bar.c/baz' asFilename addSuffix:'st' |
11748 | 6120 |
" |
6121 |
! |
|
6122 |
||
2906 | 6123 |
hasSuffix:aSuffixString |
6124 |
"return true if my suffix is the same as aString. |
|
6125 |
This cares for systems, where case is ignored in filenames" |
|
6126 |
||
6127 |
|mySuffix| |
|
6128 |
||
6129 |
mySuffix := self suffix. |
|
15811 | 6130 |
self species isCaseSensitive ifTrue:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6131 |
^ mySuffix = aSuffixString |
2906 | 6132 |
]. |
6133 |
^ mySuffix asLowercase = aSuffixString asLowercase |
|
6134 |
||
6135 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6136 |
'abc.st' asFilename hasSuffix:'st' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6137 |
'abc.ST' asFilename hasSuffix:'st' |
7115
dea26def3167
prefix/suffix definition changed for files beginning with
Claus Gittinger <cg@exept.de>
parents:
7088
diff
changeset
|
6138 |
'.ST' asFilename hasSuffix:'st' -- false expected here |
dea26def3167
prefix/suffix definition changed for files beginning with
Claus Gittinger <cg@exept.de>
parents:
7088
diff
changeset
|
6139 |
'.foorc' asFilename hasSuffix:'foorc' -- false expected here |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6140 |
'.foorc.sav' asFilename hasSuffix:'sav' |
2906 | 6141 |
" |
6142 |
||
6143 |
"Modified: 7.9.1997 / 02:55:25 / cg" |
|
6144 |
! |
|
6145 |
||
10155 | 6146 |
nameWithoutSuffix |
19440 | 6147 |
"return the receiver's name without the suffix. |
10155 | 6148 |
If the name has no suffix, the original name is returned." |
6149 |
||
6150 |
|nm idx idxFromEnd| |
|
6151 |
||
6152 |
nm := self baseName. |
|
15811 | 6153 |
idx := nm lastIndexOf:(self species suffixSeparator). |
10155 | 6154 |
(idx == 0) ifTrue:[^ nameString]. |
6155 |
"/ be careful: if the name consists only of suffix (i.e '.foo'), |
|
6156 |
"/ the suffix is considered empty. |
|
6157 |
(idx == 1) ifTrue:[^ nameString]. |
|
6158 |
||
6159 |
idxFromEnd := nm size - idx. |
|
6160 |
idx := nameString size - idxFromEnd. |
|
6161 |
||
6162 |
^ nameString copyTo:(idx - 1) |
|
6163 |
||
6164 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6165 |
'abc.st' asFilename nameWithoutSuffix |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6166 |
'abc' asFilename nameWithoutSuffix |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6167 |
'/abc' asFilename nameWithoutSuffix |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6168 |
'/abc.d' asFilename nameWithoutSuffix |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6169 |
'./abc' asFilename nameWithoutSuffix |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6170 |
'./abc.d' asFilename nameWithoutSuffix |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6171 |
'./.abc' asFilename nameWithoutSuffix |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6172 |
'a.b.c' asFilename nameWithoutSuffix |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6173 |
'a.b.' asFilename nameWithoutSuffix |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6174 |
'.b.c' asFilename nameWithoutSuffix |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6175 |
'.b.' asFilename nameWithoutSuffix |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6176 |
'.b' asFilename nameWithoutSuffix |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6177 |
'/foo/bar/baz.c' asFilename nameWithoutSuffix |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6178 |
'/foo/bar.x/baz.c' asFilename nameWithoutSuffix |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6179 |
'/foo/bar.x/baz' asFilename nameWithoutSuffix |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6180 |
'/foo/bar/baz/foo.c/bar' asFilename nameWithoutSuffix |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6181 |
'/foo/bar/baz/foo.c/bar.c' asFilename nameWithoutSuffix |
10155 | 6182 |
" |
6183 |
||
6184 |
"Modified: / 07-09-1995 / 11:15:42 / claus" |
|
6185 |
"Created: / 07-11-2006 / 13:55:18 / cg" |
|
6186 |
! |
|
6187 |
||
9453 | 6188 |
prefix |
6189 |
"return my prefix. |
|
6190 |
The suffix is the namepart after the final period character, |
|
6191 |
or the empty string, if the name does not contain a period." |
|
6192 |
||
6193 |
^ self prefixAndSuffix at:1 |
|
6194 |
||
6195 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6196 |
'abc.st' asFilename prefix |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6197 |
'abc' asFilename prefix |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6198 |
'a.b.c' asFilename prefix |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6199 |
'a.b.c' asFilename prefix |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6200 |
'a.' asFilename prefix |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6201 |
'.a' asFilename prefix |
9453 | 6202 |
" |
6203 |
||
6204 |
"Modified: / 07-09-1995 / 11:09:03 / claus" |
|
6205 |
"Created: / 13-07-2006 / 10:27:19 / fm" |
|
6206 |
! |
|
6207 |
||
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
6208 |
prefixAndSuffix |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
6209 |
"return an array consisting of my prefix and suffix. |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
6210 |
The suffix is the namepart after the final period character, |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
6211 |
the prefix everything before, except for the period. |
1517 | 6212 |
The directory name part is stripped off (i.e. the returned prefix |
16578 | 6213 |
will consist of the file's basename only.) |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
6214 |
(on some systems, the suffix-character may be different from a period). |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
6215 |
For example, foo.bar.baz has a prefix of 'foo.bar' and a suffix of '.baz'. |
7115
dea26def3167
prefix/suffix definition changed for files beginning with
Claus Gittinger <cg@exept.de>
parents:
7088
diff
changeset
|
6216 |
An exception to the above: if the name starts with the suffixCharacter, |
dea26def3167
prefix/suffix definition changed for files beginning with
Claus Gittinger <cg@exept.de>
parents:
7088
diff
changeset
|
6217 |
that part is NOT considered a suffix. Thus, '.foorc' has no suffix and a prefix of |
dea26def3167
prefix/suffix definition changed for files beginning with
Claus Gittinger <cg@exept.de>
parents:
7088
diff
changeset
|
6218 |
'.foorc'. |
1517 | 6219 |
See also: #withoutSuffix and #withSuffix |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6220 |
Notice: |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6221 |
there is currently no known system which uses other than |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6222 |
the period character as suffixCharacter." |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
6223 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
6224 |
|nm idx| |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
6225 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
6226 |
nm := self baseName. |
15811 | 6227 |
idx := nm lastIndexOf:(self species suffixSeparator). |
7115
dea26def3167
prefix/suffix definition changed for files beginning with
Claus Gittinger <cg@exept.de>
parents:
7088
diff
changeset
|
6228 |
"/ be careful: if the name consists only of suffix (i.e '.foo'), |
dea26def3167
prefix/suffix definition changed for files beginning with
Claus Gittinger <cg@exept.de>
parents:
7088
diff
changeset
|
6229 |
"/ the suffix is considered empty. |
dea26def3167
prefix/suffix definition changed for files beginning with
Claus Gittinger <cg@exept.de>
parents:
7088
diff
changeset
|
6230 |
((idx == 1) or:[ idx == 0 ]) ifTrue:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6231 |
^ Array with:nm with:'' |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
6232 |
]. |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6233 |
^ Array |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6234 |
with:(nm copyTo:idx-1) |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6235 |
with:(nm copyFrom:idx+1) |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6236 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6237 |
" |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6238 |
'abc.st' asFilename prefixAndSuffix |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6239 |
'abc' asFilename prefixAndSuffix |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6240 |
'a.b.c' asFilename prefixAndSuffix |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6241 |
'/foo/bar.c/baz.c' asFilename prefixAndSuffix |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6242 |
'a.' asFilename prefixAndSuffix |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6243 |
'.a' asFilename prefixAndSuffix |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6244 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6245 |
|parts| |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
6246 |
parts := 'Object.st' asFilename prefixAndSuffix. |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6247 |
((parts at:1) , '.o') asFilename |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
6248 |
" |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
6249 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
6250 |
"Modified: 7.9.1995 / 11:15:42 / claus" |
1517 | 6251 |
"Modified: 3.7.1996 / 10:53:10 / cg" |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
6252 |
! |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
6253 |
|
2906 | 6254 |
suffix |
6255 |
"return my suffix. |
|
6256 |
The suffix is the namepart after the final period character, |
|
6257 |
or the empty string, if the name does not contain a period." |
|
6258 |
||
6259 |
^ self prefixAndSuffix at:2 |
|
6260 |
||
6261 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6262 |
'abc.st' asFilename suffix |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6263 |
'abc' asFilename suffix |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6264 |
'a.b.c' asFilename suffix |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6265 |
'a.b.c' asFilename suffix |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6266 |
'a.' asFilename suffix |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6267 |
'.a' asFilename suffix |
2906 | 6268 |
" |
6269 |
||
6270 |
"Modified: 7.9.1995 / 11:09:03 / claus" |
|
6271 |
! |
|
6272 |
||
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
6273 |
withSuffix:aSuffix |
19440 | 6274 |
"return a new filename for the receiver's name with a different suffix. |
6256 | 6275 |
If the name already has a suffix, the new suffix replaces it; |
1993 | 6276 |
otherwise, the new suffix is simply appended to the name." |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
6277 |
|
7115
dea26def3167
prefix/suffix definition changed for files beginning with
Claus Gittinger <cg@exept.de>
parents:
7088
diff
changeset
|
6278 |
|prefixName| |
dea26def3167
prefix/suffix definition changed for files beginning with
Claus Gittinger <cg@exept.de>
parents:
7088
diff
changeset
|
6279 |
|
10155 | 6280 |
prefixName := self nameWithoutSuffix. |
7115
dea26def3167
prefix/suffix definition changed for files beginning with
Claus Gittinger <cg@exept.de>
parents:
7088
diff
changeset
|
6281 |
aSuffix isEmptyOrNil ifTrue:[ |
19599 | 6282 |
^ self species named:prefixName |
6262 | 6283 |
]. |
6284 |
||
15811 | 6285 |
^ self species named: |
19599 | 6286 |
(prefixName |
6287 |
, self class suffixSeparator asString |
|
6288 |
, aSuffix asString) |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6289 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6290 |
" |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6291 |
'abc.st' asFilename withSuffix:nil |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6292 |
'a.b.c' asFilename withSuffix:nil |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6293 |
'.b.c.' asFilename withSuffix:nil |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6294 |
'.b.c' asFilename withSuffix:nil |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6295 |
'.c.' asFilename withSuffix:nil |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6296 |
'.c' asFilename withSuffix:nil |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6297 |
'c.' asFilename withSuffix:nil |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6298 |
'.' asFilename withSuffix:nil |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6299 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6300 |
'abc.st' asFilename withSuffix:'o' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6301 |
'abc' asFilename withSuffix:'o' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6302 |
'a.b.c' asFilename withSuffix:'o' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6303 |
'a.b.c.' asFilename withSuffix:'o' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6304 |
'.b.c.' asFilename withSuffix:'o' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6305 |
'.c.' asFilename withSuffix:'o' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6306 |
'.c' asFilename withSuffix:'o' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6307 |
'c.' asFilename withSuffix:'o' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6308 |
'.' asFilename withSuffix:'o' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6309 |
'/foo/bar/baz.st' asFilename withSuffix:'c' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6310 |
'/foo/bar/baz.c' asFilename withSuffix:'st' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6311 |
'/foo/bar.c/baz.c' asFilename withSuffix:'st' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6312 |
'/foo/bar.c/baz' asFilename withSuffix:'st' |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
6313 |
" |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
6314 |
|
10155 | 6315 |
"Modified: / 07-09-1995 / 11:15:42 / claus" |
6316 |
"Modified: / 07-11-2006 / 13:58:45 / cg" |
|
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
6317 |
! |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
6318 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
6319 |
withoutSuffix |
19440 | 6320 |
"return a new filename for the receiver's name without the suffix. |
10155 | 6321 |
If the name has no suffix, a filename representing the same file as the receiver is returned." |
6322 |
||
6323 |
|n| |
|
6324 |
||
6325 |
n := self nameWithoutSuffix. |
|
6326 |
n = nameString ifTrue:[^ self]. |
|
15811 | 6327 |
^ self species named:n |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
6328 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
6329 |
" |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6330 |
'abc.st' asFilename withoutSuffix |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6331 |
'abc' asFilename withoutSuffix |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6332 |
'/abc' asFilename withoutSuffix |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6333 |
'/abc.d' asFilename withoutSuffix |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6334 |
'./abc' asFilename withoutSuffix |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6335 |
'./abc.d' asFilename withoutSuffix |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6336 |
'./.abc' asFilename withoutSuffix |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6337 |
'a.b.c' asFilename withoutSuffix |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6338 |
'a.b.' asFilename withoutSuffix |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6339 |
'.b.c' asFilename withoutSuffix |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6340 |
'.b.' asFilename withoutSuffix |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6341 |
'.b' asFilename withoutSuffix |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6342 |
'/foo/bar/baz.c' asFilename withoutSuffix |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6343 |
'/foo/bar.x/baz.c' asFilename withoutSuffix |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6344 |
'/foo/bar.x/baz' asFilename withoutSuffix |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6345 |
'/foo/bar/baz/foo.c/bar' asFilename withoutSuffix |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6346 |
'/foo/bar/baz/foo.c/bar.c' asFilename withoutSuffix |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
6347 |
" |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
6348 |
|
10155 | 6349 |
"Modified: / 07-09-1995 / 11:15:42 / claus" |
6350 |
"Modified: / 07-11-2006 / 13:57:45 / cg" |
|
174 | 6351 |
! ! |
6352 |
||
5597 | 6353 |
!Filename methodsFor:'testing'! |
6354 |
||
6355 |
isFilename |
|
6356 |
"return true, if the receiver is some kind of filename; |
|
6357 |
false is returned here - the method is redefined from Object." |
|
6358 |
||
6359 |
^true |
|
6360 |
||
6361 |
||
6362 |
! ! |
|
6363 |
||
10271 | 6364 |
!Filename methodsFor:'writing-files'! |
6365 |
||
14512 | 6366 |
appendingFileDo:aBlock |
6367 |
"create a append-stream on the receiver file, evaluate aBlock, passing that stream as arg, |
|
19088 | 6368 |
and return the block's value. |
14512 | 6369 |
If the file cannot be opened, an exception is raised. |
6370 |
Ensures that the stream is closed." |
|
6371 |
||
6372 |
|stream result| |
|
6373 |
||
6374 |
stream := self appendStream. |
|
6375 |
[ |
|
19599 | 6376 |
result := aBlock value:stream |
14512 | 6377 |
] ensure:[ |
19599 | 6378 |
stream close |
14512 | 6379 |
]. |
6380 |
^ result |
|
6381 |
||
6382 |
" |
|
14513 | 6383 |
'ttt' asFilename appendingFileDo:[:s | |
19599 | 6384 |
s nextPutLine:'hello'. |
6385 |
s nextPutLine:'world'. |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6386 |
] |
14512 | 6387 |
" |
6388 |
||
6389 |
"Created: / 09-11-2012 / 10:07:41 / sr" |
|
6390 |
! |
|
6391 |
||
10779 | 6392 |
contents:aStringOrCollectionOfLines |
10271 | 6393 |
"create (or overwrite) a file given its contents as a collection of lines. |
6394 |
Raises an error, if the file is unwritable." |
|
6395 |
||
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6396 |
^ self |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6397 |
writingFileDo:[:s | |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6398 |
aStringOrCollectionOfLines isNonByteCollection ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6399 |
"a StringCollection or a collection of lines" |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6400 |
aStringOrCollectionOfLines do:[:each | s nextPutLine:(each ? '')] |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6401 |
] ifFalse:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6402 |
"something string-like" |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6403 |
aStringOrCollectionOfLines isString ifFalse:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6404 |
s binary |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6405 |
]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6406 |
s nextPutAll:aStringOrCollectionOfLines |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6407 |
] |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6408 |
]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6409 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6410 |
" |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6411 |
'foo1' asFilename contents:#('one' 'two' 'three') |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6412 |
'foo2' asFilename contents:'Hello world' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6413 |
'foo3' asFilename contents:#[1 2 3 4 5] |
10271 | 6414 |
" |
6415 |
||
6416 |
"Created: / 11-12-2006 / 14:11:21 / cg" |
|
10779 | 6417 |
"Modified: / 08-11-2007 / 13:28:41 / cg" |
10271 | 6418 |
! |
6419 |
||
6420 |
writingFileDo:aBlock |
|
6421 |
"create a write-stream on the receiver file, evaluate aBlock, passing that stream as arg, |
|
19088 | 6422 |
and return the block's value. |
10271 | 6423 |
If the file cannot be opened, an exception is raised. |
6424 |
Ensures that the stream is closed." |
|
6425 |
||
6426 |
|stream result| |
|
6427 |
||
6428 |
stream := self writeStream. |
|
6429 |
[ |
|
19599 | 6430 |
result := aBlock value:stream |
10271 | 6431 |
] ensure:[ |
19599 | 6432 |
stream close |
10271 | 6433 |
]. |
6434 |
^ result |
|
6435 |
||
6436 |
" |
|
6437 |
'ttt' asFilename writingFileDo:[:s | |
|
19599 | 6438 |
s nextPutLine:'hello'. |
6439 |
s nextPutLine:'world'. |
|
10271 | 6440 |
] |
6441 |
" |
|
6442 |
||
6443 |
"Created: / 11-12-2006 / 14:09:39 / cg" |
|
6444 |
! ! |
|
6445 |
||
1859
7f6040320daf
changes for new return from OS>>infoOf:
Claus Gittinger <cg@exept.de>
parents:
1614
diff
changeset
|
6446 |
!Filename class methodsFor:'documentation'! |
630 | 6447 |
|
6448 |
version |
|
18490 | 6449 |
^ '$Header$' |
12318 | 6450 |
! |
6451 |
||
6452 |
version_CVS |
|
18490 | 6453 |
^ '$Header$' |
630 | 6454 |
! ! |
6771 | 6455 |
|
14628 | 6456 |
|
2906 | 6457 |
Filename initialize! |