author | Merge Script |
Thu, 24 Nov 2016 06:40:21 +0100 | |
branch | jv |
changeset 21027 | ad86468de3a0 |
parent 21025 | 442ca2ef6f76 |
parent 21023 | 22ed5c14aa99 |
child 21088 | 6f4535127ce6 |
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' |
20452 | 20 |
classVariableNames:'ConcreteClass DefaultTempDirectory TempDirectory' |
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 |
||
20293 | 52 |
'/fee/foo/foe' asFilename exists |
53 |
'/not_existing' asFilename isDirectory |
|
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 |
||
20293 | 60 |
'Makefile' asFilename readStream |
61 |
||
62 |
'newFile' asFilename writeStream |
|
63 |
||
64 |
Filename newTemporary writeStream |
|
276 | 65 |
|
1318 | 66 |
Beside lots of protocol to query for a files attributes, the class |
20293 | 67 |
protocol offers methods for filename completion, to construct paths |
1318 | 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:] |
20293 | 81 |
Claus Gittinger |
276 | 82 |
|
1286 | 83 |
[see also:] |
20293 | 84 |
String |
85 |
FileStream DirectoryStream PipeStream Socket |
|
86 |
OperatingSystem |
|
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. |
|
20413 | 384 |
Under windows, that's 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:[ |
|
20413 | 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. |
|
20413 | 404 |
Under windows, that's 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:[ |
|
20413 | 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 |
|
20731
bee58777b1f7
Separate temporary directories for different users
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
20728
diff
changeset
|
830 |
different on other operating systems. Also, the user may want to set the |
bee58777b1f7
Separate temporary directories for different users
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
20728
diff
changeset
|
831 |
TMPDIR environment variable to have her temp files somewhere else." |
3959 | 832 |
|
833 |
|tempDir| |
|
834 |
||
9806 | 835 |
TempDirectory isNil ifTrue:[ |
20731
bee58777b1f7
Separate temporary directories for different users
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
20728
diff
changeset
|
836 |
tempDir := self named:(self defaultTempDirectoryName pathName). |
bee58777b1f7
Separate temporary directories for different users
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
20728
diff
changeset
|
837 |
tempDir exists ifFalse:[ |
bee58777b1f7
Separate temporary directories for different users
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
20728
diff
changeset
|
838 |
tempDir |
bee58777b1f7
Separate temporary directories for different users
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
20728
diff
changeset
|
839 |
makeDirectory; |
bee58777b1f7
Separate temporary directories for different users
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
20728
diff
changeset
|
840 |
addAccessRights:#(readUser readGroup readOthers |
bee58777b1f7
Separate temporary directories for different users
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
20728
diff
changeset
|
841 |
writeUser writeGroup writeOthers |
bee58777b1f7
Separate temporary directories for different users
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
20728
diff
changeset
|
842 |
executeUser executeGroup executeOthers |
bee58777b1f7
Separate temporary directories for different users
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
20728
diff
changeset
|
843 |
removeOnlyByOwner). |
bee58777b1f7
Separate temporary directories for different users
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
20728
diff
changeset
|
844 |
]. |
bee58777b1f7
Separate temporary directories for different users
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
20728
diff
changeset
|
845 |
TempDirectory := DefaultTempDirectory := tempDir construct:('stx_tmp_' , OperatingSystem getLoginName) |
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:[ |
20731
bee58777b1f7
Separate temporary directories for different users
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
20728
diff
changeset
|
853 |
TempDirectory |
bee58777b1f7
Separate temporary directories for different users
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
20728
diff
changeset
|
854 |
makeDirectory; |
bee58777b1f7
Separate temporary directories for different users
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
20728
diff
changeset
|
855 |
addAccessRights:#(readUser readGroup readOthers |
bee58777b1f7
Separate temporary directories for different users
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
20728
diff
changeset
|
856 |
writeUser writeGroup writeOthers |
bee58777b1f7
Separate temporary directories for different users
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
20728
diff
changeset
|
857 |
executeUser executeGroup executeOthers |
bee58777b1f7
Separate temporary directories for different users
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
20728
diff
changeset
|
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" |
20731
bee58777b1f7
Separate temporary directories for different users
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
20728
diff
changeset
|
873 |
"Modified: / 27-10-2016 / 23:06:51 / jv" |
11757
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 |
|
a2ce2d0ab680
new Filename class>>#tempFilename
Stefan Vogel <sv@exept.de>
parents:
11748
diff
changeset
|
876 |
tempDirectory:aFilename |
17048 | 877 |
"set the default temporary directory. |
878 |
This allows overwriting the automatically determined tmpDirectory |
|
879 |
by a knowledgable stand alone startup program. |
|
19114 | 880 |
Do not use elsewhere (and only if absolutely required)" |
11757
a2ce2d0ab680
new Filename class>>#tempFilename
Stefan Vogel <sv@exept.de>
parents:
11748
diff
changeset
|
881 |
|
a2ce2d0ab680
new Filename class>>#tempFilename
Stefan Vogel <sv@exept.de>
parents:
11748
diff
changeset
|
882 |
|temp| |
a2ce2d0ab680
new Filename class>>#tempFilename
Stefan Vogel <sv@exept.de>
parents:
11748
diff
changeset
|
883 |
|
a2ce2d0ab680
new Filename class>>#tempFilename
Stefan Vogel <sv@exept.de>
parents:
11748
diff
changeset
|
884 |
aFilename isNil ifTrue:[ |
19599 | 885 |
TempDirectory := nil. |
886 |
^ self. |
|
11757
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 |
|
a2ce2d0ab680
new Filename class>>#tempFilename
Stefan Vogel <sv@exept.de>
parents:
11748
diff
changeset
|
889 |
temp := aFilename asFilename. |
a2ce2d0ab680
new Filename class>>#tempFilename
Stefan Vogel <sv@exept.de>
parents:
11748
diff
changeset
|
890 |
self assert:temp isDirectory. |
a2ce2d0ab680
new Filename class>>#tempFilename
Stefan Vogel <sv@exept.de>
parents:
11748
diff
changeset
|
891 |
TempDirectory := temp. |
16382 | 892 |
! |
893 |
||
894 |
trashDirectoryOrNil |
|
895 |
"if the underlying OS uses/supports a trash folder, |
|
896 |
return it. Otherwise return nil. |
|
897 |
Asks the OS for the pathname; for example, on OSX, '~/.Trash' is returned." |
|
898 |
||
899 |
|s| |
|
900 |
||
901 |
s := OperatingSystem getTrashDirectory. |
|
902 |
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
|
903 |
^ nil |
16382 | 904 |
]. |
905 |
^ self named:s |
|
906 |
||
907 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
908 |
Filename desktopDirectory |
16382 | 909 |
" |
910 |
||
911 |
"Created: / 16-05-2007 / 13:18:34 / cg" |
|
16648 | 912 |
! |
913 |
||
914 |
usersPrivateSmalltalkDirectory |
|
915 |
^ Filename homeDirectory / '.smalltalk' |
|
916 |
||
917 |
" |
|
918 |
Filename usersPrivateSmalltalkDirectory |
|
919 |
" |
|
3959 | 920 |
! ! |
921 |
||
2168
649e90de1312
added filesMatching: in class protocol;
Claus Gittinger <cg@exept.de>
parents:
2013
diff
changeset
|
922 |
!Filename class methodsFor:'defaults'! |
649e90de1312
added filesMatching: in class protocol;
Claus Gittinger <cg@exept.de>
parents:
2013
diff
changeset
|
923 |
|
649e90de1312
added filesMatching: in class protocol;
Claus Gittinger <cg@exept.de>
parents:
2013
diff
changeset
|
924 |
concreteClass |
6256 | 925 |
"different subclasses of Filename are used for different |
926 |
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
|
927 |
|
2906 | 928 |
^ ConcreteClass ? self |
2168
649e90de1312
added filesMatching: in class protocol;
Claus Gittinger <cg@exept.de>
parents:
2013
diff
changeset
|
929 |
|
649e90de1312
added filesMatching: in class protocol;
Claus Gittinger <cg@exept.de>
parents:
2013
diff
changeset
|
930 |
"Created: 14.2.1997 / 16:36:13 / cg" |
2906 | 931 |
"Modified: 7.9.1997 / 23:29:20 / cg" |
2168
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 |
|
649e90de1312
added filesMatching: in class protocol;
Claus Gittinger <cg@exept.de>
parents:
2013
diff
changeset
|
934 |
defaultClass |
6256 | 935 |
"different subclasses of Filename are used for different |
936 |
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
|
937 |
|
2906 | 938 |
^ ConcreteClass |
939 |
||
940 |
"Modified: 8.9.1997 / 00:36:01 / cg" |
|
7836 | 941 |
! |
942 |
||
943 |
defaultTempDirectoryName |
|
944 |
"return the default temp directory as a filename. |
|
945 |
This is used, if no special preferences were defined in |
|
946 |
any of the TEMP-environment variables (see tempDirectory)." |
|
947 |
||
11781
6488fd6cc498
Make AutoDeletedFilename work like Filename
Stefan Vogel <sv@exept.de>
parents:
11763
diff
changeset
|
948 |
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
|
949 |
^ ConcreteClass defaultTempDirectoryName |
7836 | 950 |
]. |
951 |
||
10994
1a3776d0b845
always return a fileName from defaultTempDirectoryName
fm
parents:
10969
diff
changeset
|
952 |
^ '/tmp' asFilename |
7836 | 953 |
|
954 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
955 |
Filename defaultTempDirectoryName |
7836 | 956 |
" |
957 |
||
958 |
"Modified: 7.9.1995 / 10:48:31 / claus" |
|
959 |
"Created: 7.3.1996 / 14:51:18 / cg" |
|
960 |
"Modified: 8.9.1997 / 00:24:53 / cg" |
|
19599 | 961 |
! |
962 |
||
963 |
defaultVolumeName |
|
964 |
^ '/' |
|
2168
649e90de1312
added filesMatching: in class protocol;
Claus Gittinger <cg@exept.de>
parents:
2013
diff
changeset
|
965 |
! ! |
649e90de1312
added filesMatching: in class protocol;
Claus Gittinger <cg@exept.de>
parents:
2013
diff
changeset
|
966 |
|
2922 | 967 |
!Filename class methodsFor:'misc'! |
968 |
||
3077 | 969 |
filterSeps:aFilenameString |
970 |
"ST80 compatibility: |
|
971 |
filter out (invalid) separators in aFilenameString. |
|
972 |
We recommend using #makeLegalFilename" |
|
973 |
||
16762 | 974 |
^ aFilenameString copyReplaceAll:(Character space) with:$_ ifNone:aFilenameString. |
3077 | 975 |
|
976 |
"Created: / 1.11.1997 / 12:39:50 / cg" |
|
3658 | 977 |
"Modified: / 18.7.1998 / 22:53:24 / cg" |
3077 | 978 |
! |
979 |
||
14220
2a3457b016be
Fix the '~/dir/name' resolution fow windows
Stefan Vogel <sv@exept.de>
parents:
14218
diff
changeset
|
980 |
nameWithSpecialExpansions:aString |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
981 |
"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
|
982 |
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
|
983 |
|
2a3457b016be
Fix the '~/dir/name' resolution fow windows
Stefan Vogel <sv@exept.de>
parents:
14218
diff
changeset
|
984 |
|dir user cutIdx idx userInfo| |
2a3457b016be
Fix the '~/dir/name' resolution fow windows
Stefan Vogel <sv@exept.de>
parents:
14218
diff
changeset
|
985 |
|
19670 | 986 |
(aString startsWith:$~) ifFalse:[ |
987 |
^ aString. |
|
14220
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 |
|
2a3457b016be
Fix the '~/dir/name' resolution fow windows
Stefan Vogel <sv@exept.de>
parents:
14218
diff
changeset
|
990 |
aString size > 1 ifTrue:[ |
19670 | 991 |
idx := aString indexOf:self separator. |
992 |
idx == 0 ifTrue:[ |
|
993 |
"aString is '~user'" |
|
994 |
user := aString copyFrom:2. |
|
995 |
cutIdx := aString size + 1. |
|
996 |
] ifFalse:[ |
|
997 |
"aString is '~user/something'" |
|
998 |
user := aString copyFrom:2 to:(idx - 1). |
|
999 |
cutIdx := idx. |
|
1000 |
]. |
|
1001 |
user notEmpty ifTrue:[ |
|
1002 |
userInfo := OperatingSystem userInfoOf:user. |
|
1003 |
userInfo notNil ifTrue:[ |
|
1004 |
dir := userInfo at:#dir ifAbsent:nil. |
|
1005 |
]. |
|
1006 |
dir isNil ifTrue:[ |
|
14220
2a3457b016be
Fix the '~/dir/name' resolution fow windows
Stefan Vogel <sv@exept.de>
parents:
14218
diff
changeset
|
1007 |
"/ ('Filename [info]: unknown user: ' , user) infoPrintCR. |
19670 | 1008 |
^ aString |
1009 |
]. |
|
1010 |
]. |
|
14220
2a3457b016be
Fix the '~/dir/name' resolution fow windows
Stefan Vogel <sv@exept.de>
parents:
14218
diff
changeset
|
1011 |
]. |
2a3457b016be
Fix the '~/dir/name' resolution fow windows
Stefan Vogel <sv@exept.de>
parents:
14218
diff
changeset
|
1012 |
dir isNil ifTrue:[ |
19670 | 1013 |
"aString is '~' or '~/'" |
1014 |
dir := OperatingSystem getHomeDirectory. |
|
1015 |
cutIdx := 2. |
|
14220
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 |
|
2a3457b016be
Fix the '~/dir/name' resolution fow windows
Stefan Vogel <sv@exept.de>
parents:
14218
diff
changeset
|
1018 |
^ dir , (aString copyFrom:cutIdx) |
2a3457b016be
Fix the '~/dir/name' resolution fow windows
Stefan Vogel <sv@exept.de>
parents:
14218
diff
changeset
|
1019 |
|
2a3457b016be
Fix the '~/dir/name' resolution fow windows
Stefan Vogel <sv@exept.de>
parents:
14218
diff
changeset
|
1020 |
" |
20709 | 1021 |
Filename nameWithSpecialExpansions:'~' |
1022 |
Filename nameWithSpecialExpansions:'~\work' |
|
1023 |
Filename nameWithSpecialExpansions:'~stefan' |
|
1024 |
Filename nameWithSpecialExpansions:'~stefan\work' |
|
1025 |
Filename nameWithSpecialExpansions:'~foo' |
|
1026 |
Filename nameWithSpecialExpansions:'~foo\bar' |
|
1027 |
" |
|
1028 |
||
1029 |
" |
|
1030 |
UnixFilename nameWithSpecialExpansions:'~' |
|
1031 |
UnixFilename nameWithSpecialExpansions:'~/work' |
|
1032 |
UnixFilename nameWithSpecialExpansions:'~stefan' |
|
1033 |
UnixFilename nameWithSpecialExpansions:'~stefan/work' |
|
1034 |
UnixFilename nameWithSpecialExpansions:'~foo' |
|
1035 |
UnixFilename nameWithSpecialExpansions:'~foo/bar' |
|
1036 |
" |
|
1037 |
||
1038 |
" |
|
1039 |
PCFilename nameWithSpecialExpansions:'~' |
|
1040 |
PCFilename nameWithSpecialExpansions:'~\work' |
|
1041 |
PCFilename nameWithSpecialExpansions:'~stefan' |
|
1042 |
PCFilename nameWithSpecialExpansions:'~stefan\work' |
|
1043 |
PCFilename nameWithSpecialExpansions:'~foo' |
|
1044 |
PCFilename nameWithSpecialExpansions:'~foo\bar' |
|
14220
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 |
! |
2a3457b016be
Fix the '~/dir/name' resolution fow windows
Stefan Vogel <sv@exept.de>
parents:
14218
diff
changeset
|
1047 |
|
16999 | 1048 |
possiblyQuotedPathname:aPath |
1049 |
"return a filename path usable as command line argument, |
|
1050 |
by quoting in double quotes if there are any embedded special characters. |
|
1051 |
On Unix systems, special characters might also be prefixed by a backslash character." |
|
1052 |
||
19670 | 1053 |
(aPath startsWith:$") ifFalse:[ |
1054 |
(aPath includes:Character space) ifTrue:[ |
|
1055 |
^ '"',aPath,'"' |
|
1056 |
]. |
|
16999 | 1057 |
]. |
1058 |
^ aPath |
|
1059 |
||
1060 |
||
1061 |
" |
|
18667
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/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' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1064 |
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
|
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 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1068 |
suggest:aFilenameString |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1069 |
"return a fileNamestring based on the argument, |
3077 | 1070 |
which is legal on the current platform." |
1071 |
||
1072 |
^ self canonicalize:aFilenameString |
|
1073 |
||
1074 |
"Created: / 1.11.1997 / 12:42:39 / cg" |
|
2922 | 1075 |
! ! |
1076 |
||
1859
7f6040320daf
changes for new return from OS>>infoOf:
Claus Gittinger <cg@exept.de>
parents:
1614
diff
changeset
|
1077 |
!Filename class methodsFor:'queries'! |
2 | 1078 |
|
10663
b95f903be43e
Make temp dir accessible to all users
Stefan Vogel <sv@exept.de>
parents:
10583
diff
changeset
|
1079 |
currentDirectoryName |
b95f903be43e
Make temp dir accessible to all users
Stefan Vogel <sv@exept.de>
parents:
10583
diff
changeset
|
1080 |
"return a filename for the current directory" |
b95f903be43e
Make temp dir accessible to all users
Stefan Vogel <sv@exept.de>
parents:
10583
diff
changeset
|
1081 |
|
11781
6488fd6cc498
Make AutoDeletedFilename work like Filename
Stefan Vogel <sv@exept.de>
parents:
11763
diff
changeset
|
1082 |
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
|
1083 |
^ ConcreteClass currentDirectoryName |
10663
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 |
|
b95f903be43e
Make temp dir accessible to all users
Stefan Vogel <sv@exept.de>
parents:
10583
diff
changeset
|
1086 |
"/ 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
|
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 |
|
b95f903be43e
Make temp dir accessible to all users
Stefan Vogel <sv@exept.de>
parents:
10583
diff
changeset
|
1090 |
" |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1091 |
Filename currentDirectoryName |
10663
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 |
|
b95f903be43e
Make temp dir accessible to all users
Stefan Vogel <sv@exept.de>
parents:
10583
diff
changeset
|
1094 |
"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
|
1095 |
"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
|
1096 |
! |
b95f903be43e
Make temp dir accessible to all users
Stefan Vogel <sv@exept.de>
parents:
10583
diff
changeset
|
1097 |
|
b95f903be43e
Make temp dir accessible to all users
Stefan Vogel <sv@exept.de>
parents:
10583
diff
changeset
|
1098 |
defaultDirectoryName |
b95f903be43e
Make temp dir accessible to all users
Stefan Vogel <sv@exept.de>
parents:
10583
diff
changeset
|
1099 |
"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
|
1100 |
|
b95f903be43e
Make temp dir accessible to all users
Stefan Vogel <sv@exept.de>
parents:
10583
diff
changeset
|
1101 |
^ self defaultDirectory name |
b95f903be43e
Make temp dir accessible to all users
Stefan Vogel <sv@exept.de>
parents:
10583
diff
changeset
|
1102 |
|
b95f903be43e
Make temp dir accessible to all users
Stefan Vogel <sv@exept.de>
parents:
10583
diff
changeset
|
1103 |
" |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1104 |
Filename defaultDirectoryName |
10663
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 |
! |
b95f903be43e
Make temp dir accessible to all users
Stefan Vogel <sv@exept.de>
parents:
10583
diff
changeset
|
1107 |
|
2963 | 1108 |
directorySuffix |
1109 |
"Return the OS dependent directory suffix string, or nil if there is none. |
|
1110 |
The default is nil here, redefined for VMS" |
|
1111 |
||
11781
6488fd6cc498
Make AutoDeletedFilename work like Filename
Stefan Vogel <sv@exept.de>
parents:
11763
diff
changeset
|
1112 |
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
|
1113 |
^ ConcreteClass directorySuffix |
2963 | 1114 |
]. |
1115 |
||
1116 |
^ nil |
|
1117 |
! |
|
1118 |
||
1523 | 1119 |
errorReporter |
1120 |
"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
|
1121 |
|
1523 | 1122 |
^ FileStream |
1123 |
||
1124 |
"Created: 2.7.1996 / 12:30:25 / stefan" |
|
1125 |
! |
|
1126 |
||
440 | 1127 |
filenameCompletionFor:aString directory:inDirectory directoriesOnly:directoriesOnly filesOnly:filesOnly ifMultiple:aBlock |
1128 |
"perform filename completion on aString in some directory; |
|
1129 |
return the longest matching filename prefix as a string. |
|
1318 | 1130 |
The boolean directoriesOnly and filesOnly control respectively, |
1131 |
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
|
1132 |
If multiple files match, the exception block aBlock is evaluated with a |
1318 | 1133 |
filename representing the directory (where the match was done) as argument. |
440 | 1134 |
(this may be different from the inDirectory argument, if aString is absolute |
1135 |
or starts with ../)" |
|
1136 |
||
11781
6488fd6cc498
Make AutoDeletedFilename work like Filename
Stefan Vogel <sv@exept.de>
parents:
11763
diff
changeset
|
1137 |
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
|
1138 |
^ ConcreteClass |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1139 |
filenameCompletionFor:aString |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1140 |
directory:inDirectory |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1141 |
directoriesOnly:directoriesOnly |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1142 |
filesOnly:filesOnly |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1143 |
ifMultiple:aBlock |
2906 | 1144 |
]. |
6839
d5bc53f68bab
can evaluate block for matchList on filename completition
penk
parents:
6826
diff
changeset
|
1145 |
^ 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
|
1146 |
! |
d5bc53f68bab
can evaluate block for matchList on filename completition
penk
parents:
6826
diff
changeset
|
1147 |
|
d5bc53f68bab
can evaluate block for matchList on filename completition
penk
parents:
6826
diff
changeset
|
1148 |
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
|
1149 |
"perform filename completion on aString in some directory; |
d5bc53f68bab
can evaluate block for matchList on filename completition
penk
parents:
6826
diff
changeset
|
1150 |
return the longest matching filename prefix as a string. |
d5bc53f68bab
can evaluate block for matchList on filename completition
penk
parents:
6826
diff
changeset
|
1151 |
The boolean directoriesOnly and filesOnly control respectively, |
d5bc53f68bab
can evaluate block for matchList on filename completition
penk
parents:
6826
diff
changeset
|
1152 |
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
|
1153 |
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
|
1154 |
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
|
1155 |
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
|
1156 |
(list of matched filenames) as arguments. |
d5bc53f68bab
can evaluate block for matchList on filename completition
penk
parents:
6826
diff
changeset
|
1157 |
(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
|
1158 |
or starts with ../)" |
d5bc53f68bab
can evaluate block for matchList on filename completition
penk
parents:
6826
diff
changeset
|
1159 |
|
d5bc53f68bab
can evaluate block for matchList on filename completition
penk
parents:
6826
diff
changeset
|
1160 |
|s f matchSet nMatch name dir isAbsolute sep| |
2906 | 1161 |
|
5642
87ad71e66acb
fileNameCompletion now does exactly that;
Claus Gittinger <cg@exept.de>
parents:
5602
diff
changeset
|
1162 |
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
|
1163 |
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
|
1164 |
^ '' |
440 | 1165 |
]. |
1166 |
||
5642
87ad71e66acb
fileNameCompletion now does exactly that;
Claus Gittinger <cg@exept.de>
parents:
5602
diff
changeset
|
1167 |
sep := self separator. |
87ad71e66acb
fileNameCompletion now does exactly that;
Claus Gittinger <cg@exept.de>
parents:
5602
diff
changeset
|
1168 |
|
87ad71e66acb
fileNameCompletion now does exactly that;
Claus Gittinger <cg@exept.de>
parents:
5602
diff
changeset
|
1169 |
"/ 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
|
1170 |
|
87ad71e66acb
fileNameCompletion now does exactly that;
Claus Gittinger <cg@exept.de>
parents:
5602
diff
changeset
|
1171 |
f := self named:aString. |
3854
a13d0d489365
care for absolute fileNames in fileNameCompletion.
Claus Gittinger <cg@exept.de>
parents:
3852
diff
changeset
|
1172 |
isAbsolute := f isAbsolute. |
6556
367bc84f51fc
filename completion better if an empty basename is shown
Claus Gittinger <cg@exept.de>
parents:
6529
diff
changeset
|
1173 |
matchSet := f filenameCompletionIn:inDirectory. "/ BAD DESIGN: has side effect on f |
440 | 1174 |
dir := f directory. |
1175 |
||
4131
f370ebc75bf9
fixed filenameCompletion for caseless systems (win32)
Claus Gittinger <cg@exept.de>
parents:
3978
diff
changeset
|
1176 |
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
|
1177 |
|f isDir| |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1178 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1179 |
isAbsolute ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1180 |
f := aFilename asFilename |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1181 |
] ifFalse:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1182 |
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
|
1183 |
]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1184 |
isDir := f isDirectory. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1185 |
directoriesOnly ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1186 |
isDir |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1187 |
] ifFalse:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1188 |
filesOnly ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1189 |
isDir not |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1190 |
] ifFalse:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1191 |
true |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1192 |
] |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1193 |
] |
440 | 1194 |
]. |
1195 |
||
6803 | 1196 |
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
|
1197 |
(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
|
1198 |
" |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1199 |
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
|
1200 |
" |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1201 |
aMultipleBlock notNil ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1202 |
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
|
1203 |
]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1204 |
aBlock value:f |
440 | 1205 |
]. |
4131
f370ebc75bf9
fixed filenameCompletion for caseless systems (win32)
Claus Gittinger <cg@exept.de>
parents:
3978
diff
changeset
|
1206 |
|
440 | 1207 |
" |
1208 |
even with more than one possible completion, |
|
1209 |
f's name is now the common prefix |
|
1210 |
" |
|
1211 |
name := f asString. |
|
4323
8b3752e1b060
add trailing filename separator if match is a directory
Claus Gittinger <cg@exept.de>
parents:
4246
diff
changeset
|
1212 |
|
8b3752e1b060
add trailing filename separator if match is a directory
Claus Gittinger <cg@exept.de>
parents:
4246
diff
changeset
|
1213 |
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
|
1214 |
" |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1215 |
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
|
1216 |
" |
3752 | 1217 |
"/ 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
|
1218 |
false "directoriesOnly" ifFalse:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1219 |
(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
|
1220 |
(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
|
1221 |
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
|
1222 |
]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1223 |
]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1224 |
] |
440 | 1225 |
]. |
1226 |
||
5642
87ad71e66acb
fileNameCompletion now does exactly that;
Claus Gittinger <cg@exept.de>
parents:
5602
diff
changeset
|
1227 |
s := name. |
440 | 1228 |
|
1229 |
"/ special: if there was no change, and the string represented |
|
1230 |
"/ 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
|
1231 |
((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
|
1232 |
(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
|
1233 |
(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
|
1234 |
^ s , sep asString |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1235 |
] |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1236 |
]. |
440 | 1237 |
]. |
1238 |
||
1239 |
^ s |
|
1318 | 1240 |
|
4131
f370ebc75bf9
fixed filenameCompletion for caseless systems (win32)
Claus Gittinger <cg@exept.de>
parents:
3978
diff
changeset
|
1241 |
"Modified: / 30.4.1999 / 09:40:13 / cg" |
615 | 1242 |
! |
1243 |
||
2168
649e90de1312
added filesMatching: in class protocol;
Claus Gittinger <cg@exept.de>
parents:
2013
diff
changeset
|
1244 |
filesMatching:aPattern |
649e90de1312
added filesMatching: in class protocol;
Claus Gittinger <cg@exept.de>
parents:
2013
diff
changeset
|
1245 |
"return a collection of strings, representing the names |
649e90de1312
added filesMatching: in class protocol;
Claus Gittinger <cg@exept.de>
parents:
2013
diff
changeset
|
1246 |
of files matching aPattern. |
2547
4467d25fe057
filesMatching class method returns names as given
Claus Gittinger <cg@exept.de>
parents:
2503
diff
changeset
|
1247 |
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
|
1248 |
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
|
1249 |
The returned strings are the expanded names, in the same form |
2550 | 1250 |
as given in pattern. |
1251 |
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
|
1252 |
|
4467d25fe057
filesMatching class method returns names as given
Claus Gittinger <cg@exept.de>
parents:
2503
diff
changeset
|
1253 |
|basePattern dir d files| |
2168
649e90de1312
added filesMatching: in class protocol;
Claus Gittinger <cg@exept.de>
parents:
2013
diff
changeset
|
1254 |
|
11781
6488fd6cc498
Make AutoDeletedFilename work like Filename
Stefan Vogel <sv@exept.de>
parents:
11763
diff
changeset
|
1255 |
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
|
1256 |
^ ConcreteClass filesMatching:aPattern |
2906 | 1257 |
]. |
1258 |
||
1259 |
"/ the following works on Unix & MSDOS (but not on openVMS) |
|
1260 |
||
2168
649e90de1312
added filesMatching: in class protocol;
Claus Gittinger <cg@exept.de>
parents:
2013
diff
changeset
|
1261 |
dir := aPattern asFilename directoryName. |
2547
4467d25fe057
filesMatching class method returns names as given
Claus Gittinger <cg@exept.de>
parents:
2503
diff
changeset
|
1262 |
basePattern := aPattern asFilename baseName. |
4467d25fe057
filesMatching class method returns names as given
Claus Gittinger <cg@exept.de>
parents:
2503
diff
changeset
|
1263 |
d := dir asFilename. |
2548
b6182b559ea2
made filesMatching ST-80 compatible.
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
1264 |
files := dir asFilename filesMatchingWithoutDotDirs:basePattern. |
2547
4467d25fe057
filesMatching class method returns names as given
Claus Gittinger <cg@exept.de>
parents:
2503
diff
changeset
|
1265 |
dir = '.' ifTrue:[^ files]. |
4467d25fe057
filesMatching class method returns names as given
Claus Gittinger <cg@exept.de>
parents:
2503
diff
changeset
|
1266 |
^ files collect:[:base | d constructString:base]. |
2168
649e90de1312
added filesMatching: in class protocol;
Claus Gittinger <cg@exept.de>
parents:
2013
diff
changeset
|
1267 |
|
649e90de1312
added filesMatching: in class protocol;
Claus Gittinger <cg@exept.de>
parents:
2013
diff
changeset
|
1268 |
" |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1269 |
Filename filesMatching:'*' |
2168
649e90de1312
added filesMatching: in class protocol;
Claus Gittinger <cg@exept.de>
parents:
2013
diff
changeset
|
1270 |
Filename filesMatching:'/*' |
2547
4467d25fe057
filesMatching class method returns names as given
Claus Gittinger <cg@exept.de>
parents:
2503
diff
changeset
|
1271 |
Filename filesMatching:'/usr/local/*' |
2168
649e90de1312
added filesMatching: in class protocol;
Claus Gittinger <cg@exept.de>
parents:
2013
diff
changeset
|
1272 |
" |
649e90de1312
added filesMatching: in class protocol;
Claus Gittinger <cg@exept.de>
parents:
2013
diff
changeset
|
1273 |
|
2906 | 1274 |
"Modified: 8.9.1997 / 00:32:31 / cg" |
615 | 1275 |
! |
1276 |
||
11781
6488fd6cc498
Make AutoDeletedFilename work like Filename
Stefan Vogel <sv@exept.de>
parents:
11763
diff
changeset
|
1277 |
isAbstract |
6488fd6cc498
Make AutoDeletedFilename work like Filename
Stefan Vogel <sv@exept.de>
parents:
11763
diff
changeset
|
1278 |
"return true, if this is not a concrete class" |
6488fd6cc498
Make AutoDeletedFilename work like Filename
Stefan Vogel <sv@exept.de>
parents:
11763
diff
changeset
|
1279 |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1280 |
^ self == Filename |
11781
6488fd6cc498
Make AutoDeletedFilename work like Filename
Stefan Vogel <sv@exept.de>
parents:
11763
diff
changeset
|
1281 |
! |
6488fd6cc498
Make AutoDeletedFilename work like Filename
Stefan Vogel <sv@exept.de>
parents:
11763
diff
changeset
|
1282 |
|
2903 | 1283 |
isBadCharacter:aCharacter |
1284 |
"return true, if aCharacter is unallowed in a filename." |
|
1285 |
||
11781
6488fd6cc498
Make AutoDeletedFilename work like Filename
Stefan Vogel <sv@exept.de>
parents:
11763
diff
changeset
|
1286 |
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
|
1287 |
^ ConcreteClass isBadCharacter:aCharacter |
2906 | 1288 |
]. |
1289 |
||
8095
bfbd1309a4a6
Use #codePoint instead of deprecated #asciiValue
Stefan Vogel <sv@exept.de>
parents:
8036
diff
changeset
|
1290 |
^ aCharacter isControlCharacter |
2903 | 1291 |
! |
1292 |
||
1293 |
isCaseSensitive |
|
1294 |
"return true, if filenames are case sensitive. |
|
19821 | 1295 |
We ask the OS about this, to be independent here. |
1296 |
This is not really correct, as the sensitivity may depend on |
|
1297 |
the paricular mounted file system (NFS, for example). |
|
1298 |
So we need a query on the instance side" |
|
2903 | 1299 |
|
11781
6488fd6cc498
Make AutoDeletedFilename work like Filename
Stefan Vogel <sv@exept.de>
parents:
11763
diff
changeset
|
1300 |
self isAbstract ifTrue:[ |
19821 | 1301 |
^ ConcreteClass isCaseSensitive |
2906 | 1302 |
]. |
1303 |
||
2903 | 1304 |
^ OperatingSystem caseSensitiveFilenames |
2906 | 1305 |
|
1306 |
"Modified: 8.9.1997 / 00:33:32 / cg" |
|
2903 | 1307 |
! |
1308 |
||
615 | 1309 |
localNameStringFrom:aString |
1310 |
"ST-80 compatibility. |
|
1311 |
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
|
1312 |
GUESS: |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1313 |
does it strip off any volume characters and make a path relative ?" |
2922 | 1314 |
|
11781
6488fd6cc498
Make AutoDeletedFilename work like Filename
Stefan Vogel <sv@exept.de>
parents:
11763
diff
changeset
|
1315 |
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
|
1316 |
^ ConcreteClass localNameStringFrom:aString |
2906 | 1317 |
]. |
1318 |
||
15227 | 1319 |
^ aString withoutPrefix:self separatorString |
615 | 1320 |
|
1321 |
"Modified: 7.9.1995 / 10:44:56 / claus" |
|
2906 | 1322 |
"Modified: 8.9.1997 / 00:33:51 / cg" |
615 | 1323 |
! |
1324 |
||
2908 | 1325 |
maxComponentLength |
1326 |
"return the maximum number of characters a filename component may |
|
1327 |
be in size. This depends on the OperatingSystem." |
|
1328 |
||
11781
6488fd6cc498
Make AutoDeletedFilename work like Filename
Stefan Vogel <sv@exept.de>
parents:
11763
diff
changeset
|
1329 |
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
|
1330 |
^ ConcreteClass maxComponentLength |
2908 | 1331 |
]. |
1332 |
^ OperatingSystem maxFileNameLength |
|
1333 |
! |
|
1334 |
||
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1335 |
maxLength |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1336 |
"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
|
1337 |
This depends on the OperatingSystem." |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1338 |
|
11781
6488fd6cc498
Make AutoDeletedFilename work like Filename
Stefan Vogel <sv@exept.de>
parents:
11763
diff
changeset
|
1339 |
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
|
1340 |
^ ConcreteClass maxLength |
2908 | 1341 |
]. |
1342 |
^ OperatingSystem maxPathLength |
|
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1343 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1344 |
"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
|
1345 |
"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
|
1346 |
! |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1347 |
|
3171 | 1348 |
nullFilename |
1349 |
"Return the OS dependent filename for /dev/null, or nil if there is none. |
|
1350 |
The default is nil here" |
|
1351 |
||
11781
6488fd6cc498
Make AutoDeletedFilename work like Filename
Stefan Vogel <sv@exept.de>
parents:
11763
diff
changeset
|
1352 |
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
|
1353 |
^ ConcreteClass nullFilename |
3171 | 1354 |
]. |
1355 |
||
8754 | 1356 |
^ OperatingSystem getNullDevice |
3171 | 1357 |
|
1358 |
"Created: / 12.1.1998 / 12:15:30 / stefan" |
|
1359 |
! |
|
1360 |
||
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1361 |
parentDirectoryName |
615 | 1362 |
"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
|
1363 |
This is '..' for unix and dos-like systems. |
615 | 1364 |
(there may be more in the future." |
1365 |
||
11781
6488fd6cc498
Make AutoDeletedFilename work like Filename
Stefan Vogel <sv@exept.de>
parents:
11763
diff
changeset
|
1366 |
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
|
1367 |
^ ConcreteClass parentDirectoryName |
2906 | 1368 |
]. |
1369 |
||
1370 |
^ OperatingSystem parentDirectoryName |
|
1371 |
||
1372 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1373 |
Filename parentDirectoryName |
2906 | 1374 |
" |
1375 |
||
1376 |
"Modified: 8.9.1997 / 00:34:39 / cg" |
|
615 | 1377 |
! |
1378 |
||
1379 |
separator |
|
1380 |
"return the file/directory separator. |
|
15246 | 1381 |
This is to be redefined in concrete classes." |
1382 |
||
1383 |
^ ConcreteClass separator |
|
8243 | 1384 |
|
1385 |
" |
|
8754 | 1386 |
Filename separator |
1387 |
PCFilename separator |
|
8243 | 1388 |
" |
2906 | 1389 |
|
1390 |
"Modified: 8.9.1997 / 00:20:28 / cg" |
|
615 | 1391 |
! |
1392 |
||
8243 | 1393 |
separatorString |
1394 |
"return the file/directory separator as a string." |
|
1395 |
||
1396 |
^ self separator asString |
|
1397 |
||
1398 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1399 |
Filename separatorString |
8243 | 1400 |
" |
1401 |
! |
|
1402 |
||
615 | 1403 |
suffixSeparator |
1404 |
"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
|
1405 |
Usually, this is $. for unix-like and msdos systems |
1318 | 1406 |
(there is currently no known system, where this differs)" |
615 | 1407 |
|
1408 |
^ $. |
|
1409 |
||
1410 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1411 |
Filename suffixSeparator |
615 | 1412 |
" |
1413 |
||
1414 |
"Modified: 7.9.1995 / 11:10:43 / claus" |
|
1318 | 1415 |
"Modified: 30.4.1996 / 12:14:25 / cg" |
615 | 1416 |
! |
1417 |
||
2906 | 1418 |
tempFileNameTemplate |
1419 |
"return a template for temporary files. |
|
1420 |
This is expanded with the current processID and a sequenceNumber |
|
1421 |
to generate a unique filename." |
|
1422 |
||
11781
6488fd6cc498
Make AutoDeletedFilename work like Filename
Stefan Vogel <sv@exept.de>
parents:
11763
diff
changeset
|
1423 |
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
|
1424 |
^ ConcreteClass tempFileNameTemplate |
2906 | 1425 |
]. |
1426 |
||
1427 |
^ 'stxtmp_%1_%2' |
|
1428 |
||
1429 |
"Created: 8.9.1997 / 00:01:46 / cg" |
|
1430 |
"Modified: 8.9.1997 / 00:35:02 / cg" |
|
1431 |
! |
|
1432 |
||
615 | 1433 |
volumes |
1434 |
"ST-80 compatibility. |
|
2896 | 1435 |
GUESS: does it return the available drives on MSDOS systems ? |
1436 |
Q: what does this do on Unix systems ? (used in FileNavigator-goody)." |
|
1437 |
||
11781
6488fd6cc498
Make AutoDeletedFilename work like Filename
Stefan Vogel <sv@exept.de>
parents:
11763
diff
changeset
|
1438 |
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
|
1439 |
^ ConcreteClass volumes |
2906 | 1440 |
]. |
1441 |
||
2896 | 1442 |
^ OperatingSystem getDriveList |
615 | 1443 |
|
8679 | 1444 |
" |
1445 |
Filename volumes |
|
1446 |
" |
|
615 | 1447 |
! ! |
1448 |
||
6383 | 1449 |
!Filename class methodsFor:'utilities'! |
1450 |
||
16389 | 1451 |
canonicalize:aPathString |
1452 |
"convert the argument, aPathString to a good format. |
|
1453 |
This should eliminate useless directory components (i.e. '././') |
|
1454 |
and useless tree walks (i.e. '../foo/..')." |
|
1455 |
||
1456 |
^ self nameFromComponents:(self canonicalizedNameComponents:aPathString) |
|
1457 |
||
1458 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1459 |
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
|
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:'/home/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:'cg/../../..' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1467 |
Filename canonicalize:'./' |
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:'/home/../..' |
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' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1472 |
Filename canonicalize:'//foo//bar' |
16389 | 1473 |
" |
1474 |
! |
|
1475 |
||
1476 |
canonicalizedNameComponents:aPathString |
|
1477 |
"convert the argument, aPathString to a good format. |
|
1478 |
This should eliminate useless directory components (i.e. '././') |
|
1479 |
and useless tree walks (i.e. '../foo/..'). |
|
1480 |
||
1481 |
Answer a sequenceable collection of name components." |
|
1482 |
||
1483 |
|comps newComps rootName dotDot dot| |
|
1484 |
||
1485 |
dotDot := self parentDirectoryName. |
|
1486 |
dot := self currentDirectoryName. |
|
1487 |
rootName := self separatorString. |
|
1488 |
||
1489 |
comps := self components:aPathString. |
|
1490 |
newComps := OrderedCollection new:comps size. |
|
1491 |
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
|
1492 |
eachComponent ~= dot ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1493 |
eachComponent = dotDot ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1494 |
(newComps isEmpty |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1495 |
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
|
1496 |
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
|
1497 |
newComps add:eachComponent |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1498 |
] ifFalse:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1499 |
newComps removeLast |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1500 |
]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1501 |
] ifFalse:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1502 |
newComps add:eachComponent |
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 |
] |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1505 |
]. |
16389 | 1506 |
"/ add current Directory if empty |
1507 |
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
|
1508 |
newComps add:dot. |
16389 | 1509 |
]. |
1510 |
^ newComps |
|
1511 |
||
1512 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1513 |
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
|
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:'/home/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:'cg/../../..' |
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:'/.' |
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:'/home/../..' |
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' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1529 |
Filename canonicalizedNameComponents:'//foo//bar' |
16389 | 1530 |
" |
1531 |
! |
|
1532 |
||
1533 |
components:aString |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1534 |
"separate the pathName given by aString into |
16578 | 1535 |
a collection containing the directory components and the file's name as |
16389 | 1536 |
the final component. |
1537 |
If the argument names an absolute path, the first component will be the |
|
1538 |
name of the root directory (i.e. '/')." |
|
1539 |
||
1540 |
|sep f vol rest components| |
|
1541 |
||
1542 |
self isAbstract ifTrue:[ |
|
19821 | 1543 |
^ ConcreteClass components:aString |
16389 | 1544 |
]. |
1545 |
||
1546 |
"/ the following works on Unix & MSDOS (but not on openVMS) |
|
1547 |
"/ However, MSDOS drive-letters and network drives are |
|
1548 |
"/ not correctly handled here. |
|
1549 |
||
1550 |
sep := self separator. |
|
1551 |
f := aString asFilename. |
|
1552 |
vol := f volume. |
|
1553 |
vol size ~~ 0 ifTrue:[ |
|
19821 | 1554 |
rest := f localPathName. |
16389 | 1555 |
] ifFalse:[ |
19821 | 1556 |
rest := aString |
16389 | 1557 |
]. |
1558 |
||
1559 |
components := rest asCollectionOfSubstringsSeparatedBy:sep. |
|
1560 |
(rest startsWith:sep) ifTrue:[ |
|
19821 | 1561 |
"first was a separator - root directory - restore" |
1562 |
(rest size > 1 and:[rest second = sep and:[vol isEmptyOrNil]]) ifTrue:[ |
|
1563 |
"keep \\ for windows network paths" |
|
1564 |
components at:1 put:(String with:sep with:sep). |
|
1565 |
] ifFalse:[ |
|
1566 |
components at:1 put:sep asString. |
|
1567 |
]. |
|
16389 | 1568 |
]. |
1569 |
||
1570 |
"/ prepend volume to first component (the root directory) |
|
1571 |
vol size ~~ 0 ifTrue:[ |
|
20694 | 1572 |
vol last = $: ifTrue:[ |
1573 |
vol := vol, (components at:1). |
|
1574 |
]. |
|
1575 |
components at:1 put:vol. |
|
1576 |
]. |
|
1577 |
components := components select:[:each| each notEmpty]. |
|
1578 |
||
16389 | 1579 |
^ components |
1580 |
||
1581 |
" |
|
19821 | 1582 |
Unix: |
1583 |
UnixFilename components:'/foo/bar/baz' |
|
1584 |
UnixFilename components:'/' |
|
1585 |
UnixFilename components:'//' |
|
1586 |
UnixFilename components:'foo/bar/baz' |
|
1587 |
UnixFilename components:'foo/bar' |
|
1588 |
UnixFilename components:'foo' |
|
1589 |
UnixFilename components:'/foo' |
|
1590 |
UnixFilename components:'//foo' |
|
1591 |
UnixFilename components:'' |
|
1592 |
||
1593 |
Windows: |
|
1594 |
PCFilename components:'\' |
|
1595 |
PCFilename components:'\foo' |
|
1596 |
PCFilename components:'\foo\' |
|
1597 |
PCFilename components:'\foo\bar' |
|
1598 |
PCFilename components:'\foo\bar\' |
|
1599 |
PCFilename components:'c:' |
|
1600 |
PCFilename components:'c:\' |
|
1601 |
PCFilename components:'c:\foo' |
|
1602 |
PCFilename components:'c:\foo\' |
|
1603 |
PCFilename components:'c:\foo\bar' |
|
1604 |
PCFilename components:'c:\foo\bar\' |
|
1605 |
PCFilename components:'\\idefix' |
|
1606 |
PCFilename components:'\\idefix\home' |
|
1607 |
PCFilename components:'\\idefix\home\bar' |
|
16389 | 1608 |
" |
1609 |
||
1610 |
"Modified: / 24.9.1998 / 19:10:52 / cg" |
|
1611 |
! |
|
1612 |
||
19821 | 1613 |
filesMatchingGLOB:pattern |
1614 |
"does a GLOB filename expansion. |
|
1615 |
Generates and returns a possibly empty list of files which match |
|
1616 |
the given glob pattern" |
|
1617 |
||
1618 |
^ OrderedCollection withCollectedContents:[:coll | |
|
1619 |
pattern asFilename filesMatchingGLOBDo:[:each | coll add:each] |
|
1620 |
] |
|
1621 |
||
1622 |
" |
|
1623 |
Filename filesMatchingGLOB:'./A*' |
|
1624 |
Filename filesMatchingGLOB:'/etc/A*' |
|
1625 |
Filename filesMatchingGLOB:'/*/A*' |
|
1626 |
'.' asFilename filesMatchingGLOB:'A*' |
|
1627 |
" |
|
1628 |
! |
|
1629 |
||
6802 | 1630 |
nameFromComponents:aCollectionOfDirectoryNames |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1631 |
"return a filenameString from components given in aCollectionOfDirectoryNames. |
6802 | 1632 |
If the first component is the name of the root directory (i.e. '/'), |
1633 |
an absolute path-string is returned." |
|
1634 |
||
1635 |
|sep s| |
|
1636 |
||
11781
6488fd6cc498
Make AutoDeletedFilename work like Filename
Stefan Vogel <sv@exept.de>
parents:
11763
diff
changeset
|
1637 |
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
|
1638 |
^ ConcreteClass nameFromComponents:aCollectionOfDirectoryNames |
6802 | 1639 |
]. |
1640 |
||
1641 |
"/ fallBack - works on Unix & MSDOS |
|
1642 |
||
8243 | 1643 |
sep := self separatorString. |
6802 | 1644 |
s := ''. |
1645 |
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
|
1646 |
index == 1 ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1647 |
s := component. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1648 |
] ifFalse:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1649 |
(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
|
1650 |
s := s , component |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1651 |
] ifFalse:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1652 |
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
|
1653 |
] |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1654 |
]. |
6802 | 1655 |
]. |
1656 |
^ s |
|
1657 |
||
1658 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1659 |
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
|
1660 |
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
|
1661 |
Filename nameFromComponents:#('/') |
7074 | 1662 |
|
1663 |
|comps| |
|
1664 |
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
|
1665 |
Filename nameFromComponents:comps |
7074 | 1666 |
|
1667 |
|comps| |
|
1668 |
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
|
1669 |
Filename nameFromComponents:comps |
7074 | 1670 |
|
1671 |
|comps| |
|
1672 |
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
|
1673 |
Filename nameFromComponents:comps |
7074 | 1674 |
|
1675 |
|comps| |
|
1676 |
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
|
1677 |
Filename nameFromComponents:comps |
7074 | 1678 |
|
1679 |
|comps| |
|
1680 |
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
|
1681 |
Filename nameFromComponents:comps |
7074 | 1682 |
|
1683 |
|comps| |
|
1684 |
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
|
1685 |
Filename nameFromComponents:comps |
7074 | 1686 |
|
1687 |
|comps| |
|
1688 |
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
|
1689 |
Filename nameFromComponents:comps |
6802 | 1690 |
" |
1691 |
||
1692 |
"Modified: 8.9.1997 / 00:23:16 / cg" |
|
1693 |
! |
|
1694 |
||
6383 | 1695 |
readingFile:aPathName do:aBlock |
20158 | 1696 |
"Create a read stream on a file, evaluate aBlock, passing that stream, |
1697 |
and return the block's value. |
|
6383 | 1698 |
Ensures that the stream is closed." |
1699 |
||
6529 | 1700 |
^ aPathName asFilename readingFileDo:aBlock. |
1701 |
||
1702 |
" |
|
1703 |
read the first line from some file: |
|
1704 |
||
1705 |
|rslt| |
|
1706 |
||
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1707 |
rslt := |
20158 | 1708 |
Filename |
1709 |
readingFile:'/etc/passwd' |
|
1710 |
do:[:s | |
|
1711 |
s nextLine |
|
1712 |
]. |
|
6529 | 1713 |
Transcript showCR:rslt. |
1714 |
" |
|
1715 |
||
1716 |
" |
|
1717 |
find all used shells in /etc/passwd and count their usage: |
|
1718 |
||
6383 | 1719 |
|rslt| |
1720 |
||
6529 | 1721 |
rslt := |
20158 | 1722 |
Filename |
1723 |
readingFile:'/etc/passwd' |
|
1724 |
do: |
|
1725 |
[:s | |
|
1726 |
|shells| |
|
1727 |
||
1728 |
shells := Bag new. |
|
1729 |
s linesDo: |
|
1730 |
[:line | |
|
1731 |
|parts| |
|
1732 |
||
1733 |
parts := line asCollectionOfSubstringsSeparatedBy:$:. |
|
1734 |
shells add:(parts seventh). |
|
1735 |
]. |
|
1736 |
shells contents |
|
1737 |
]. |
|
6529 | 1738 |
Transcript showCR:rslt. |
1739 |
" |
|
6383 | 1740 |
! ! |
1741 |
||
7261 | 1742 |
!Filename methodsFor:'Compatibility-VW5.4'! |
6139 | 1743 |
|
1744 |
asLogicalFileSpecification |
|
1745 |
^ self |
|
1746 |
||
1747 |
"Created: / 30.10.2001 / 17:31:10 / cg" |
|
6447 | 1748 |
! |
1749 |
||
10583 | 1750 |
canBeWritten |
1751 |
"same as isWritable - for ST-80 compatibility" |
|
1752 |
||
1753 |
^ self isWritable |
|
1754 |
||
1755 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1756 |
'/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
|
1757 |
'/tmp' asFilename canBeWritten |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1758 |
'Makefile' asFilename canBeWritten |
10583 | 1759 |
" |
1760 |
! |
|
1761 |
||
7596 | 1762 |
definitelyExists |
1763 |
"for now - a kludge" |
|
1764 |
||
1765 |
^ self exists |
|
1766 |
! |
|
1767 |
||
6447 | 1768 |
extension |
6454 | 1769 |
"return the receiver's extension; |
1770 |
that is the characters from and including |
|
1771 |
the last period or nil, if there is none." |
|
1772 |
||
1773 |
|string idx| |
|
1774 |
||
1775 |
string := self asString. |
|
1776 |
idx := string lastIndexOf:$.. |
|
1777 |
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
|
1778 |
^ string copyFrom:idx |
6454 | 1779 |
]. |
1780 |
^ nil |
|
1781 |
||
1782 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1783 |
'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
|
1784 |
'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
|
1785 |
'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
|
1786 |
'foo.' asFilename extension |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1787 |
'foo' asFilename extension |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1788 |
'.login' asFilename extension |
6454 | 1789 |
" |
6139 | 1790 |
! ! |
1791 |
||
615 | 1792 |
!Filename methodsFor:'comparing'! |
1793 |
||
16255 | 1794 |
< aFilename |
1795 |
"compare file names - used for sorting" |
|
1796 |
||
1797 |
^ self asString < aFilename asString |
|
1798 |
! |
|
1799 |
||
615 | 1800 |
= aFilename |
1801 |
"return true, if the argument represents the same filename" |
|
1802 |
||
1803 |
|str| |
|
1804 |
||
1805 |
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
|
1806 |
str := aFilename asString. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1807 |
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
|
1808 |
^ nameString = str |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1809 |
]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1810 |
^ nameString sameAs:str |
615 | 1811 |
]. |
1812 |
^ false |
|
1813 |
! |
|
1814 |
||
5877 | 1815 |
contentsIsPrefixOf:aFilename |
5876
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1816 |
"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
|
1817 |
is the same as or a prefix of the contents of the file represented by the argument, aFilename. |
16578 | 1818 |
This compares the files' actual contents; not the filenames." |
3868 | 1819 |
|
8771 | 1820 |
|f2 s1 s2 bufferSize buffer1 buffer2 n| |
1821 |
||
1822 |
bufferSize := 8192 * 4. |
|
4979 | 1823 |
|
1824 |
f2 := aFilename asFilename. |
|
5876
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1825 |
self fileSize > f2 fileSize ifTrue:[^ false]. |
3868 | 1826 |
|
7088
cc3233554827
Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents:
7075
diff
changeset
|
1827 |
[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1828 |
s1 := self readStream. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1829 |
s2 := f2 readStream. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1830 |
s1 binary. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1831 |
s2 binary. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1832 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1833 |
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
|
1834 |
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
|
1835 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1836 |
[s1 atEnd] whileFalse:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1837 |
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
|
1838 |
n == 0 ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1839 |
"/ receiver shorter. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1840 |
^ true |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1841 |
]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1842 |
(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
|
1843 |
"/ aFilename shorter |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1844 |
^ false |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1845 |
]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1846 |
buffer1 ~= buffer2 ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1847 |
^ false |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1848 |
] |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1849 |
]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1850 |
"/ receiver shorter or same size. |
7088
cc3233554827
Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents:
7075
diff
changeset
|
1851 |
] ensure:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1852 |
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
|
1853 |
s2 notNil ifTrue:[s2 close]. |
3868 | 1854 |
]. |
5876
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1855 |
^ true |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1856 |
|
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1857 |
" |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1858 |
|s| |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1859 |
|
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1860 |
s := 'testFile1' asFilename writeStream. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1861 |
s nextPutAll:'11111'. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1862 |
s nextPutAll:'22222'. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1863 |
s nextPutAll:'33333'. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1864 |
s close. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1865 |
|
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1866 |
s := 'testFile2' asFilename writeStream. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1867 |
s nextPutAll:'11111'. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1868 |
s nextPutAll:'22222'. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1869 |
s nextPutAll:'33333'. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1870 |
s close. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1871 |
|
5877 | 1872 |
('testFile1' asFilename contentsIsPrefixOf:'testFile2' ) ifFalse:[self halt]. |
5876
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1873 |
|
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1874 |
s := 'testFile2' asFilename writeStream. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1875 |
s nextPutAll:'11111'. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1876 |
s nextPutAll:'22222'. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1877 |
s nextPutAll:'33333'. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1878 |
s nextPutAll:'44444'. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1879 |
s close. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1880 |
|
5877 | 1881 |
('testFile1' asFilename contentsIsPrefixOf:'testFile2' ) ifFalse:[self halt]. |
5876
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1882 |
|
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1883 |
s := 'testFile2' asFilename writeStream. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1884 |
s nextPutAll:'11111'. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1885 |
s nextPutAll:'22222'. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1886 |
s close. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1887 |
|
5877 | 1888 |
('testFile1' asFilename contentsIsPrefixOf:'testFile2' ) ifTrue:[self halt]. |
5876
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1889 |
|
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1890 |
s := 'testFile2' asFilename writeStream. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1891 |
s nextPutAll:'11111'. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1892 |
s nextPutAll:'22222'. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1893 |
s nextPutAll:'33334'. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1894 |
s close. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1895 |
|
5877 | 1896 |
('testFile1' asFilename contentsIsPrefixOf:'testFile2' ) ifTrue:[self halt]. |
1897 |
||
1898 |
" |
|
1899 |
! |
|
1900 |
||
1901 |
contentsStartsWithContentsOf:aFilename |
|
1902 |
"return true if the contents of the file represented by aFilename |
|
1903 |
is the same as or a prefix of the contents of the file represented by the receiver. |
|
16578 | 1904 |
This compares the files' actual contents; not the filenames." |
5877 | 1905 |
|
1906 |
^ aFilename asFilename contentsIsPrefixOf:self |
|
1907 |
||
1908 |
" |
|
1909 |
|s| |
|
1910 |
||
1911 |
s := 'testFile1' asFilename writeStream. |
|
1912 |
s nextPutAll:'11111'. |
|
1913 |
s nextPutAll:'22222'. |
|
1914 |
s nextPutAll:'33333'. |
|
1915 |
s close. |
|
1916 |
||
1917 |
s := 'testFile2' asFilename writeStream. |
|
1918 |
s nextPutAll:'11111'. |
|
1919 |
s nextPutAll:'22222'. |
|
1920 |
s nextPutAll:'33333'. |
|
1921 |
s close. |
|
1922 |
||
1923 |
('testFile2' asFilename contentsStartsWithContentsOf:'testFile1' ) ifFalse:[self halt]. |
|
1924 |
||
1925 |
s := 'testFile2' asFilename writeStream. |
|
1926 |
s nextPutAll:'11111'. |
|
1927 |
s nextPutAll:'22222'. |
|
1928 |
s nextPutAll:'33333'. |
|
1929 |
s nextPutAll:'44444'. |
|
1930 |
s close. |
|
1931 |
||
1932 |
('testFile2' asFilename contentsStartsWithContentsOf:'testFile1' ) ifFalse:[self halt]. |
|
1933 |
||
1934 |
s := 'testFile2' asFilename writeStream. |
|
1935 |
s nextPutAll:'11111'. |
|
1936 |
s nextPutAll:'22222'. |
|
1937 |
s close. |
|
1938 |
||
1939 |
('testFile2' asFilename contentsStartsWithContentsOf:'testFile1' ) ifTrue:[self halt]. |
|
1940 |
||
1941 |
s := 'testFile2' asFilename writeStream. |
|
1942 |
s nextPutAll:'11111'. |
|
1943 |
s nextPutAll:'22222'. |
|
1944 |
s nextPutAll:'33334'. |
|
1945 |
s close. |
|
1946 |
||
1947 |
('testFile2' asFilename contentsStartsWithContentsOf:'testFile1' ) ifTrue:[self halt]. |
|
5876
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1948 |
|
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1949 |
" |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1950 |
! |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1951 |
|
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1952 |
hash |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1953 |
"return an integer useful as a hash-key" |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1954 |
|
15811 | 1955 |
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
|
1956 |
"/ 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
|
1957 |
"/ 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
|
1958 |
"/ 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
|
1959 |
^ nameString asUppercase hash |
11424
c169cc34afe9
fixed hash for case-insensitive files
Claus Gittinger <cg@exept.de>
parents:
11406
diff
changeset
|
1960 |
]. |
5876
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1961 |
^ nameString hash |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1962 |
! |
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 |
sameContentsAs:aFilename |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1965 |
"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
|
1966 |
same contents as the file represented by the argument, aFilename. |
16578 | 1967 |
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
|
1968 |
|
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1969 |
|f2| |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1970 |
|
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1971 |
f2 := aFilename asFilename. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1972 |
f2 fileSize = self fileSize ifFalse:[^ false]. |
5877 | 1973 |
^ self contentsIsPrefixOf:f2. |
3868 | 1974 |
|
1975 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1976 |
'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
|
1977 |
'Make.proto' asFilename sameContentsAs:'Make.proto' |
3868 | 1978 |
" |
5876
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1979 |
|
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1980 |
" |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1981 |
|s| |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1982 |
|
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1983 |
s := 'testFile1' asFilename writeStream. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1984 |
s nextPutAll:'11111'. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1985 |
s nextPutAll:'22222'. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1986 |
s nextPutAll:'33333'. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1987 |
s close. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1988 |
|
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1989 |
s := 'testFile2' asFilename writeStream. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1990 |
s nextPutAll:'11111'. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1991 |
s nextPutAll:'22222'. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1992 |
s nextPutAll:'33333'. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1993 |
s close. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1994 |
|
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1995 |
('testFile1' asFilename sameContentsAs:'testFile2' ) ifFalse:[self halt]. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1996 |
|
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1997 |
s := 'testFile2' asFilename writeStream. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1998 |
s nextPutAll:'11111'. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1999 |
s nextPutAll:'22222'. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
2000 |
s nextPutAll:'33333'. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
2001 |
s nextPutAll:'44444'. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
2002 |
s close. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
2003 |
|
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
2004 |
('testFile1' asFilename sameContentsAs:'testFile2' ) ifTrue:[self halt]. |
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 |
s := 'testFile2' asFilename writeStream. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
2007 |
s nextPutAll:'11111'. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
2008 |
s nextPutAll:'22222'. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
2009 |
s close. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
2010 |
|
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
2011 |
('testFile1' asFilename sameContentsAs:'testFile2' ) ifTrue:[self halt]. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
2012 |
|
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
2013 |
s := 'testFile2' asFilename writeStream. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
2014 |
s nextPutAll:'11111'. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
2015 |
s nextPutAll:'22222'. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
2016 |
s nextPutAll:'33334'. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
2017 |
s close. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
2018 |
|
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
2019 |
('testFile1' asFilename sameContentsAs:'testFile2' ) ifTrue:[self halt]. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
2020 |
|
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
2021 |
" |
615 | 2022 |
! ! |
2023 |
||
2024 |
!Filename methodsFor:'converting'! |
|
2025 |
||
2026 |
asAbsoluteFilename |
|
2027 |
"return the receiver converted to a filename with |
|
2028 |
an absolute pathname." |
|
2029 |
||
15811 | 2030 |
^ self species named:self pathName |
7332 | 2031 |
|
2032 |
" |
|
2033 |
'.' asFilename |
|
2034 |
'.' asFilename asAbsoluteFilename |
|
9173 | 2035 |
'c:' asFilename asAbsoluteFilename |
7332 | 2036 |
" |
615 | 2037 |
! |
2038 |
||
10769 | 2039 |
asAutoDeletedFilename |
13653
6821135a2e1a
comment/format in: #asAutoDeletedFilename
Claus Gittinger <cg@exept.de>
parents:
13424
diff
changeset
|
2040 |
"will automatically delete myself, when no longer referenced" |
6821135a2e1a
comment/format in: #asAutoDeletedFilename
Claus Gittinger <cg@exept.de>
parents:
13424
diff
changeset
|
2041 |
|
11784 | 2042 |
^ AutoDeletedFilename basicNew setName:self name |
13653
6821135a2e1a
comment/format in: #asAutoDeletedFilename
Claus Gittinger <cg@exept.de>
parents:
13424
diff
changeset
|
2043 |
|
6821135a2e1a
comment/format in: #asAutoDeletedFilename
Claus Gittinger <cg@exept.de>
parents:
13424
diff
changeset
|
2044 |
"Modified (comment): / 07-09-2011 / 12:20:59 / cg" |
10769 | 2045 |
! |
2046 |
||
6802 | 2047 |
asCanonicalizedFilename |
2048 |
"return the receiver converted to a filename without intermediate ..'s and .'s |
|
2049 |
(similar to an absolute pathname, but symlinks are not resolved)." |
|
2050 |
||
15811 | 2051 |
^ self species named:(self species canonicalize:nameString) |
7074 | 2052 |
|
2053 |
" |
|
2054 |
'c:\test\work' asFilename asCanonicalizedFilename |
|
2055 |
'/test/work' asFilename asCanonicalizedFilename |
|
2056 |
" |
|
6802 | 2057 |
! |
2058 |
||
615 | 2059 |
asFilename |
20413 | 2060 |
"return the receiver converted to a filename; here, that's the receiver itself." |
2061 |
||
2062 |
"That's pretty easy here :-)" |
|
615 | 2063 |
^ self |
1970 | 2064 |
|
2065 |
"Modified: 12.11.1996 / 12:40:03 / cg" |
|
615 | 2066 |
! |
2067 |
||
2068 |
asString |
|
2069 |
"return the receiver converted to a string" |
|
2070 |
||
2071 |
^ nameString |
|
2072 |
! |
|
2073 |
||
6256 | 2074 |
asURI |
15001 | 2075 |
"return the receiver converted to a file URI" |
6256 | 2076 |
|
2077 |
^ FileURI fromFilename:self. |
|
2078 |
! |
|
2079 |
||
15001 | 2080 |
asURL |
2081 |
"return an URL-object from myself" |
|
2082 |
||
2083 |
^ URL fromString:self pathName. |
|
2084 |
! |
|
2085 |
||
19665 | 2086 |
asUniqueFilename |
2087 |
"I a file by my name already exists, return a new filename with a unique string appended. |
|
2088 |
here, a somewhat naive strategy is performed, by trying _1, _2,... until a new name is generated." |
|
2089 |
||
2090 |
|fn baseFn nextSeqNr| |
|
2091 |
||
2092 |
fn := baseFn := self. |
|
2093 |
nextSeqNr := 0. |
|
2094 |
[ fn exists ] whileTrue:[ |
|
20453 | 2095 |
|newFn suff| |
19665 | 2096 |
|
2097 |
nextSeqNr := (nextSeqNr ? 0) + 1. |
|
20453 | 2098 |
suff := baseFn suffix. |
2099 |
suff notEmpty ifTrue:[ suff := '.',suff ]. |
|
2100 |
fn := self class named:((baseFn withoutSuffix name,'_',nextSeqNr asString),suff). |
|
19665 | 2101 |
]. |
2102 |
^ fn |
|
2103 |
||
2104 |
" |
|
2105 |
'aaa.txt' asFilename contents:'bla'. |
|
20453 | 2106 |
'aaa.1.2.3.apk.txt' asFilename asUniqueFilename contents:'bla2'. |
19665 | 2107 |
'aaa.txt' asFilename asUniqueFilename contents:'bla3'. |
2108 |
'aaa.txt' asFilename asUniqueFilename contents:'bla4'. |
|
2109 |
#('aaa.txt' 'aaa_1.txt' 'aaa_2.txt' 'aaa_3.txt') do:[:f | f asFilename delete]. |
|
2110 |
" |
|
2111 |
! |
|
2112 |
||
5890 | 2113 |
components |
19440 | 2114 |
"return the receiver's filename components - that is the name of each directory |
5890 | 2115 |
along the pathName (that DOES include the root directory)" |
2116 |
||
15811 | 2117 |
^ self species components:self name |
5890 | 2118 |
|
2119 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2120 |
'.' asFilename asAbsoluteFilename components |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2121 |
'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
|
2122 |
" |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2123 |
! |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2124 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2125 |
makeLegalFilename |
19440 | 2126 |
"convert the receiver's name to be a legal filename. |
1970 | 2127 |
This removes/replaces invalid characters and/or compresses |
2128 |
the name as required by the OS. |
|
615 | 2129 |
The implementation may change in the future to be more |
2130 |
OS specific." |
|
2131 |
||
2132 |
" |
|
2133 |
actually, in Unix spaces are allowed - but it makes life |
|
2134 |
so hard; therefore, replace them by underscores ... |
|
2135 |
" |
|
16761 | 2136 |
nameString := nameString copyReplaceAll:(Character space) with:$_ ifNone:nameString. |
615 | 2137 |
" |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2138 |
need more - especially on SYS5.3 type systems, |
615 | 2139 |
we may want to contract the fileName to 14 characters. |
2140 |
" |
|
2141 |
^ self |
|
2142 |
||
2143 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2144 |
'hello world' asFilename makeLegalFilename |
615 | 2145 |
" |
1970 | 2146 |
|
3658 | 2147 |
"Modified: / 20.7.1998 / 13:16:51 / cg" |
2707
280456505357
added #findDefaultDirectory and #withEncoding:
Claus Gittinger <cg@exept.de>
parents:
2630
diff
changeset
|
2148 |
! |
280456505357
added #findDefaultDirectory and #withEncoding:
Claus Gittinger <cg@exept.de>
parents:
2630
diff
changeset
|
2149 |
|
280456505357
added #findDefaultDirectory and #withEncoding:
Claus Gittinger <cg@exept.de>
parents:
2630
diff
changeset
|
2150 |
withEncoding:encodingSymbol |
280456505357
added #findDefaultDirectory and #withEncoding:
Claus Gittinger <cg@exept.de>
parents:
2630
diff
changeset
|
2151 |
"dummy for now - for ST80 compatibility" |
280456505357
added #findDefaultDirectory and #withEncoding:
Claus Gittinger <cg@exept.de>
parents:
2630
diff
changeset
|
2152 |
|
280456505357
added #findDefaultDirectory and #withEncoding:
Claus Gittinger <cg@exept.de>
parents:
2630
diff
changeset
|
2153 |
^ self |
280456505357
added #findDefaultDirectory and #withEncoding:
Claus Gittinger <cg@exept.de>
parents:
2630
diff
changeset
|
2154 |
|
280456505357
added #findDefaultDirectory and #withEncoding:
Claus Gittinger <cg@exept.de>
parents:
2630
diff
changeset
|
2155 |
"Created: 20.6.1997 / 17:01:28 / cg" |
2 | 2156 |
! ! |
2157 |
||
18272 | 2158 |
|
5889
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2159 |
!Filename methodsFor:'enumerating-contents'! |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2160 |
|
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2161 |
allDirectoriesDo:aBlock |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2162 |
"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
|
2163 |
The block is invoked with a filename-arguments. |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2164 |
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
|
2165 |
filenames (but by creation time - on some systems). |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2166 |
This excludes entries for '.' or '..'. |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2167 |
NoOp for non-existing directories; however, this behavior |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2168 |
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
|
2169 |
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
|
2170 |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2171 |
self recursiveDirectoryContentsDo:[:eachFileOrDirectoryName | |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2172 |
|eachFileOrDirectory| |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2173 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2174 |
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
|
2175 |
eachFileOrDirectory isDirectory ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2176 |
aBlock value:eachFileOrDirectory |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2177 |
] |
5889
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2178 |
]. |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2179 |
|
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2180 |
" |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2181 |
'.' asFilename allDirectoriesDo:[:fn | Transcript showCR:fn name]. |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2182 |
'.' asFilename directoriesDo:[:fn | Transcript showCR:fn name]. |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2183 |
" |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2184 |
! |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2185 |
|
6773
26415b61ad09
isMountPoint & isParentDirectoryOf & allParentDirsDo:
penk
parents:
6771
diff
changeset
|
2186 |
allParentDirectoriesDo:aBlock |
26415b61ad09
isMountPoint & isParentDirectoryOf & allParentDirsDo:
penk
parents:
6771
diff
changeset
|
2187 |
"evaluate aBlock for all (recursive) directories along the parent directory path. |
26415b61ad09
isMountPoint & isParentDirectoryOf & allParentDirsDo:
penk
parents:
6771
diff
changeset
|
2188 |
The block is invoked with a filename-arguments." |
26415b61ad09
isMountPoint & isParentDirectoryOf & allParentDirsDo:
penk
parents:
6771
diff
changeset
|
2189 |
|
26415b61ad09
isMountPoint & isParentDirectoryOf & allParentDirsDo:
penk
parents:
6771
diff
changeset
|
2190 |
|parent here| |
26415b61ad09
isMountPoint & isParentDirectoryOf & allParentDirsDo:
penk
parents:
6771
diff
changeset
|
2191 |
|
26415b61ad09
isMountPoint & isParentDirectoryOf & allParentDirsDo:
penk
parents:
6771
diff
changeset
|
2192 |
here := self. |
26415b61ad09
isMountPoint & isParentDirectoryOf & allParentDirsDo:
penk
parents:
6771
diff
changeset
|
2193 |
parent := here directory. |
26415b61ad09
isMountPoint & isParentDirectoryOf & allParentDirsDo:
penk
parents:
6771
diff
changeset
|
2194 |
[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
|
2195 |
aBlock value:parent. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2196 |
here := parent. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2197 |
parent := here directory. |
6773
26415b61ad09
isMountPoint & isParentDirectoryOf & allParentDirsDo:
penk
parents:
6771
diff
changeset
|
2198 |
]. |
26415b61ad09
isMountPoint & isParentDirectoryOf & allParentDirsDo:
penk
parents:
6771
diff
changeset
|
2199 |
|
26415b61ad09
isMountPoint & isParentDirectoryOf & allParentDirsDo:
penk
parents:
6771
diff
changeset
|
2200 |
" |
26415b61ad09
isMountPoint & isParentDirectoryOf & allParentDirsDo:
penk
parents:
6771
diff
changeset
|
2201 |
'.' asFilename allParentDirectoriesDo:[:fn | Transcript showCR:fn pathName]. |
26415b61ad09
isMountPoint & isParentDirectoryOf & allParentDirsDo:
penk
parents:
6771
diff
changeset
|
2202 |
" |
26415b61ad09
isMountPoint & isParentDirectoryOf & allParentDirsDo:
penk
parents:
6771
diff
changeset
|
2203 |
! |
26415b61ad09
isMountPoint & isParentDirectoryOf & allParentDirsDo:
penk
parents:
6771
diff
changeset
|
2204 |
|
9362 | 2205 |
directories |
2206 |
"return a collection of directories contained in the directory represented by the receiver." |
|
2207 |
||
19821 | 2208 |
^ OrderedCollection withCollectedContents:[:coll | |
2209 |
self directoriesDo:[:eachDirectory | coll add:eachDirectory]] |
|
9362 | 2210 |
|
2211 |
" |
|
2212 |
'.' asFilename directories. |
|
2213 |
" |
|
10557 | 2214 |
|
2215 |
"Modified: / 29-05-2007 / 12:02:56 / cg" |
|
9362 | 2216 |
! |
2217 |
||
5889
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2218 |
directoriesDo:aBlock |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2219 |
"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
|
2220 |
The block is invoked with a filename-arguments. |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2221 |
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
|
2222 |
filenames (but by creation time - on some systems). |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2223 |
This excludes entries for '.' or '..'. |
18686 | 2224 |
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
|
2225 |
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
|
2226 |
|
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2227 |
self directoryContentsAsFilenamesDo:[:eachFileOrDirectory | |
19599 | 2228 |
eachFileOrDirectory isDirectory ifTrue:[ |
2229 |
aBlock value:eachFileOrDirectory |
|
2230 |
] |
|
5889
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2231 |
]. |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2232 |
|
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2233 |
" |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2234 |
'.' asFilename directoriesDo:[:fn | Transcript showCR:fn baseName]. |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2235 |
" |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2236 |
! |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2237 |
|
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2238 |
directoryContentsAsFilenamesDo:aBlock |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2239 |
"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
|
2240 |
The block is invoked with a filename-argument. |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2241 |
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
|
2242 |
filenames (but by creation time - on some systems). |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2243 |
This excludes entries for '.' or '..'. |
17310 | 2244 |
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
|
2245 |
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
|
2246 |
Notice: this enumerates fileName objects; see also |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2247 |
#directoryContentsDo:, which enumerates strings." |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2248 |
|
6776
11df52e55905
better loop (dont preread all items in ..asFilenamesDo:)
penk
parents:
6773
diff
changeset
|
2249 |
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
|
2250 |
aBlock value:(self construct:entry). |
6776
11df52e55905
better loop (dont preread all items in ..asFilenamesDo:)
penk
parents:
6773
diff
changeset
|
2251 |
] |
5889
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 |
" |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2254 |
'.' asFilename directoryContentsAsFilenamesDo:[:fn | Transcript showCR:fn pathName]. |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2255 |
" |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2256 |
|
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2257 |
"Modified: / 18.9.1997 / 18:42:23 / stefan" |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2258 |
"Modified: / 23.12.1999 / 20:56:35 / cg" |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2259 |
! |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2260 |
|
7464 | 2261 |
directoryContentsDo:aBlock |
2262 |
"evaluate aBlock for each file in the directory represented by the receiver. |
|
2263 |
The block is invoked with a string as argument. |
|
2264 |
The enumerations order is undefined - i.e. usually NOT sorted by |
|
2265 |
filenames (but by creation time - on some systems). |
|
2266 |
This excludes entries for '.' or '..'. |
|
17310 | 2267 |
An OpenError exception is raised it the directory does not exist or is not readable. |
7464 | 2268 |
So users of this method better test for existing directory before. |
2269 |
Notice: this enumerates strings; see also |
|
2270 |
#directoryContentsAsFilenamesDo:, which enumerates fileName objects." |
|
2271 |
||
20533 | 2272 |
|s files| |
17310 | 2273 |
|
2274 |
s := DirectoryStream directoryNamed:self osNameForDirectoryContents. |
|
2275 |
"check for nil, in order to allow to proceed from an OpenError" |
|
2276 |
s notNil ifTrue:[ |
|
20533 | 2277 |
"/ the old code did a recursive call with the stream open. |
2278 |
"/ for very very deep hierarchies, this lead to having too many file streams open for |
|
2279 |
"/ some operating systems. |
|
2280 |
"/ (and therefore to a blocked system, sooner or later, when running out of open files) |
|
2281 |
"/ new code reads the directory first, then does the recursion. |
|
2282 |
||
2283 |
"/ [ |
|
2284 |
"/ [s atEnd] whileFalse:[ |
|
2285 |
"/ |fn| |
|
2286 |
"/ |
|
2287 |
"/ fn := s nextLine. |
|
2288 |
"/ (fn notNil and:[fn ~= '.' and:[fn ~= '..']]) ifTrue:[ |
|
2289 |
"/ aBlock value:fn |
|
2290 |
"/ ]. |
|
2291 |
"/ ]. |
|
2292 |
"/ ] ensure:[ |
|
2293 |
"/ s close. |
|
2294 |
"/ ]. |
|
2295 |
files := OrderedCollection new. |
|
2296 |
||
19821 | 2297 |
[ |
2298 |
[s atEnd] whileFalse:[ |
|
2299 |
|fn| |
|
2300 |
||
2301 |
fn := s nextLine. |
|
2302 |
(fn notNil and:[fn ~= '.' and:[fn ~= '..']]) ifTrue:[ |
|
20533 | 2303 |
files add:fn |
19821 | 2304 |
]. |
2305 |
]. |
|
2306 |
] ensure:[ |
|
2307 |
s close. |
|
20533 | 2308 |
]. |
2309 |
files do:aBlock |
|
7464 | 2310 |
]. |
2311 |
||
2312 |
" |
|
2313 |
'.' asFilename directoryContentsDo:[:fn | Transcript showCR:fn]. |
|
7473 | 2314 |
'doeSnotExIST' asFilename directoryContentsDo:[:fn | Transcript showCR:fn]. |
17310 | 2315 |
[ |
19821 | 2316 |
'doeSnotExIST' asFilename directoryContentsDo:[:fn | Transcript showCR:fn]. |
17310 | 2317 |
] on:OpenError do:[:ex| ex proceed] |
7464 | 2318 |
" |
2319 |
||
2320 |
"Modified: / 18.9.1997 / 18:42:23 / stefan" |
|
2321 |
"Modified: / 23.12.1999 / 20:56:35 / cg" |
|
2322 |
! |
|
2323 |
||
9382 | 2324 |
files |
19599 | 2325 |
"return a collection of regular files |
18734 | 2326 |
contained in the directory represented by the receiver." |
9382 | 2327 |
|
19821 | 2328 |
^ OrderedCollection withCollectedContents:[:coll | |
2329 |
self filesDo:[:eachFileName | coll add:eachFileName]]. |
|
9382 | 2330 |
|
2331 |
" |
|
2332 |
'.' asFilename files. |
|
2333 |
" |
|
10557 | 2334 |
|
2335 |
"Modified: / 29-05-2007 / 12:02:15 / cg" |
|
9382 | 2336 |
! |
2337 |
||
9806 | 2338 |
filesDo:aBlock |
18734 | 2339 |
"evaluate aBlock for all regular files (i.e. subdirs are ignored) |
2340 |
contained in the directory represented by the receiver." |
|
9806 | 2341 |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2342 |
^ self directoryContentsAsFilenamesDo:[:eachFileOrDirectory | |
19599 | 2343 |
eachFileOrDirectory isRegularFile ifTrue:[ |
2344 |
aBlock value: eachFileOrDirectory |
|
2345 |
]. |
|
17310 | 2346 |
]. |
9806 | 2347 |
|
2348 |
" |
|
2349 |
'.' asFilename filesDo:[:f | Transcript showCR:f]. |
|
2350 |
" |
|
2351 |
||
2352 |
"Created: / 29-08-2006 / 11:03:15 / cg" |
|
10557 | 2353 |
"Modified: / 29-05-2007 / 12:02:46 / cg" |
9806 | 2354 |
! |
2355 |
||
19821 | 2356 |
filesMatchingGLOB:pattern do:aBlock |
2357 |
"Interpreting pattern as a GLOB pattern, |
|
2358 |
evaluate aBlock for each file in me, which matches. |
|
2359 |
Returns the number of matches." |
|
2360 |
||
2361 |
self assert:(pattern asFilename isAbsolute not). |
|
2362 |
^ self filesMatchingGLOBComponents:(Filename components:pattern) do:aBlock |
|
2363 |
||
2364 |
" |
|
2365 |
'..' asFilename filesMatchingGLOB:'A*' do:[:fn | Transcript showCR:fn]. |
|
2366 |
'../..' asFilename filesMatchingGLOB:'lib*/*.st' do:[:fn | Transcript showCR:fn]. |
|
2367 |
" |
|
2368 |
! |
|
2369 |
||
2370 |
filesMatchingGLOBComponents:patternComponents do:aBlock |
|
2371 |
"patternComponents is a component-collection with possible GLOB patterns. |
|
2372 |
Evaluate aBlock for each file in me, which matches. |
|
2373 |
Returns the number of matches" |
|
2374 |
||
2375 |
|dirPath subComponents count| |
|
2376 |
||
2377 |
dirPath := patternComponents first. |
|
2378 |
subComponents := patternComponents copyFrom:2. |
|
2379 |
||
2380 |
dirPath includesMatchCharacters ifFalse:[ |
|
2381 |
| sub | |
|
2382 |
||
2383 |
sub := (self / dirPath). |
|
2384 |
subComponents isEmpty ifTrue:[ |
|
2385 |
"/ I am a leaf |
|
2386 |
sub exists ifTrue:[ |
|
2387 |
aBlock value:sub. |
|
2388 |
^ 1. |
|
2389 |
]. |
|
2390 |
^ 0 |
|
2391 |
] ifFalse:[ |
|
2392 |
^ sub filesMatchingGLOBComponents:subComponents do:aBlock |
|
2393 |
]. |
|
2394 |
] ifTrue:[ |
|
2395 |
count := 0. |
|
2396 |
subComponents isEmpty ifTrue:[ |
|
2397 |
"/ I am a leaf |
|
2398 |
self isDirectory ifTrue:[ |
|
2399 |
self filesMatching:dirPath do:[:eachMatchingFile | |
|
2400 |
aBlock value:(self / eachMatchingFile). |
|
2401 |
count := count + 1. |
|
2402 |
] |
|
2403 |
] |
|
2404 |
] ifFalse:[ |
|
2405 |
self filesMatching:dirPath do:[:eachMatchingSubDir | |
|
2406 |
|sub| |
|
2407 |
sub := (self / eachMatchingSubDir). |
|
2408 |
sub isDirectory ifTrue:[ |
|
2409 |
count := count + (sub filesMatchingGLOBComponents:subComponents do:aBlock) |
|
2410 |
]. |
|
2411 |
]. |
|
2412 |
]. |
|
2413 |
^ count |
|
2414 |
]. |
|
2415 |
||
2416 |
" |
|
2417 |
'/etc/A*' asFilename filesMatchingGLOBDo:[:fn | Transcript showCR:fn]. |
|
2418 |
'../A*' asFilename filesMatchingGLOBDo:[:fn | Transcript showCR:fn]. |
|
2419 |
'../../lib*/*.st' asFilename filesMatchingGLOBDo:[:fn | Transcript showCR:fn]. |
|
2420 |
" |
|
2421 |
! |
|
2422 |
||
2423 |
filesMatchingGLOBDo:aBlock |
|
2424 |
"Interpreting myself as a GLOB pattern, |
|
2425 |
evaluate aBlock for each file which matches." |
|
2426 |
||
2427 |
|parts dirPath subComponents count top| |
|
2428 |
||
2429 |
parts := self components. |
|
2430 |
dirPath := parts first. |
|
2431 |
subComponents := parts copyFrom:2. |
|
2432 |
||
2433 |
OpenError handle:[:ex | |
|
2434 |
('%1 [info]: failed to open %2: %3' |
|
2435 |
bindWith:self class name |
|
2436 |
with:ex pathName |
|
2437 |
with:ex description) infoPrintCR. |
|
2438 |
self breakPoint:#cg. |
|
2439 |
ex proceed. |
|
2440 |
] do:[ |
|
2441 |
top := dirPath asFilename. |
|
2442 |
||
2443 |
dirPath includesMatchCharacters ifFalse:[ |
|
2444 |
top isAbsolute ifFalse:[ |
|
2445 |
top := Filename currentDirectory construct:dirPath. |
|
2446 |
]. |
|
2447 |
^ top filesMatchingGLOBComponents:subComponents do:aBlock |
|
2448 |
]. |
|
2449 |
||
2450 |
top isAbsolute ifFalse:[ |
|
2451 |
top := Filename currentDirectory. |
|
2452 |
]. |
|
2453 |
count := 0. |
|
2454 |
top filesMatching:dirPath do:[:sub | |
|
2455 |
count := count + ((self / sub) filesMatchingGLOBComponents:subComponents do:aBlock) |
|
2456 |
]. |
|
2457 |
^ count |
|
2458 |
]. |
|
2459 |
||
2460 |
" |
|
2461 |
'/etc/A*' asFilename filesMatchingGLOBDo:[:fn | Transcript showCR:fn]. |
|
2462 |
'/etc/a*' asFilename filesMatchingGLOBDo:[:fn | Transcript showCR:fn]. |
|
2463 |
'../A*' asFilename filesMatchingGLOBDo:[:fn | Transcript showCR:fn]. |
|
2464 |
'../../lib*/*.st' asFilename filesMatchingGLOBDo:[:fn | Transcript showCR:fn]. |
|
2465 |
'../../lib*/[A-D]*.st' asFilename filesMatchingGLOBDo:[:fn | Transcript showCR:fn]. |
|
2466 |
'../../*/[A-D]*.st' asFilename filesMatchingGLOBDo:[:fn | Transcript showCR:fn]. |
|
2467 |
'../../*/*/[A-D]*.st' asFilename filesMatchingGLOBDo:[:fn | Transcript showCR:fn]. |
|
2468 |
'../../*java*/*/[A-D]*.st' asFilename filesMatchingGLOBDo:[:fn | Transcript showCR:fn]. |
|
2469 |
'../../*java*/*/Ary.st' asFilename filesMatchingGLOBDo:[:fn | Transcript showCR:fn]. |
|
2470 |
'/*/A*' asFilename filesMatchingGLOBDo:[:fn | Transcript showCR:fn]. |
|
2471 |
'*/A*' asFilename filesMatchingGLOBDo:[:fn | Transcript showCR:fn]. |
|
2472 |
'../*/A*' asFilename filesMatchingGLOBDo:[:fn | Transcript showCR:fn]. |
|
2473 |
'./*/A*' asFilename filesMatchingGLOBDo:[:fn | Transcript showCR:fn]. |
|
2474 |
'./*/*' asFilename filesMatchingGLOBDo:[:fn | Transcript showCR:fn]. |
|
2475 |
'././A*' asFilename filesMatchingGLOBDo:[:fn | Transcript showCR:fn]. |
|
2476 |
" |
|
2477 |
! |
|
2478 |
||
18734 | 2479 |
filesWithSuffix:suffix |
2480 |
"return a collection of regular files (i.e. not subdirectories) |
|
19599 | 2481 |
with a given suffix which are contained in the directory |
18734 | 2482 |
represented by the receiver." |
2483 |
||
19821 | 2484 |
^ OrderedCollection withCollectedContents:[:coll | |
2485 |
self filesWithSuffix:suffix do:[:eachFileName | coll add:eachFileName]]. |
|
18734 | 2486 |
|
2487 |
" |
|
2488 |
'.' asFilename filesWithSuffix:'so'. |
|
19821 | 2489 |
'packages' asFilename filesWithSuffix:'so'. |
18734 | 2490 |
" |
2491 |
! |
|
2492 |
||
2493 |
filesWithSuffix:suffix do:aBlock |
|
2494 |
"evaluate aBlock for all regular files with a given suffix |
|
2495 |
contained in the directory represented by the receiver. |
|
2496 |
(i.e. subdirs are ignored)" |
|
2497 |
||
2498 |
^ self directoryContentsAsFilenamesDo:[:eachFileOrDirectory | |
|
19599 | 2499 |
(eachFileOrDirectory hasSuffix:suffix) ifTrue:[ |
2500 |
eachFileOrDirectory isRegularFile ifTrue:[ |
|
2501 |
aBlock value: eachFileOrDirectory |
|
2502 |
]. |
|
2503 |
]. |
|
18734 | 2504 |
]. |
2505 |
||
2506 |
" |
|
2507 |
'.' asFilename filesWithSuffix:'so' do:[:f | Transcript showCR:f]. |
|
2508 |
" |
|
2509 |
! |
|
2510 |
||
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2511 |
recursiveDirectoryContentsAsFilenamesDo:aBlock |
13191
10ffa6ac5505
added: #recursiveDirectoryContentsAsFilenamesDo:
Claus Gittinger <cg@exept.de>
parents:
13139
diff
changeset
|
2512 |
"evaluate aBlock for all files and directories found under the receiver. |
10ffa6ac5505
added: #recursiveDirectoryContentsAsFilenamesDo:
Claus Gittinger <cg@exept.de>
parents:
13139
diff
changeset
|
2513 |
The block is invoked with the filenames as argument. |
10ffa6ac5505
added: #recursiveDirectoryContentsAsFilenamesDo:
Claus Gittinger <cg@exept.de>
parents:
13139
diff
changeset
|
2514 |
The walk is bread-first. |
10ffa6ac5505
added: #recursiveDirectoryContentsAsFilenamesDo:
Claus Gittinger <cg@exept.de>
parents:
13139
diff
changeset
|
2515 |
This excludes any entries for '.' or '..'. |
10ffa6ac5505
added: #recursiveDirectoryContentsAsFilenamesDo:
Claus Gittinger <cg@exept.de>
parents:
13139
diff
changeset
|
2516 |
Subdirectory files are included with a relative pathname. |
10ffa6ac5505
added: #recursiveDirectoryContentsAsFilenamesDo:
Claus Gittinger <cg@exept.de>
parents:
13139
diff
changeset
|
2517 |
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
|
2518 |
|
10ffa6ac5505
added: #recursiveDirectoryContentsAsFilenamesDo:
Claus Gittinger <cg@exept.de>
parents:
13139
diff
changeset
|
2519 |
self recursiveDirectoryContentsDo:[:relFn | |
19664 | 2520 |
aBlock value:(self construct:relFn) |
13191
10ffa6ac5505
added: #recursiveDirectoryContentsAsFilenamesDo:
Claus Gittinger <cg@exept.de>
parents:
13139
diff
changeset
|
2521 |
]. |
10ffa6ac5505
added: #recursiveDirectoryContentsAsFilenamesDo:
Claus Gittinger <cg@exept.de>
parents:
13139
diff
changeset
|
2522 |
|
10ffa6ac5505
added: #recursiveDirectoryContentsAsFilenamesDo:
Claus Gittinger <cg@exept.de>
parents:
13139
diff
changeset
|
2523 |
" |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2524 |
'.' asFilename recursiveDirectoryContentsAsFilenamesDo:[:f | Transcript showCR:f] |
13191
10ffa6ac5505
added: #recursiveDirectoryContentsAsFilenamesDo:
Claus Gittinger <cg@exept.de>
parents:
13139
diff
changeset
|
2525 |
" |
10ffa6ac5505
added: #recursiveDirectoryContentsAsFilenamesDo:
Claus Gittinger <cg@exept.de>
parents:
13139
diff
changeset
|
2526 |
|
10ffa6ac5505
added: #recursiveDirectoryContentsAsFilenamesDo:
Claus Gittinger <cg@exept.de>
parents:
13139
diff
changeset
|
2527 |
"Modified: / 12-09-2010 / 15:43:22 / cg" |
10ffa6ac5505
added: #recursiveDirectoryContentsAsFilenamesDo:
Claus Gittinger <cg@exept.de>
parents:
13139
diff
changeset
|
2528 |
! |
10ffa6ac5505
added: #recursiveDirectoryContentsAsFilenamesDo:
Claus Gittinger <cg@exept.de>
parents:
13139
diff
changeset
|
2529 |
|
20686 | 2530 |
recursiveDirectoryContentsAsFilenamesDo:aBlock filterForVisitingDirectories:filterOrNil |
2531 |
"evaluate aBlock for all files and directories found under the receiver. |
|
2532 |
The block is invoked with the filenames as argument. |
|
2533 |
The walk is bread-first. |
|
2534 |
This excludes any entries for '.' or '..'. |
|
2535 |
Subdirectory files are included with a relative pathname. |
|
2536 |
If filterOrNil is nonNil, it is passed every directory about to be walked into; |
|
2537 |
if it returns false, that directory is not entered. |
|
2538 |
Warning: this may take a long time to execute |
|
2539 |
(especially with deep and/or remote fileSystems)." |
|
2540 |
||
2541 |
self |
|
2542 |
recursiveDirectoryContentsDo:[:relFn | |
|
2543 |
aBlock value:(self construct:relFn) |
|
2544 |
] |
|
2545 |
filterForVisitingDirectories:filterOrNil. |
|
2546 |
||
2547 |
" |
|
2548 |
'.' asFilename recursiveDirectoryContentsAsFilenamesDo:[:f | Transcript showCR:f] |
|
2549 |
" |
|
2550 |
||
2551 |
"Modified: / 12-09-2010 / 15:43:22 / cg" |
|
2552 |
! |
|
2553 |
||
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2554 |
recursiveDirectoryContentsDo:aBlock |
5889
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2555 |
"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
|
2556 |
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
|
2557 |
The walk is bread-first. |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2558 |
This excludes any entries for '.' or '..'. |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2559 |
Subdirectory files are included with a relative pathname. |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2560 |
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
|
2561 |
|
19664 | 2562 |
self |
2563 |
recursiveDirectoryContentsWithPrefix:'' |
|
2564 |
filesDo:aBlock |
|
2565 |
directoriesDo:aBlock |
|
5889
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2566 |
|
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2567 |
" |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2568 |
'.' asFilename recursiveDirectoryContentsDo:[:f | Transcript showCR:f] |
5889
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2569 |
" |
13057
4f7fa62156ac
comment/format in: #recursiveDirectoryContentsDo:
Claus Gittinger <cg@exept.de>
parents:
12975
diff
changeset
|
2570 |
|
4f7fa62156ac
comment/format in: #recursiveDirectoryContentsDo:
Claus Gittinger <cg@exept.de>
parents:
12975
diff
changeset
|
2571 |
"Modified: / 12-09-2010 / 15:43:22 / cg" |
5889
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2572 |
! |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2573 |
|
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2574 |
recursiveDirectoryContentsDo:aBlock directoryPrefix:aPrefix |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2575 |
"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
|
2576 |
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
|
2577 |
The walk is breadth-first. |
5889
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2578 |
This excludes any entries for '.' or '..'. |
19664 | 2579 |
The argument to aBlock is a pathname relative to aPrefix. |
19114 | 2580 |
A proceedable exception is raised forn non-accessible directories. |
5889
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2581 |
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
|
2582 |
|
19664 | 2583 |
self |
2584 |
recursiveDirectoryContentsWithPrefix:aPrefix |
|
2585 |
filesDo:aBlock |
|
2586 |
directoriesDo:aBlock |
|
5889
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2587 |
|
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2588 |
" |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2589 |
'.' 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
|
2590 |
'/etc' asFilename recursiveDirectoryContentsDo:[:f | Transcript showCR:f] |
5889
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2591 |
" |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2592 |
! |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2593 |
|
20686 | 2594 |
recursiveDirectoryContentsDo:aBlock filterForVisitingDirectories:filterOrNil |
2595 |
"evaluate aBlock for all files and directories found under the receiver. |
|
2596 |
The block is invoked with the relative filenames as string-argument. |
|
2597 |
The walk is bread-first. |
|
2598 |
This excludes any entries for '.' or '..'. |
|
2599 |
Subdirectory files are included with a relative pathname. |
|
2600 |
If filterOrNil is nonNil, it is passed every directory about to be walked into; |
|
2601 |
if it returns false, that directory is not entered. |
|
2602 |
Warning: this may take a long time to execute |
|
2603 |
(especially with deep and/or remote fileSystems)." |
|
2604 |
||
2605 |
self |
|
2606 |
recursiveDirectoryContentsWithPrefix:'' |
|
2607 |
filesDo:aBlock |
|
2608 |
directoriesDo:aBlock |
|
2609 |
filterForVisitingDirectories:filterOrNil |
|
2610 |
||
2611 |
" |
|
2612 |
'.' asFilename recursiveDirectoryContentsDo:[:f | Transcript showCR:f] |
|
2613 |
" |
|
2614 |
||
2615 |
"Modified: / 12-09-2010 / 15:43:22 / cg" |
|
2616 |
! |
|
2617 |
||
19664 | 2618 |
recursiveDirectoryContentsWithPrefix:aPrefix filesDo:fileBlock directoriesDo:dirBlock |
2619 |
"evaluate aBlock for all files and directories found under the receiver. |
|
2620 |
The blocks are invoked with a relative pathname as string-argument. |
|
2621 |
The walk is breadth-first (first files, then directories). |
|
2622 |
This excludes any entries for '.' or '..'. |
|
2623 |
A proceedable exception is raised for non-accessible directories. |
|
20686 | 2624 |
Warning: this may take a long time to execute |
2625 |
(especially with deep and/or remote fileSystems)." |
|
2626 |
||
2627 |
self |
|
2628 |
recursiveDirectoryContentsWithPrefix:aPrefix |
|
2629 |
filesDo:fileBlock |
|
2630 |
directoriesDo:dirBlock |
|
2631 |
filterForVisitingDirectories:nil |
|
2632 |
||
2633 |
" |
|
2634 |
'.' asFilename |
|
2635 |
recursiveDirectoryContentsWithPrefix:'bla' |
|
2636 |
filesDo:[:f | Transcript show:'file: '; showCR:f] |
|
2637 |
directoriesDo:[:f | Transcript show:'dir: '; showCR:f] |
|
2638 |
" |
|
2639 |
! |
|
2640 |
||
2641 |
recursiveDirectoryContentsWithPrefix:aPrefix filesDo:fileBlock directoriesDo:dirBlock filterForVisitingDirectories:filterOrNil |
|
2642 |
"evaluate aBlock for all files and directories found under the receiver. |
|
2643 |
The blocks are invoked with a relative pathname as string-argument. |
|
2644 |
The walk is breadth-first (first files, then directories). |
|
2645 |
This excludes any entries for '.' or '..'. |
|
2646 |
A proceedable exception is raised for non-accessible directories. |
|
2647 |
If filterOrNil is nonNil, it is passed every directory about to be walked into; |
|
2648 |
if it returns false, that directory is not entered. |
|
2649 |
Warning: this may take a long time to execute |
|
2650 |
(especially with deep and/or remote fileSystems). |
|
2651 |
" |
|
19664 | 2652 |
|
2653 |
|fileNames dirNames p| |
|
2654 |
||
2655 |
"/ first collect files and dirs |
|
2656 |
fileNames := OrderedCollection new. |
|
2657 |
dirNames := OrderedCollection new. |
|
2658 |
||
2659 |
self directoryContentsDo:[:f | |t| |
|
2660 |
t := self construct:f. |
|
2661 |
t isDirectory ifTrue:[ |
|
20686 | 2662 |
(filterOrNil isNil or:[filterOrNil value:t]) ifTrue:[ |
2663 |
dirBlock notNil ifTrue:[ |
|
2664 |
t isSymbolicLink ifFalse:[ |
|
2665 |
dirNames add:f |
|
2666 |
] |
|
19664 | 2667 |
] |
2668 |
] |
|
2669 |
] ifFalse:[ |
|
2670 |
fileBlock notNil ifTrue:[ |
|
2671 |
fileNames add:f |
|
2672 |
] |
|
2673 |
] |
|
2674 |
]. |
|
2675 |
||
2676 |
aPrefix size > 0 ifTrue:[ |
|
2677 |
p := aPrefix , self separator |
|
2678 |
] ifFalse:[ |
|
2679 |
p := '' |
|
2680 |
]. |
|
2681 |
||
2682 |
fileBlock notNil ifTrue:[ |
|
2683 |
fileNames do:[:aFile | fileBlock value:(p , aFile)]. |
|
2684 |
]. |
|
2685 |
dirBlock notNil ifTrue:[ |
|
2686 |
dirNames do:[:dN | |
|
20686 | 2687 |
|subDir| |
2688 |
||
2689 |
subDir := (self construct:dN). |
|
2690 |
(filterOrNil isNil or:[filterOrNil value:subDir]) ifTrue:[ |
|
2691 |
dirBlock value:(p , dN). |
|
2692 |
subDir |
|
2693 |
recursiveDirectoryContentsWithPrefix:(p , dN) |
|
2694 |
filesDo:fileBlock directoriesDo:dirBlock |
|
2695 |
]. |
|
19664 | 2696 |
]. |
2697 |
]. |
|
2698 |
||
2699 |
" |
|
2700 |
'.' asFilename |
|
2701 |
recursiveDirectoryContentsWithPrefix:'bla' |
|
2702 |
filesDo:[:f | Transcript show:'file: '; showCR:f] |
|
2703 |
directoriesDo:[:f | Transcript show:'dir: '; showCR:f] |
|
2704 |
" |
|
2705 |
! |
|
2706 |
||
5889
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2707 |
withAllDirectoriesDo:aBlock |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2708 |
"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
|
2709 |
The block is invoked with a filename-arguments. |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2710 |
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
|
2711 |
filenames (but by creation time - on some systems). |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2712 |
This excludes entries for '.' or '..'. |
17310 | 2713 |
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
|
2714 |
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
|
2715 |
|
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2716 |
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
|
2717 |
aBlock value:self. |
5889
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2718 |
]. |
17310 | 2719 |
self allDirectoriesDo:aBlock. |
5889
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2720 |
|
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2721 |
" |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2722 |
'.' asFilename withAllDirectoriesDo:[:fn | Transcript showCR:fn name]. |
17310 | 2723 |
'IdoNOTexist' asFilename withAllDirectoriesDo:[:fn | Transcript showCR:fn name]. |
2724 |
'/etc/hosts' asFilename withAllDirectoriesDo:[:fn | Transcript showCR:fn name]. |
|
5889
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2725 |
" |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2726 |
! ! |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2727 |
|
542 | 2728 |
!Filename methodsFor:'error handling'! |
2729 |
||
615 | 2730 |
accessDeniedError:filename |
1120
94c803be0210
compile errorMethods with +optSpace
Claus Gittinger <cg@exept.de>
parents:
1081
diff
changeset
|
2731 |
"{ Pragma: +optSpace }" |
94c803be0210
compile errorMethods with +optSpace
Claus Gittinger <cg@exept.de>
parents:
1081
diff
changeset
|
2732 |
|
94c803be0210
compile errorMethods with +optSpace
Claus Gittinger <cg@exept.de>
parents:
1081
diff
changeset
|
2733 |
"report an error that access to some file was denied" |
94c803be0210
compile errorMethods with +optSpace
Claus Gittinger <cg@exept.de>
parents:
1081
diff
changeset
|
2734 |
|
4820 | 2735 |
|errNo errString| |
2736 |
||
2737 |
errNo := OperatingSystem lastErrorNumber. |
|
2738 |
errString := OperatingSystem lastErrorString. |
|
2739 |
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
|
2740 |
errString := ''. |
4820 | 2741 |
] ifFalse:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2742 |
errString := ' (' , errString , ')' |
4820 | 2743 |
]. |
2744 |
||
615 | 2745 |
^ OperatingSystem accessDeniedErrorSignal |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2746 |
raiseRequestWith:filename ? self |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2747 |
errorString:(' : ' , (filename ? self) asString , errString) |
4820 | 2748 |
|
2749 |
"Modified: / 26.9.1999 / 16:11:44 / cg" |
|
615 | 2750 |
! |
2751 |
||
2752 |
fileCreationError:filename |
|
1120
94c803be0210
compile errorMethods with +optSpace
Claus Gittinger <cg@exept.de>
parents:
1081
diff
changeset
|
2753 |
"{ Pragma: +optSpace }" |
94c803be0210
compile errorMethods with +optSpace
Claus Gittinger <cg@exept.de>
parents:
1081
diff
changeset
|
2754 |
|
94c803be0210
compile errorMethods with +optSpace
Claus Gittinger <cg@exept.de>
parents:
1081
diff
changeset
|
2755 |
"report an error that some file could not be created" |
94c803be0210
compile errorMethods with +optSpace
Claus Gittinger <cg@exept.de>
parents:
1081
diff
changeset
|
2756 |
|
615 | 2757 |
^ OperatingSystem accessDeniedErrorSignal |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2758 |
raiseRequestWith:filename?self |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2759 |
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
|
2760 |
! |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2761 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2762 |
fileNotFoundError:filename |
1120
94c803be0210
compile errorMethods with +optSpace
Claus Gittinger <cg@exept.de>
parents:
1081
diff
changeset
|
2763 |
"{ Pragma: +optSpace }" |
94c803be0210
compile errorMethods with +optSpace
Claus Gittinger <cg@exept.de>
parents:
1081
diff
changeset
|
2764 |
|
94c803be0210
compile errorMethods with +optSpace
Claus Gittinger <cg@exept.de>
parents:
1081
diff
changeset
|
2765 |
"report an error that some file was not found" |
94c803be0210
compile errorMethods with +optSpace
Claus Gittinger <cg@exept.de>
parents:
1081
diff
changeset
|
2766 |
|
542 | 2767 |
^ OperatingSystem fileNotFoundErrorSignal |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2768 |
raiseRequestWith:filename?self |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2769 |
errorString:('file not found: ' , (filename ? self) asString) |
542 | 2770 |
! |
2771 |
||
2772 |
removeError:filename |
|
1120
94c803be0210
compile errorMethods with +optSpace
Claus Gittinger <cg@exept.de>
parents:
1081
diff
changeset
|
2773 |
"{ Pragma: +optSpace }" |
94c803be0210
compile errorMethods with +optSpace
Claus Gittinger <cg@exept.de>
parents:
1081
diff
changeset
|
2774 |
|
94c803be0210
compile errorMethods with +optSpace
Claus Gittinger <cg@exept.de>
parents:
1081
diff
changeset
|
2775 |
"report an error that some file could not be removed" |
94c803be0210
compile errorMethods with +optSpace
Claus Gittinger <cg@exept.de>
parents:
1081
diff
changeset
|
2776 |
|
542 | 2777 |
^ OperatingSystem accessDeniedErrorSignal |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2778 |
raiseRequestWith:filename?self |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2779 |
errorString:('cannot remove: ' , (filename?self) asString) |
615 | 2780 |
! |
2781 |
||
2782 |
reportError:string with:filename |
|
1120
94c803be0210
compile errorMethods with +optSpace
Claus Gittinger <cg@exept.de>
parents:
1081
diff
changeset
|
2783 |
"{ Pragma: +optSpace }" |
94c803be0210
compile errorMethods with +optSpace
Claus Gittinger <cg@exept.de>
parents:
1081
diff
changeset
|
2784 |
|
94c803be0210
compile errorMethods with +optSpace
Claus Gittinger <cg@exept.de>
parents:
1081
diff
changeset
|
2785 |
"report an error" |
94c803be0210
compile errorMethods with +optSpace
Claus Gittinger <cg@exept.de>
parents:
1081
diff
changeset
|
2786 |
|
15192 | 2787 |
^ OsError |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2788 |
raiseRequestWith:filename?self |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2789 |
errorString:string |
615 | 2790 |
! ! |
2791 |
||
2792 |
!Filename methodsFor:'file access'! |
|
2793 |
||
3015 | 2794 |
appendStream |
2795 |
"return a stream for appending to the file represented by the receiver. |
|
2796 |
If the file does not already exist, it is created. |
|
2797 |
Same as #appendingWriteStream for ST-80 compatibility." |
|
2798 |
||
2799 |
^ self appendingWriteStream |
|
2800 |
! |
|
2801 |
||
615 | 2802 |
appendingWriteStream |
2803 |
"return a stream for appending to the file represented by the receiver. |
|
5720 | 2804 |
If the file does not already exist, it is created; |
2805 |
if it does exist, writes are appended at the end." |
|
615 | 2806 |
|
2947 | 2807 |
^ FileStream appendingOldFileNamed:(self osNameForAccess) |
5720 | 2808 |
|
2809 |
" |
|
2810 |
|s| |
|
2811 |
||
2812 |
s := '/tmp/foo' asFilename writeStream. |
|
2813 |
s nextPutAll:'1234567890'. |
|
2814 |
s close. |
|
2815 |
||
2816 |
s := '/tmp/foo' asFilename appendingWriteStream. |
|
2817 |
s nextPutAll:'abcdef'. |
|
2818 |
s close. |
|
2819 |
||
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2820 |
'/tmp/foo' asFilename contents |
5720 | 2821 |
" |
615 | 2822 |
! |
2823 |
||
15490 | 2824 |
existingReadWriteStream |
2825 |
"return a stream for read/write the file represented by the receiver. |
|
2826 |
If the file does not already exist, an exception is raised." |
|
2827 |
||
2828 |
^ FileStream oldFileNamed:(self osNameForAccess) |
|
2829 |
||
2830 |
" |
|
2831 |
'/tmp/blaFaselQuall666666' asFilename remove. |
|
2832 |
'/tmp/blaFaselQuall666666' asFilename existingReadWriteStream. |
|
2833 |
" |
|
2834 |
" |
|
2835 |
|s| |
|
2836 |
s := '/tmp/foo' asFilename readWriteStream. |
|
2837 |
s nextPutAll:'1234567890'; close. |
|
2838 |
s := '/tmp/foo' asFilename existingReadWriteStream. |
|
2839 |
s nextPutAll:'abcdef'; close. |
|
2840 |
||
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2841 |
'/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
|
2842 |
'/tmp/foo' asFilename remove |
15490 | 2843 |
" |
2844 |
! |
|
2845 |
||
615 | 2846 |
newReadWriteStream |
2847 |
"return a stream for read/write the file represented by the receiver. |
|
5720 | 2848 |
If the file does not already exist, it is created; |
2849 |
if it does exist, it is truncated." |
|
615 | 2850 |
|
2947 | 2851 |
^ FileStream newFileNamed:(self osNameForAccess) |
5720 | 2852 |
|
2853 |
" |
|
2854 |
|s| |
|
2855 |
||
2856 |
s := '/tmp/foo' asFilename writeStream. |
|
2857 |
s nextPutAll:'1234567890'. |
|
2858 |
s close. |
|
2859 |
||
2860 |
s := '/tmp/foo' asFilename newReadWriteStream. |
|
2861 |
s nextPutAll:'12345'. |
|
2862 |
s close. |
|
2863 |
||
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2864 |
'/tmp/foo' asFilename contents |
5720 | 2865 |
" |
615 | 2866 |
! |
2867 |
||
15459 | 2868 |
openWithMode:anArrayOrString |
2869 |
"return a stream for read/write the file represented by the receiver. |
|
2870 |
If the file does not already exist, it is created; |
|
2871 |
if it does exist, it is truncated." |
|
2872 |
||
2873 |
^ FileStream open:self osNameForAccess withMode:anArrayOrString |
|
2874 |
||
2875 |
" |
|
2876 |
|s| |
|
2877 |
||
2878 |
s := '/tmp/foo' asFilename openWithMode:'r+'. |
|
2879 |
s nextPutAll:'1234567890'. |
|
2880 |
s close. |
|
2881 |
||
2882 |
||
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2883 |
'/tmp/foo' asFilename contents |
15459 | 2884 |
" |
2885 |
! |
|
2886 |
||
615 | 2887 |
readStream |
20156 | 2888 |
"Return a stream for reading from the file represented by the receiver. |
7828 | 2889 |
Raises an error if the file does not exist." |
615 | 2890 |
|
2947 | 2891 |
^ FileStream readonlyFileNamed:(self osNameForAccess) |
615 | 2892 |
|
2893 |
" |
|
20156 | 2894 |
'/tmp/foo' asFilename readStream |
615 | 2895 |
" |
2896 |
! |
|
2897 |
||
2898 |
readWriteStream |
|
2899 |
"return a stream for read/write the file represented by the receiver. |
|
7828 | 2900 |
If the file does not already exist, it is created. |
2901 |
If the file does exist, it is NOT truncated, but rewritten at the beginning." |
|
615 | 2902 |
|
7088
cc3233554827
Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents:
7075
diff
changeset
|
2903 |
^ FileStream fileNamed:(self osNameForAccess) |
5720 | 2904 |
|
2905 |
" |
|
2906 |
|s| |
|
2907 |
||
2908 |
s := '/tmp/foo' asFilename writeStream. |
|
2909 |
s nextPutAll:'1234567890'. |
|
2910 |
s close. |
|
2911 |
||
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2912 |
s := '/tmp/foo' asFilename readWriteStream. |
5720 | 2913 |
s nextPutAll:'abcdef'. |
2914 |
s close. |
|
2915 |
||
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2916 |
'/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
|
2917 |
'/tmp/foo' asFilename remove |
5720 | 2918 |
" |
615 | 2919 |
! |
2920 |
||
2921 |
writeStream |
|
2922 |
"return a stream for writing to the file represented by the receiver. |
|
5720 | 2923 |
If the file does not already exist, it is created; |
2924 |
if it does exist, it is truncated." |
|
615 | 2925 |
|
2947 | 2926 |
^ FileStream newFileForWritingNamed:(self osNameForAccess) |
615 | 2927 |
|
2928 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2929 |
'/tmp/foo' asFilename writeStream |
615 | 2930 |
" |
5720 | 2931 |
|
2932 |
" |
|
2933 |
|s| |
|
2934 |
||
2935 |
s := '/tmp/foo' asFilename writeStream. |
|
2936 |
s nextPutAll:'1234567890'. |
|
2937 |
s close. |
|
2938 |
||
2939 |
s := '/tmp/foo' asFilename writeStream. |
|
2940 |
s nextPutAll:'12345'. |
|
2941 |
s close. |
|
2942 |
||
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2943 |
'/tmp/foo' asFilename contents |
5720 | 2944 |
" |
615 | 2945 |
! ! |
2946 |
||
8140
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2947 |
!Filename methodsFor:'file access - migration'! |
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2948 |
|
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2949 |
appendingWriteStreamOrNil |
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2950 |
"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
|
2951 |
If the file does not already exist, it is created; |
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2952 |
if it does exist, writes are appended at the end. |
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2953 |
|
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2954 |
Return nil, if the file cannot be opened. |
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2955 |
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
|
2956 |
instead of an exception when an error occurs." |
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2957 |
|
8280
0caa2f092e45
avoid expensive full-blocks (which return)
Claus Gittinger <cg@exept.de>
parents:
8243
diff
changeset
|
2958 |
^ [ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2959 |
FileStream appendingOldFileNamed:(self osNameForAccess) |
8280
0caa2f092e45
avoid expensive full-blocks (which return)
Claus Gittinger <cg@exept.de>
parents:
8243
diff
changeset
|
2960 |
] on:FileStream openErrorSignal do:[:ex| nil]. |
8140
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2961 |
! |
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2962 |
|
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2963 |
newReadWriteStreamOrNil |
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2964 |
"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
|
2965 |
If the file does not already exist, it is created; |
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2966 |
if it does exist, it is truncated. |
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2967 |
|
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2968 |
Return nil, if the file cannot be opened. |
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2969 |
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
|
2970 |
instead of an exception when an error occurs." |
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2971 |
|
8280
0caa2f092e45
avoid expensive full-blocks (which return)
Claus Gittinger <cg@exept.de>
parents:
8243
diff
changeset
|
2972 |
^ [ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2973 |
FileStream newFileNamed:(self osNameForAccess) |
8280
0caa2f092e45
avoid expensive full-blocks (which return)
Claus Gittinger <cg@exept.de>
parents:
8243
diff
changeset
|
2974 |
] on:FileStream openErrorSignal do:[:ex|nil]. |
8140
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2975 |
! |
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2976 |
|
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2977 |
readStreamOrNil |
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2978 |
"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
|
2979 |
If the file does not already exist, nil is returned. |
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2980 |
|
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2981 |
Return nil, if the file cannot be opened. |
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2982 |
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
|
2983 |
instead of an exception when an error occurs." |
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2984 |
|
8280
0caa2f092e45
avoid expensive full-blocks (which return)
Claus Gittinger <cg@exept.de>
parents:
8243
diff
changeset
|
2985 |
^ [ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2986 |
FileStream readonlyFileNamed:(self osNameForAccess) |
8280
0caa2f092e45
avoid expensive full-blocks (which return)
Claus Gittinger <cg@exept.de>
parents:
8243
diff
changeset
|
2987 |
] on:FileStream openErrorSignal do:[:ex|nil]. |
8140
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2988 |
|
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2989 |
" |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2990 |
'/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
|
2991 |
'/tmp/foo' asFilename readStream |
8140
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2992 |
" |
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2993 |
! |
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2994 |
|
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2995 |
readWriteStreamOrNil |
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2996 |
"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
|
2997 |
If the file does not already exist, it is created. |
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2998 |
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
|
2999 |
|
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
3000 |
Return nil, if the file cannot be opened. |
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
3001 |
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
|
3002 |
instead of an exception when an error occurs." |
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
3003 |
|
8280
0caa2f092e45
avoid expensive full-blocks (which return)
Claus Gittinger <cg@exept.de>
parents:
8243
diff
changeset
|
3004 |
^ [ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3005 |
FileStream fileNamed:(self osNameForAccess) |
8280
0caa2f092e45
avoid expensive full-blocks (which return)
Claus Gittinger <cg@exept.de>
parents:
8243
diff
changeset
|
3006 |
] on:FileStream openErrorSignal do:[:ex|^ nil]. |
8140
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
3007 |
! |
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
3008 |
|
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
3009 |
writeStreamOrNil |
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
3010 |
"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
|
3011 |
If the file does not already exist, it is created; |
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
3012 |
if it does exist, it is truncated. |
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
3013 |
|
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
3014 |
Return nil, if the file cannot be opened. |
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
3015 |
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
|
3016 |
instead of an exception when an error occurs." |
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
3017 |
|
8280
0caa2f092e45
avoid expensive full-blocks (which return)
Claus Gittinger <cg@exept.de>
parents:
8243
diff
changeset
|
3018 |
^ [ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3019 |
FileStream newFileForWritingNamed:(self osNameForAccess) |
8280
0caa2f092e45
avoid expensive full-blocks (which return)
Claus Gittinger <cg@exept.de>
parents:
8243
diff
changeset
|
3020 |
] on:FileStream openErrorSignal do:[:ex|^ nil]. |
8140
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
3021 |
|
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
3022 |
|
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
3023 |
" |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3024 |
'/etc/foo' asFilename writeStreamOrNil |
8140
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
3025 |
" |
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
3026 |
! ! |
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
3027 |
|
16310 | 3028 |
!Filename methodsFor:'file access rights'! |
615 | 3029 |
|
12529 | 3030 |
accessRights |
3031 |
"return the access rights of the file as opaque data |
|
3032 |
(SmallInteger in unix/linux)" |
|
3033 |
||
3034 |
^ OperatingSystem accessModeOf:self osNameForFile. |
|
3035 |
||
3036 |
" |
|
3037 |
'Make.proto' asFilename accessRights |
|
3038 |
" |
|
3039 |
! |
|
3040 |
||
3041 |
accessRights:opaqueData |
|
3042 |
"set the access rights of the file to opaqueData, |
|
3043 |
which is normally retrieved by Filename>>#accessRights." |
|
3044 |
||
3045 |
(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
|
3046 |
^ self accessDeniedError:self |
12529 | 3047 |
]. |
3048 |
||
3049 |
" |
|
3050 |
|rights| |
|
3051 |
||
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3052 |
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
|
3053 |
'Make.proto' asFilename accessRights:rights. |
12529 | 3054 |
" |
3055 |
||
3056 |
"Modified: / 5.5.1999 / 13:41:21 / cg" |
|
3057 |
! |
|
3058 |
||
615 | 3059 |
addAccessRights:aCollection |
3060 |
"add the access rights as specified in aCollection for the file represented |
|
3061 |
by the receiver. The argument must be a collection of symbols, |
|
3062 |
such as #readUser, #writeGroup etc." |
|
3063 |
||
2922 | 3064 |
|access osName| |
3065 |
||
2947 | 3066 |
osName := self osNameForFile. |
2922 | 3067 |
access := OperatingSystem accessModeOf:osName. |
615 | 3068 |
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
|
3069 |
access := access bitOr:(OperatingSystem accessMaskFor:accessSymbol). |
615 | 3070 |
]. |
2922 | 3071 |
(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
|
3072 |
^ self accessDeniedError:self |
615 | 3073 |
] |
3074 |
||
3075 |
" |
|
3076 |
'foo' asFilename writeStream close. |
|
3077 |
'foo' asFilename addAccessRights:#(readUser readGroup readOthers). |
|
3078 |
'foo' asFilename addAccessRights:#(writeUser writeGroup writeOthers). |
|
3079 |
'foo' asFilename addAccessRights:#(executeUser executeGroup executeOthers). |
|
3080 |
" |
|
3081 |
! |
|
3082 |
||
6223 | 3083 |
makeExecutable |
3084 |
"make the file executable - you must have permission to do so. |
|
3085 |
For directories, execution means: 'allow changing into it'" |
|
3086 |
||
3087 |
^ self addAccessRights:#(executeUser) |
|
3088 |
||
3089 |
"Created: 9.1.1996 / 15:32:47 / cg" |
|
3090 |
! |
|
3091 |
||
3092 |
makeExecutableForAll |
|
3093 |
"make the file executable for all - you must have permission to do so. |
|
3094 |
For directories, execution means: 'allow changing into it'" |
|
3095 |
||
3096 |
^ self addAccessRights:#(executeUser executeGroup executeOthers) |
|
3097 |
||
3098 |
"Created: 9.1.1996 / 15:32:28 / cg" |
|
3099 |
! |
|
3100 |
||
3101 |
makeExecutableForGroup |
|
3102 |
"make the file executable for the group - you must have permission to do so. |
|
3103 |
For directories, execution means: 'allow changing into it'" |
|
3104 |
||
3105 |
^ self addAccessRights:#(executeGroup) |
|
3106 |
||
3107 |
"Created: 9.1.1996 / 15:32:28 / cg" |
|
3108 |
! |
|
3109 |
||
3110 |
makeReadable |
|
3111 |
"make the file readable for the owner - you must have permission to do so." |
|
3112 |
||
3113 |
^ self addAccessRights:#(readUser) |
|
3114 |
! |
|
3115 |
||
3116 |
makeReadableForAll |
|
3117 |
"make the file readable for all - you must have permission to do so." |
|
3118 |
||
3119 |
^ self addAccessRights:#(readUser readGroup readOthers) |
|
3120 |
! |
|
3121 |
||
3122 |
makeReadableForGroup |
|
3123 |
"make the file readable for the group - you must have permission to do so." |
|
3124 |
||
3125 |
^ self addAccessRights:#(readGroup) |
|
3126 |
! |
|
3127 |
||
3128 |
makeUnwritable |
|
3129 |
"make the file unwritable for all - you must have permission to do so." |
|
3130 |
||
3131 |
^ self removeAccessRights:#(writeUser writeGroup writeOthers) |
|
3132 |
! |
|
3133 |
||
3134 |
makeWritable |
|
3135 |
"make the file writableable for all - you must have permission to do so." |
|
3136 |
||
3137 |
^ self addAccessRights:#(writeUser) |
|
3138 |
! |
|
3139 |
||
3140 |
makeWritableForAll |
|
3141 |
"make the file writable for all - you must have permission to do so." |
|
3142 |
||
3143 |
^ self addAccessRights:#(writeUser writeGroup writeOthers) |
|
3144 |
! |
|
3145 |
||
3146 |
makeWritableForGroup |
|
3147 |
"make the file writable for the group - you must have permission to do so." |
|
3148 |
||
3149 |
^ self addAccessRights:#(writeGroup) |
|
3150 |
! |
|
3151 |
||
3152 |
removeAccessRights:aCollection |
|
3153 |
"remove the access rights as specified in aCollection for the file represented |
|
3154 |
by the receiver. The argument must be a collection of symbols, |
|
3155 |
such as #readUser, #writeGroup etc. |
|
3156 |
Raises an exception if not successful." |
|
3157 |
||
3158 |
|access osName| |
|
3159 |
||
3160 |
osName := self osNameForFile. |
|
3161 |
access := OperatingSystem accessModeOf:osName. |
|
3162 |
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
|
3163 |
access := access bitAnd:(OperatingSystem accessMaskFor:accessSymbol) bitInvert. |
6223 | 3164 |
]. |
3165 |
(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
|
3166 |
^ self accessDeniedError:self |
6223 | 3167 |
]. |
3168 |
||
3169 |
" |
|
3170 |
'foo' asFilename writeStream close. |
|
3171 |
'foo' asFilename removeAccessRights:#(readUser readGroup readOthers). |
|
3172 |
'foo' asFilename removeAccessRights:#(writeUser writeGroup writeOthers). |
|
3173 |
'foo' asFilename removeAccessRights:#(executeUser executeGroup executeOthers). |
|
3174 |
" |
|
3175 |
||
3176 |
"Modified: / 5.5.1999 / 13:41:21 / cg" |
|
3177 |
! |
|
3178 |
||
3179 |
symbolicAccessRights |
|
3180 |
"return the access rights of the file as a aCollection of access symbols. |
|
3181 |
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
|
3182 |
#readUser, #writeGroup etc." |
6223 | 3183 |
|
3184 |
|access osName| |
|
3185 |
||
3186 |
osName := self osNameForFile. |
|
3187 |
access := OperatingSystem accessModeOf:osName. |
|
3188 |
||
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3189 |
^ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3190 |
#( readUser writeUser executeUser |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3191 |
readGroup writeGroup executeGroup |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3192 |
readOthers writeOthers executeOthers |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3193 |
) select:[:eachSymbolicAccessSymbol | |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3194 |
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
|
3195 |
]. |
6223 | 3196 |
|
3197 |
" |
|
3198 |
'Makefile' asFilename symbolicAccessRights |
|
3199 |
" |
|
3200 |
||
3201 |
"Modified: / 5.5.1999 / 13:41:21 / cg" |
|
3202 |
! |
|
3203 |
||
3204 |
symbolicAccessRights:aCollectionOfSymbols |
|
3205 |
"set the access rights of the file given a aCollection of access symbols. |
|
3206 |
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
|
3207 |
#readUser, #writeGroup etc." |
6223 | 3208 |
|
3209 |
|access osName| |
|
3210 |
||
3211 |
osName := self osNameForFile. |
|
3212 |
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
|
3213 |
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
|
3214 |
]. |
6223 | 3215 |
|
3216 |
(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
|
3217 |
^ self accessDeniedError:self |
6223 | 3218 |
]. |
3219 |
||
3220 |
" |
|
3221 |
|rights| |
|
3222 |
||
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3223 |
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
|
3224 |
'Makefile' asFilename symbolicAccessRights:(rights , #(executeOthers)). |
6223 | 3225 |
" |
3226 |
||
3227 |
"Modified: / 5.5.1999 / 13:41:21 / cg" |
|
3228 |
! ! |
|
3229 |
||
3230 |
!Filename methodsFor:'file operations'! |
|
3231 |
||
7329 | 3232 |
appendTo:newNameOrStream |
3233 |
"append the file - the argument must be convertable to a filename. |
|
3234 |
Raises an exception, if an error occurs." |
|
3235 |
||
3236 |
|inStream outStream outStreamToClose| |
|
3237 |
||
3238 |
inStream := self readStream. |
|
3239 |
[ |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3240 |
newNameOrStream isStream ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3241 |
outStream := newNameOrStream. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3242 |
] ifFalse:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3243 |
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
|
3244 |
]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3245 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3246 |
inStream binary. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3247 |
outStream binary. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3248 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3249 |
[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3250 |
inStream copyToEndInto:outStream. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3251 |
] 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
|
3252 |
^ self fileCreationError:newNameOrStream |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3253 |
] |
7329 | 3254 |
] ensure:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3255 |
inStream close. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3256 |
outStreamToClose notNil ifTrue:[outStreamToClose close]. |
7329 | 3257 |
]. |
3258 |
||
3259 |
" |
|
3260 |
'/etc/group' asFilename appendTo:'/tmp/Makefile.foo'. |
|
3261 |
'Makefile' asFilename appendTo:'/tmp/Makefile.foo' |
|
3262 |
'Makefile' asFilename copyTo:'/' |
|
3263 |
'smalltalk' asFilename copyTo:'/dev/null' |
|
3264 |
" |
|
3265 |
||
3266 |
"Modified: / 23.12.1999 / 21:52:36 / cg" |
|
3267 |
! |
|
3268 |
||
2982 | 3269 |
basicMakeDirectory |
19440 | 3270 |
"create a directory with the receiver's name. |
2982 | 3271 |
Return true if successful, false if not." |
3272 |
||
3273 |
^ OperatingSystem createDirectory:(self osNameForDirectory) |
|
3274 |
! |
|
3275 |
||
10020 | 3276 |
copyTo:newNameArg |
16578 | 3277 |
"Copy the file's contents into another file. |
9235 | 3278 |
The argument must be convertable to a filename. |
4148
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3279 |
Raises an exception, if an error occurs." |
615 | 3280 |
|
12529 | 3281 |
|newName inStream outStream newNameAlreadyExists| |
10020 | 3282 |
|
3283 |
newName := newNameArg asFilename. |
|
6804
caf6a4521d4c
added utility: ExternalStream >> copyToEndInto:
Claus Gittinger <cg@exept.de>
parents:
6803
diff
changeset
|
3284 |
|
19957 | 3285 |
"Contents is not copied if newName represents the same file as me." |
10020 | 3286 |
newName asAbsoluteFilename = self asAbsoluteFilename ifTrue: [ ^ self ]. |
8535 | 3287 |
|
19957 | 3288 |
(newName exists and:[newName isDirectory]) ifTrue:[ |
3289 |
newName := newName construct:(self baseName). |
|
3290 |
]. |
|
3291 |
||
615 | 3292 |
inStream := self readStream. |
17143 | 3293 |
inStream isNil ifTrue:[ |
19957 | 3294 |
"open failed, but somenone did a proceed for the OpenError. |
3295 |
Ignore this file but continue in order to copy the rest when |
|
3296 |
doing a recursive copy" |
|
3297 |
^ self. |
|
17143 | 3298 |
]. |
3299 |
||
6804
caf6a4521d4c
added utility: ExternalStream >> copyToEndInto:
Claus Gittinger <cg@exept.de>
parents:
6803
diff
changeset
|
3300 |
[ |
19957 | 3301 |
newNameAlreadyExists := newName exists. |
3302 |
outStream := newName writeStream. |
|
3303 |
newNameAlreadyExists ifFalse:[ |
|
3304 |
[ |
|
3305 |
"would be nice to keep the access rights of the original test suite" |
|
3306 |
newName accessRights:self accessRights. |
|
3307 |
] on:OperatingSystem accessDeniedErrorSignal do:[:ex| |
|
20252 | 3308 |
"ignore the error - may occur when copying to a network drive" |
19957 | 3309 |
]. |
3310 |
]. |
|
3311 |
inStream binary; buffered:false. |
|
3312 |
outStream binary; buffered:false. |
|
3313 |
inStream copyToEndInto:outStream. |
|
6804
caf6a4521d4c
added utility: ExternalStream >> copyToEndInto:
Claus Gittinger <cg@exept.de>
parents:
6803
diff
changeset
|
3314 |
] ensure:[ |
19957 | 3315 |
inStream close. |
3316 |
outStream notNil ifTrue:[outStream close]. |
|
615 | 3317 |
]. |
3318 |
||
3319 |
" |
|
12529 | 3320 |
'Make.proto' asFilename copyTo:'/tmp/Makefile.foo' |
3321 |
'Make.proto' asFilename copyTo:'/' |
|
615 | 3322 |
'smalltalk' asFilename copyTo:'/dev/null' |
3323 |
" |
|
4148
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3324 |
|
10020 | 3325 |
"Modified: / 10-09-2004 / 09:49:28 / janfrog" |
19957 | 3326 |
"Modified: / 06-06-2016 / 12:15:25 / cg" |
615 | 3327 |
! |
3328 |
||
15465 | 3329 |
copyToStream:outStream |
16578 | 3330 |
"Copy the file's contents into another file. |
15465 | 3331 |
The argument must be convertable to a filename. |
3332 |
Raises an exception, if an error occurs." |
|
3333 |
||
15858 | 3334 |
|inStream resetBinary| |
15465 | 3335 |
|
3336 |
"Contents is not copied if newName represent same file as me." |
|
3337 |
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
|
3338 |
outStream fileName asAbsoluteFilename = self asAbsoluteFilename ifTrue: [ ^ self ]. |
15465 | 3339 |
]. |
3340 |
||
3341 |
inStream := self readStream. |
|
3342 |
[ |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3343 |
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
|
3344 |
resetBinary := false. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3345 |
outStream isBinary ifFalse:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3346 |
outStream binary. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3347 |
resetBinary := true. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3348 |
]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3349 |
inStream copyToEndInto:outStream. |
15465 | 3350 |
] ensure:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3351 |
inStream close. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3352 |
resetBinary ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3353 |
outStream text. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3354 |
]. |
15465 | 3355 |
]. |
3356 |
||
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3357 |
" |
15465 | 3358 |
|out| |
3359 |
out := FileStream newTemporary. |
|
3360 |
'Make.proto' asFilename copyToStream:out. |
|
3361 |
out reset; contents |
|
3362 |
" |
|
3363 |
! |
|
3364 |
||
6983 | 3365 |
createAsEmptyFile |
19440 | 3366 |
"create an empty file with the receiver's name. |
6983 | 3367 |
Raises an exception if not successful |
3368 |
(either already existing or creation not possible)" |
|
3369 |
||
3370 |
|writeStream| |
|
3371 |
||
3372 |
self exists ifTrue:[ |
|
19599 | 3373 |
OperatingSystem accessDeniedErrorSignal |
3374 |
raiseRequestWith:self |
|
3375 |
errorString:(' - file exists: ' , self asString). |
|
3376 |
^ self |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3377 |
]. |
6983 | 3378 |
|
3379 |
FileStream openErrorSignal handle:[:ex| |
|
19599 | 3380 |
self fileCreationError:self. |
3381 |
^ self |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3382 |
] do:[ |
19599 | 3383 |
writeStream := self newReadWriteStream. |
6983 | 3384 |
]. |
3385 |
writeStream close. |
|
3386 |
! |
|
3387 |
||
17143 | 3388 |
createAsSymbolicLinkTo:linkFilenameString |
19440 | 3389 |
"create a directory with the receiver's name. |
17143 | 3390 |
Raises an exception if not successful" |
3391 |
||
3392 |
OperatingSystem createSymbolicLinkFrom:linkFilenameString to:self pathName. |
|
3393 |
||
3394 |
" |
|
19599 | 3395 |
'/tmp/link' asFilename makeSymbolicLinkTo:'bla' |
17143 | 3396 |
" |
3397 |
! |
|
3398 |
||
615 | 3399 |
delete |
3400 |
"remove the file - same as remove, for ST-80 compatibility" |
|
3401 |
||
3402 |
self remove |
|
3403 |
! |
|
3404 |
||
3405 |
makeDirectory |
|
19440 | 3406 |
"create a directory with the receiver's name. |
4148
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3407 |
Raises an exception if not successful" |
615 | 3408 |
|
2982 | 3409 |
(self basicMakeDirectory) ifFalse:[ |
19599 | 3410 |
"/ |
3411 |
"/ could have existed before ... |
|
3412 |
"/ |
|
3413 |
(self exists and:[self isDirectory]) ifFalse:[ |
|
3414 |
self fileCreationError:self. |
|
3415 |
^ false |
|
3416 |
] |
|
2982 | 3417 |
]. |
3418 |
^ true |
|
1970 | 3419 |
|
4148
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3420 |
"Modified: / 5.5.1999 / 13:36:33 / cg" |
615 | 3421 |
! |
3422 |
||
6996
720a54a2a358
move now also supports recursive directory moves
Claus Gittinger <cg@exept.de>
parents:
6995
diff
changeset
|
3423 |
moveFileTo:newName |
720a54a2a358
move now also supports recursive directory moves
Claus Gittinger <cg@exept.de>
parents:
6995
diff
changeset
|
3424 |
"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
|
3425 |
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
|
3426 |
Raise an exception if not successful. |
720a54a2a358
move now also supports recursive directory moves
Claus Gittinger <cg@exept.de>
parents:
6995
diff
changeset
|
3427 |
(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
|
3428 |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3429 |
[self renameTo:newName] |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3430 |
on:OsError |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3431 |
do:[:ex | |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3432 |
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
|
3433 |
ex reject |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3434 |
]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3435 |
self safeCopyTo:newName. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3436 |
self remove |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3437 |
]. |
6996
720a54a2a358
move now also supports recursive directory moves
Claus Gittinger <cg@exept.de>
parents:
6995
diff
changeset
|
3438 |
|
720a54a2a358
move now also supports recursive directory moves
Claus Gittinger <cg@exept.de>
parents:
6995
diff
changeset
|
3439 |
" |
720a54a2a358
move now also supports recursive directory moves
Claus Gittinger <cg@exept.de>
parents:
6995
diff
changeset
|
3440 |
|f s| |
720a54a2a358
move now also supports recursive directory moves
Claus Gittinger <cg@exept.de>
parents:
6995
diff
changeset
|
3441 |
|
720a54a2a358
move now also supports recursive directory moves
Claus Gittinger <cg@exept.de>
parents:
6995
diff
changeset
|
3442 |
f := '/tmp/foo' asFilename. |
720a54a2a358
move now also supports recursive directory moves
Claus Gittinger <cg@exept.de>
parents:
6995
diff
changeset
|
3443 |
s := f writeStream. |
720a54a2a358
move now also supports recursive directory moves
Claus Gittinger <cg@exept.de>
parents:
6995
diff
changeset
|
3444 |
s nextPutLine:'hello'. |
720a54a2a358
move now also supports recursive directory moves
Claus Gittinger <cg@exept.de>
parents:
6995
diff
changeset
|
3445 |
s close. |
720a54a2a358
move now also supports recursive directory moves
Claus Gittinger <cg@exept.de>
parents:
6995
diff
changeset
|
3446 |
f renameTo:'./foo' |
720a54a2a358
move now also supports recursive directory moves
Claus Gittinger <cg@exept.de>
parents:
6995
diff
changeset
|
3447 |
" |
720a54a2a358
move now also supports recursive directory moves
Claus Gittinger <cg@exept.de>
parents:
6995
diff
changeset
|
3448 |
|
720a54a2a358
move now also supports recursive directory moves
Claus Gittinger <cg@exept.de>
parents:
6995
diff
changeset
|
3449 |
" |
720a54a2a358
move now also supports recursive directory moves
Claus Gittinger <cg@exept.de>
parents:
6995
diff
changeset
|
3450 |
|f s| |
720a54a2a358
move now also supports recursive directory moves
Claus Gittinger <cg@exept.de>
parents:
6995
diff
changeset
|
3451 |
|
720a54a2a358
move now also supports recursive directory moves
Claus Gittinger <cg@exept.de>
parents:
6995
diff
changeset
|
3452 |
f := '/tmp/foo' asFilename. |
720a54a2a358
move now also supports recursive directory moves
Claus Gittinger <cg@exept.de>
parents:
6995
diff
changeset
|
3453 |
s := f writeStream. |
720a54a2a358
move now also supports recursive directory moves
Claus Gittinger <cg@exept.de>
parents:
6995
diff
changeset
|
3454 |
s nextPutLine:'hello'. |
720a54a2a358
move now also supports recursive directory moves
Claus Gittinger <cg@exept.de>
parents:
6995
diff
changeset
|
3455 |
s close. |
720a54a2a358
move now also supports recursive directory moves
Claus Gittinger <cg@exept.de>
parents:
6995
diff
changeset
|
3456 |
f moveTo:'./foo' |
720a54a2a358
move now also supports recursive directory moves
Claus Gittinger <cg@exept.de>
parents:
6995
diff
changeset
|
3457 |
" |
720a54a2a358
move now also supports recursive directory moves
Claus Gittinger <cg@exept.de>
parents:
6995
diff
changeset
|
3458 |
! |
720a54a2a358
move now also supports recursive directory moves
Claus Gittinger <cg@exept.de>
parents:
6995
diff
changeset
|
3459 |
|
16490 | 3460 |
moveTo:newNameArg |
615 | 3461 |
"copy the file represented by the receiver, then delete it. |
3462 |
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
|
3463 |
Raise an exception if not successful. |
3d801043be3f
dont read the whole directory in #directoryContentsDo:
Claus Gittinger <cg@exept.de>
parents:
5577
diff
changeset
|
3464 |
(Notice, that a rename is tried first, in case of non-cross device move)" |
615 | 3465 |
|
16490 | 3466 |
|newName| |
3467 |
||
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3468 |
newName := newNameArg asFilename. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3469 |
[self renameTo:newName] |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3470 |
on:(OSErrorHolder inappropriateReferentSignal) |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3471 |
do:[:ex | |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3472 |
"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
|
3473 |
self isDirectory ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3474 |
self recursiveMoveDirectoryTo:newName. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3475 |
] ifFalse:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3476 |
self safeCopyTo:newName. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3477 |
self remove. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3478 |
]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3479 |
]. |
5507
e8c61b1741c6
in #moveTo: - try a link first, then do a copy-remove.
Claus Gittinger <cg@exept.de>
parents:
5303
diff
changeset
|
3480 |
|
e8c61b1741c6
in #moveTo: - try a link first, then do a copy-remove.
Claus Gittinger <cg@exept.de>
parents:
5303
diff
changeset
|
3481 |
" |
e8c61b1741c6
in #moveTo: - try a link first, then do a copy-remove.
Claus Gittinger <cg@exept.de>
parents:
5303
diff
changeset
|
3482 |
|f s| |
e8c61b1741c6
in #moveTo: - try a link first, then do a copy-remove.
Claus Gittinger <cg@exept.de>
parents:
5303
diff
changeset
|
3483 |
|
e8c61b1741c6
in #moveTo: - try a link first, then do a copy-remove.
Claus Gittinger <cg@exept.de>
parents:
5303
diff
changeset
|
3484 |
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
|
3485 |
s := f writeStream. |
e8c61b1741c6
in #moveTo: - try a link first, then do a copy-remove.
Claus Gittinger <cg@exept.de>
parents:
5303
diff
changeset
|
3486 |
s nextPutLine:'hello'. |
e8c61b1741c6
in #moveTo: - try a link first, then do a copy-remove.
Claus Gittinger <cg@exept.de>
parents:
5303
diff
changeset
|
3487 |
s close. |
e8c61b1741c6
in #moveTo: - try a link first, then do a copy-remove.
Claus Gittinger <cg@exept.de>
parents:
5303
diff
changeset
|
3488 |
f renameTo:'./foo' |
e8c61b1741c6
in #moveTo: - try a link first, then do a copy-remove.
Claus Gittinger <cg@exept.de>
parents:
5303
diff
changeset
|
3489 |
" |
e8c61b1741c6
in #moveTo: - try a link first, then do a copy-remove.
Claus Gittinger <cg@exept.de>
parents:
5303
diff
changeset
|
3490 |
|
e8c61b1741c6
in #moveTo: - try a link first, then do a copy-remove.
Claus Gittinger <cg@exept.de>
parents:
5303
diff
changeset
|
3491 |
" |
e8c61b1741c6
in #moveTo: - try a link first, then do a copy-remove.
Claus Gittinger <cg@exept.de>
parents:
5303
diff
changeset
|
3492 |
|f s| |
e8c61b1741c6
in #moveTo: - try a link first, then do a copy-remove.
Claus Gittinger <cg@exept.de>
parents:
5303
diff
changeset
|
3493 |
|
e8c61b1741c6
in #moveTo: - try a link first, then do a copy-remove.
Claus Gittinger <cg@exept.de>
parents:
5303
diff
changeset
|
3494 |
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
|
3495 |
s := f writeStream. |
e8c61b1741c6
in #moveTo: - try a link first, then do a copy-remove.
Claus Gittinger <cg@exept.de>
parents:
5303
diff
changeset
|
3496 |
s nextPutLine:'hello'. |
e8c61b1741c6
in #moveTo: - try a link first, then do a copy-remove.
Claus Gittinger <cg@exept.de>
parents:
5303
diff
changeset
|
3497 |
s close. |
e8c61b1741c6
in #moveTo: - try a link first, then do a copy-remove.
Claus Gittinger <cg@exept.de>
parents:
5303
diff
changeset
|
3498 |
f moveTo:'./foo' |
e8c61b1741c6
in #moveTo: - try a link first, then do a copy-remove.
Claus Gittinger <cg@exept.de>
parents:
5303
diff
changeset
|
3499 |
" |
4148
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3500 |
! |
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3501 |
|
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3502 |
recursiveCopyTo:destination |
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3503 |
"if I represent a regular file, copy it. |
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3504 |
Otherwise, copy the directory and recursively |
12975 | 3505 |
all of its subfiles/subdirectories. |
17143 | 3506 |
|
3507 |
Raises an exception if not successful. |
|
3508 |
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
|
3509 |
If a whole directory is to be copied and the destination directory |
17143 | 3510 |
does not exist, it will be created." |
3511 |
||
3512 |
|ok destinationFilename| |
|
3513 |
||
3514 |
destinationFilename := destination asFilename. |
|
4148
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3515 |
self isDirectory ifFalse:[ |
19599 | 3516 |
destinationFilename isDirectory ifTrue:[ |
3517 |
destinationFilename := destinationFilename construct:self baseName. |
|
3518 |
]. |
|
3519 |
self copyTo:destinationFilename. |
|
3520 |
^ self. |
|
4148
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3521 |
]. |
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3522 |
|
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3523 |
"/ typically, an 'cp -r' is faster; |
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3524 |
"/ 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
|
3525 |
"/ fallBack doing a manual directory walk. |
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3526 |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3527 |
ok := OperatingSystem |
19599 | 3528 |
recursiveCopyDirectory:(self osNameForDirectory) |
3529 |
to:(destinationFilename osNameForDirectory). |
|
4148
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3530 |
|
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3531 |
ok ifFalse:[ |
19599 | 3532 |
self recursiveCopyWithoutOSCommandTo:destinationFilename |
3533 |
]. |
|
3534 |
||
3535 |
" |
|
3536 |
'.' asFilename recursiveCopyTo:'/temp/xxx'. |
|
17143 | 3537 |
" |
3538 |
||
12975 | 3539 |
"Created: / 05-05-1999 / 13:35:01 / cg" |
3540 |
"Modified: / 31-05-1999 / 13:11:34 / cg" |
|
3541 |
"Modified: / 29-07-2010 / 12:41:06 / sr" |
|
4148
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3542 |
! |
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3543 |
|
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3544 |
recursiveCopyWithoutOSCommandTo:destination |
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3545 |
"if I represent a regular file, copy it. |
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3546 |
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
|
3547 |
This one walks down the directory hierarchy, not using any OS command to do the copy. |
17143 | 3548 |
Raises an exception if not successful. |
3549 |
||
3550 |
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
|
3551 |
If a whole directory is to be copied and the destination directory |
17143 | 3552 |
does not exist, it will be created." |
4148
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3553 |
|
12529 | 3554 |
|destinationFilename| |
3555 |
||
3556 |
destinationFilename := destination asFilename. |
|
4148
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3557 |
|
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3558 |
self isDirectory ifTrue:[ |
19599 | 3559 |
destinationFilename exists ifFalse:[ |
3560 |
destinationFilename makeDirectory. |
|
3561 |
destinationFilename accessRights:self accessRights. |
|
3562 |
]. |
|
3563 |
||
3564 |
self directoryContentsDo:[:aFilenameString | |
|
3565 |
|src srcInfo dst info| |
|
3566 |
||
3567 |
src := self construct:aFilenameString. |
|
3568 |
dst := destinationFilename construct:aFilenameString. |
|
3569 |
||
3570 |
srcInfo := src linkInfo. |
|
3571 |
srcInfo isDirectory ifTrue:[ |
|
3572 |
src recursiveCopyWithoutOSCommandTo:dst |
|
3573 |
] ifFalse:[srcInfo isSymbolicLink ifTrue:[ |
|
3574 |
dst |
|
3575 |
remove; |
|
3576 |
createAsSymbolicLinkTo:src linkInfo path. |
|
3577 |
] ifFalse:[ |
|
3578 |
src copyTo:dst. |
|
3579 |
]]. |
|
3580 |
]. |
|
4148
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3581 |
] ifFalse:[ |
19599 | 3582 |
destinationFilename isDirectory ifTrue:[ |
3583 |
destinationFilename := destinationFilename construct:self baseName. |
|
3584 |
]. |
|
3585 |
self copyTo:destinationFilename. |
|
4148
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3586 |
] |
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3587 |
|
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3588 |
" |
18952 | 3589 |
'.' asFilename recursiveCopyWithoutOSCommandTo:'/temp/xxx'. |
4148
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3590 |
'smalltalk.rc' asFilename recursiveCopyWithoutOSCommandTo:'/tmp/xxx'. |
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3591 |
" |
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3592 |
|
4246 | 3593 |
"Modified: / 31.5.1999 / 18:12:31 / cg" |
615 | 3594 |
! |
3595 |
||
659 | 3596 |
recursiveMakeDirectory |
18490 | 3597 |
"create a directory with the receiver's name and all required intermediate |
659 | 3598 |
directories. |
4148
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3599 |
Raises an exception if not successful." |
659 | 3600 |
|
2922 | 3601 |
(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
|
3602 |
^ self fileCreationError:self |
659 | 3603 |
] |
3604 |
||
4148
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3605 |
"Created: / 27.11.1995 / 23:36:40 / cg" |
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3606 |
"Modified: / 5.5.1999 / 13:38:42 / cg" |
659 | 3607 |
! |
3608 |
||
6997 | 3609 |
recursiveMoveDirectoryTo:newName |
3610 |
"recursively copy the directory represented by the receiver, then delete it. |
|
3611 |
This is different to renaming in case of cross device moves. |
|
3612 |
Raise an exception if not successful. |
|
3613 |
(Notice, that a rename is tried first, in case of non-cross device move)" |
|
3614 |
||
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3615 |
[self renameTo:newName] |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3616 |
on:OsError |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3617 |
do:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3618 |
self recursiveCopyTo:newName. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3619 |
self recursiveRemove |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3620 |
]. |
6997 | 3621 |
! |
3622 |
||
615 | 3623 |
recursiveRemove |
3299
5abe74e42d94
recursiveRemove is now done without OS support.
Claus Gittinger <cg@exept.de>
parents:
3171
diff
changeset
|
3624 |
"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
|
3625 |
Otherwise, remove the directory and all of its subfiles/subdirectories. |
4148
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3626 |
Raise an exception if not successful." |
615 | 3627 |
|
3628 |
|ok| |
|
3629 |
||
3302 | 3630 |
"/ 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
|
3631 |
"/ 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
|
3632 |
"/ fallBack doing a manual directory walk. |
3302 | 3633 |
|
3634 |
ok := OperatingSystem recursiveRemoveDirectory:(self osNameForDirectory). |
|
3635 |
ok ifFalse:[ |
|
19599 | 3636 |
self recursiveRemoveWithoutOSCommand |
18952 | 3637 |
]. |
3638 |
||
3639 |
" |
|
3640 |
'foo/bar' asFilename recursiveMakeDirectory. |
|
3641 |
'foo' asFilename remove. |
|
3642 |
self assert:('foo' asFilename exists not). |
|
3643 |
||
3644 |
||
3645 |
'foo' asFilename recursiveRemove. |
|
3646 |
'foo/bar' asFilename recursiveMakeDirectory. |
|
3647 |
'foo' asFilename recursiveRemove. |
|
3648 |
self assert:('foo' asFilename exists not). |
|
3302 | 3649 |
" |
3650 |
||
3651 |
"Created: / 14.11.1995 / 11:19:29 / cg" |
|
4148
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3652 |
"Modified: / 5.5.1999 / 13:43:35 / cg" |
3302 | 3653 |
! |
3654 |
||
13246 | 3655 |
recursiveRemoveAll |
13247
9e47a0e73ba4
comment/format in: #recursiveRemoveAll
Claus Gittinger <cg@exept.de>
parents:
13246
diff
changeset
|
3656 |
"Remove all of my subfiles/subdirectories. |
3302 | 3657 |
Raise an error if not successful. |
3658 |
This one walks down the directory hierarchy, not using any OS |
|
3659 |
command to do the remove." |
|
3299
5abe74e42d94
recursiveRemove is now done without OS support.
Claus Gittinger <cg@exept.de>
parents:
3171
diff
changeset
|
3660 |
|
18952 | 3661 |
|removeFailedError| |
4939 | 3662 |
|
3299
5abe74e42d94
recursiveRemove is now done without OS support.
Claus Gittinger <cg@exept.de>
parents:
3171
diff
changeset
|
3663 |
self isDirectory ifTrue:[ |
19599 | 3664 |
removeFailedError := OperatingSystem accessDeniedErrorSignal. |
3665 |
self directoryContentsAsFilenamesDo:[:eachFilename | |
|
3666 |
removeFailedError handle:[:ex | |
|
3667 |
eachFilename isDirectory ifFalse:[ ex reject ]. |
|
3668 |
eachFilename |
|
3669 |
recursiveRemoveAll; |
|
3670 |
removeDirectory. |
|
3671 |
] do:[ |
|
3672 |
eachFilename remove |
|
3673 |
]. |
|
18952 | 3674 |
|
3675 |
"/ eachFilename isDirectory ifTrue:[ |
|
3676 |
"/ eachFilename recursiveRemoveWithoutOSCommand |
|
3677 |
"/ ] ifFalse:[ |
|
3678 |
"/ eachFilename remove |
|
3679 |
"/ ]. |
|
19599 | 3680 |
] |
615 | 3681 |
]. |
13246 | 3682 |
|
3683 |
" |
|
3684 |
'foo' asFilename makeDirectory. |
|
3685 |
'foo/bar' asFilename writeStream close. |
|
3686 |
'foo' asFilename remove |
|
3687 |
" |
|
3688 |
" |
|
3689 |
'foo' asFilename makeDirectory. |
|
3690 |
'foo/bar' asFilename writeStream close. |
|
18952 | 3691 |
'foo' asFilename recursiveRemove. |
3692 |
self assert:('foo' asFilename exists not). |
|
13246 | 3693 |
" |
3694 |
||
3695 |
"Created: / 25-01-2011 / 16:42:15 / cg" |
|
3696 |
! |
|
3697 |
||
3698 |
recursiveRemoveWithoutOSCommand |
|
3699 |
"if I represent a regular file, remove it. |
|
3700 |
Otherwise, remove the directory and all of its subfiles/subdirectories. |
|
3701 |
Raise an error if not successful. |
|
3702 |
This one walks down the directory hierarchy, not using any OS |
|
3703 |
command to do the remove." |
|
3704 |
||
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3705 |
self |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3706 |
recursiveRemoveAll; |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3707 |
remove. |
615 | 3708 |
|
3709 |
" |
|
3710 |
'foo' asFilename makeDirectory. |
|
3711 |
'foo/bar' asFilename writeStream close. |
|
4940 | 3712 |
'foo' asFilename remove |
615 | 3713 |
" |
3714 |
" |
|
3715 |
'foo' asFilename makeDirectory. |
|
3716 |
'foo/bar' asFilename writeStream close. |
|
4940 | 3717 |
'foo' asFilename recursiveRemove |
615 | 3718 |
" |
3719 |
||
13246 | 3720 |
"Created: / 25-02-1998 / 19:50:40 / cg" |
13949 | 3721 |
"Modified: / 19-01-2012 / 17:18:28 / cg" |
615 | 3722 |
! |
3723 |
||
3724 |
remove |
|
845 | 3725 |
"remove the file/directory. |
4148
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3726 |
Raises an exception if not successful. |
845 | 3727 |
Use #recursiveRemove in order to (recursively) remove non empty directories." |
615 | 3728 |
|
8741 | 3729 |
|linkInfo osName ok| |
3730 |
||
18952 | 3731 |
osName := self osNameForAccess. |
3732 |
ok := OperatingSystem removeFile:osName. |
|
3733 |
ok ifFalse:[ |
|
19599 | 3734 |
linkInfo := self linkInfo. |
3735 |
linkInfo isNil ifTrue:[ |
|
3736 |
"file does not exist - no error" |
|
3737 |
^ self. |
|
3738 |
] ifFalse:[linkInfo isDirectory ifTrue:[ |
|
3739 |
ok := OperatingSystem removeDirectory:osName |
|
3740 |
]]. |
|
3741 |
ok ifFalse:[ |
|
3742 |
self exists ifTrue:[ |
|
3743 |
self removeError:self pathName |
|
3744 |
] |
|
3745 |
] |
|
615 | 3746 |
]. |
3747 |
||
3748 |
" |
|
3749 |
(FileStream newFileNamed:'foo') close. |
|
3750 |
'foo' asFilename remove |
|
3751 |
" |
|
3752 |
||
3753 |
" |
|
3754 |
'foo' asFilename makeDirectory. |
|
3755 |
'foo/bar' asFilename writeStream close. |
|
8738 | 3756 |
'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
|
3757 |
'foo' asFilename recursiveRemove. |
615 | 3758 |
" |
3759 |
||
13793
3f1c660956ce
added: #new_recursiveRemoveAll
Claus Gittinger <cg@exept.de>
parents:
13781
diff
changeset
|
3760 |
"Modified: / 20-11-1997 / 17:40:22 / stefan" |
3f1c660956ce
added: #new_recursiveRemoveAll
Claus Gittinger <cg@exept.de>
parents:
13781
diff
changeset
|
3761 |
"Modified: / 11-10-2011 / 10:20:01 / cg" |
615 | 3762 |
! |
3763 |
||
5595
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3764 |
removeDirectory |
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3765 |
"remove the directory. |
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3766 |
Raises an exception if not successful (or if its not a directory). |
5596 | 3767 |
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
|
3768 |
Use #recursiveRemove in order to (recursively) remove non empty directories." |
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3769 |
|
18952 | 3770 |
(OperatingSystem removeDirectory:(self osNameForAccess)) ifFalse:[ |
19599 | 3771 |
self exists ifFalse:[ ^ self]. |
3772 |
self removeError:self |
|
5595
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3773 |
]. |
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3774 |
|
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3775 |
" |
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3776 |
(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
|
3777 |
'foo' asFilename removeDirectory |
5595
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3778 |
" |
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3779 |
|
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3780 |
" |
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3781 |
'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
|
3782 |
'foo' asFilename removeDirectory |
5595
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3783 |
" |
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3784 |
|
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3785 |
" |
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3786 |
'foo' asFilename makeDirectory. |
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3787 |
'foo/bar' asFilename writeStream close. |
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3788 |
('foo' asFilename remove) ifFalse:[ |
19599 | 3789 |
Transcript showCR:'could not remove foo' |
5595
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3790 |
] |
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3791 |
" |
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3792 |
|
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3793 |
"Modified: / 20.11.1997 / 17:40:22 / stefan" |
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3794 |
"Modified: / 5.5.1999 / 13:41:12 / cg" |
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3795 |
! |
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3796 |
|
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3797 |
removeFile |
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3798 |
"remove the file. |
5596 | 3799 |
Raises an exception if not successful (or if its not a file). |
3800 |
Use #remove if it is not known if the receiver is a directory or file. |
|
3801 |
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
|
3802 |
|
18952 | 3803 |
(OperatingSystem removeFile:self osNameForAccess) ifFalse:[ |
19599 | 3804 |
self exists ifTrue:[ |
3805 |
self removeError:self |
|
3806 |
]. |
|
5595
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3807 |
]. |
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3808 |
|
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3809 |
" |
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3810 |
(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
|
3811 |
'foo' asFilename removeFile |
5595
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3812 |
" |
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3813 |
|
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3814 |
" |
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3815 |
'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
|
3816 |
'foo' asFilename removeFile |
5595
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3817 |
" |
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3818 |
! |
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3819 |
|
16490 | 3820 |
renameTo:newNameArg |
671 | 3821 |
"rename the file - the argument must be convertable to a String. |
15823 | 3822 |
Raises an exception if not successful. |
3823 |
If newName already exists, it will be replaced by myself." |
|
615 | 3824 |
|
16490 | 3825 |
|errno newName| |
3826 |
||
3827 |
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
|
3828 |
(OperatingSystem |
21023 | 3829 |
renameFile:(self osNameForFile) |
3830 |
to:(newName osNameForFile) |
|
2922 | 3831 |
) ifFalse:[ |
21023 | 3832 |
errno := OperatingSystem lastErrorNumber. |
3833 |
||
3834 |
self exists ifFalse:[ |
|
3835 |
^ self fileNotFoundError:self |
|
3836 |
]. |
|
3837 |
(OperatingSystem errorHolderForNumber:errno) |
|
3838 |
parameter:newName; |
|
3839 |
reportError. |
|
615 | 3840 |
]. |
3841 |
||
3842 |
" |
|
3843 |
'/tmp/foo' asFilename renameTo:'/tmp/bar' |
|
21023 | 3844 |
'C:\windows' asFilename renameTo:'C:\win' |
615 | 3845 |
" |
4148
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3846 |
|
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3847 |
"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
|
3848 |
! |
f57ec42ceb44
added interface to truncate & ftruncate (req. by Mr. Olberding)
Claus Gittinger <cg@exept.de>
parents:
883
diff
changeset
|
3849 |
|
15819 | 3850 |
safeCopyTo:newNameArg |
16578 | 3851 |
"Copy the file's contents into another file. |
15819 | 3852 |
Do it safe in an atomic operation shich makes sure that no partially written file appears. |
3853 |
The argument must be convertable to a filename. |
|
3854 |
Raises an exception, if an error occurs." |
|
3855 |
||
15823 | 3856 |
|newName inStream accessRights tempStream| |
15819 | 3857 |
|
3858 |
newName := newNameArg asFilename. |
|
3859 |
||
3860 |
"Contents is not copied if newName represent same file as me." |
|
3861 |
newName asAbsoluteFilename = self asAbsoluteFilename ifTrue: [ ^ self ]. |
|
3862 |
||
3863 |
inStream := self readStream. |
|
15823 | 3864 |
newName exists ifTrue:[ |
20252 | 3865 |
accessRights := newName accessRights. |
15819 | 3866 |
] ifFalse:[ |
20252 | 3867 |
accessRights := self accessRights. |
15819 | 3868 |
]. |
3869 |
||
3870 |
[ |
|
20252 | 3871 |
"let the temp filename start with a ~ to make it invisible" |
3872 |
tempStream := FileStream newTemporaryIn:newName directory osNameForFile nameTemplate:'~%1_%2'. |
|
3873 |
[ |
|
3874 |
"would be nice to keep the access rights of the original file" |
|
3875 |
tempStream fileName accessRights:accessRights. |
|
3876 |
] on:OperatingSystem accessDeniedErrorSignal do:[:ex| |
|
3877 |
"ignore the error - may occur when copying to a network drive" |
|
3878 |
]. |
|
3879 |
||
3880 |
inStream binary; buffered:false. |
|
3881 |
tempStream binary; buffered:false. |
|
3882 |
[ |
|
3883 |
inStream copyToEndInto:tempStream. |
|
3884 |
] ifCurtailed:[ |
|
3885 |
tempStream close. |
|
3886 |
tempStream fileName remove. |
|
3887 |
tempStream := nil. |
|
3888 |
]. |
|
3889 |
tempStream syncData. |
|
15819 | 3890 |
] ensure:[ |
20252 | 3891 |
inStream close. |
3892 |
tempStream notNil ifTrue:[tempStream close]. |
|
15819 | 3893 |
]. |
3894 |
tempStream fileName renameTo:newName. |
|
3895 |
||
3896 |
" |
|
3897 |
'Make.proto' asFilename safeCopyTo:'/tmp/Makefile.foo' |
|
3898 |
'Make.proto' asFilename safeCopyTo:'/' |
|
3899 |
'smalltalk' asFilename safeCopyTo:'/xxxxxxxxxxxxxxxx/bla' |
|
3900 |
" |
|
3901 |
||
3902 |
"Modified: / 10-09-2004 / 09:49:28 / janfrog" |
|
3903 |
"Modified: / 29-09-2006 / 16:26:32 / cg" |
|
3904 |
! |
|
3905 |
||
932
f57ec42ceb44
added interface to truncate & ftruncate (req. by Mr. Olberding)
Claus Gittinger <cg@exept.de>
parents:
883
diff
changeset
|
3906 |
truncateTo:newSize |
16578 | 3907 |
"change the file's size. |
4148
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3908 |
This may not be supported on all operating systems |
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3909 |
(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
|
3910 |
|
7888
e76fa60251dc
Remove obsolete nil-checks after opening streams
Stefan Vogel <sv@exept.de>
parents:
7846
diff
changeset
|
3911 |
(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
|
3912 |
^ 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
|
3913 |
] |
f57ec42ceb44
added interface to truncate & ftruncate (req. by Mr. Olberding)
Claus Gittinger <cg@exept.de>
parents:
883
diff
changeset
|
3914 |
|
f57ec42ceb44
added interface to truncate & ftruncate (req. by Mr. Olberding)
Claus Gittinger <cg@exept.de>
parents:
883
diff
changeset
|
3915 |
" |
f57ec42ceb44
added interface to truncate & ftruncate (req. by Mr. Olberding)
Claus Gittinger <cg@exept.de>
parents:
883
diff
changeset
|
3916 |
|s| |
f57ec42ceb44
added interface to truncate & ftruncate (req. by Mr. Olberding)
Claus Gittinger <cg@exept.de>
parents:
883
diff
changeset
|
3917 |
|
f57ec42ceb44
added interface to truncate & ftruncate (req. by Mr. Olberding)
Claus Gittinger <cg@exept.de>
parents:
883
diff
changeset
|
3918 |
s := 'test' asFilename writeStream. |
f57ec42ceb44
added interface to truncate & ftruncate (req. by Mr. Olberding)
Claus Gittinger <cg@exept.de>
parents:
883
diff
changeset
|
3919 |
s next:1000 put:$1. |
f57ec42ceb44
added interface to truncate & ftruncate (req. by Mr. Olberding)
Claus Gittinger <cg@exept.de>
parents:
883
diff
changeset
|
3920 |
s close. |
7888
e76fa60251dc
Remove obsolete nil-checks after opening streams
Stefan Vogel <sv@exept.de>
parents:
7846
diff
changeset
|
3921 |
('test' asFilename fileSize) printCR. |
932
f57ec42ceb44
added interface to truncate & ftruncate (req. by Mr. Olberding)
Claus Gittinger <cg@exept.de>
parents:
883
diff
changeset
|
3922 |
'test' asFilename truncateTo:100. |
7888
e76fa60251dc
Remove obsolete nil-checks after opening streams
Stefan Vogel <sv@exept.de>
parents:
7846
diff
changeset
|
3923 |
('test' asFilename fileSize) printCR. |
932
f57ec42ceb44
added interface to truncate & ftruncate (req. by Mr. Olberding)
Claus Gittinger <cg@exept.de>
parents:
883
diff
changeset
|
3924 |
" |
4148
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3925 |
|
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3926 |
"Modified: / 5.5.1999 / 13:41:59 / cg" |
615 | 3927 |
! ! |
3928 |
||
3929 |
!Filename methodsFor:'file queries'! |
|
3930 |
||
1532
6b4c38b9090c
added #modificationTime & #accessTime (easier to use than #dates)
Claus Gittinger <cg@exept.de>
parents:
1523
diff
changeset
|
3931 |
accessTime |
16578 | 3932 |
"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
|
3933 |
|
3768
4801b87c1cd7
care for non-existing info in #accessTime, #modTime and #fileSize
Claus Gittinger <cg@exept.de>
parents:
3763
diff
changeset
|
3934 |
| i | |
4801b87c1cd7
care for non-existing info in #accessTime, #modTime and #fileSize
Claus Gittinger <cg@exept.de>
parents:
3763
diff
changeset
|
3935 |
|
4801b87c1cd7
care for non-existing info in #accessTime, #modTime and #fileSize
Claus Gittinger <cg@exept.de>
parents:
3763
diff
changeset
|
3936 |
(i := self info) isNil ifTrue:[^ nil]. |
6793
0d3e3fd18a70
modified -> modificationTime
Claus Gittinger <cg@exept.de>
parents:
6776
diff
changeset
|
3937 |
^ i accessTime |
1532
6b4c38b9090c
added #modificationTime & #accessTime (easier to use than #dates)
Claus Gittinger <cg@exept.de>
parents:
1523
diff
changeset
|
3938 |
|
6b4c38b9090c
added #modificationTime & #accessTime (easier to use than #dates)
Claus Gittinger <cg@exept.de>
parents:
1523
diff
changeset
|
3939 |
" |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3940 |
Filename currentDirectory accessTime |
1532
6b4c38b9090c
added #modificationTime & #accessTime (easier to use than #dates)
Claus Gittinger <cg@exept.de>
parents:
1523
diff
changeset
|
3941 |
" |
6b4c38b9090c
added #modificationTime & #accessTime (easier to use than #dates)
Claus Gittinger <cg@exept.de>
parents:
1523
diff
changeset
|
3942 |
|
3768
4801b87c1cd7
care for non-existing info in #accessTime, #modTime and #fileSize
Claus Gittinger <cg@exept.de>
parents:
3763
diff
changeset
|
3943 |
"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
|
3944 |
"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
|
3945 |
"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
|
3946 |
! |
6b4c38b9090c
added #modificationTime & #accessTime (easier to use than #dates)
Claus Gittinger <cg@exept.de>
parents:
1523
diff
changeset
|
3947 |
|
6977 | 3948 |
creationTime |
16578 | 3949 |
"return a timeStamp containing the file's creation time. |
6977 | 3950 |
NOTICE: only windoof distinguishes creation from modification; |
6978 | 3951 |
under unix, nil is returned (callers should fall back and use mod-time then" |
6977 | 3952 |
|
3953 |
|i| |
|
3954 |
||
3955 |
(i := self info) isNil ifTrue:[^ nil]. "/ non-existing |
|
6978 | 3956 |
^ i creationTime |
3957 |
||
3958 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3959 |
Filename currentDirectory creationTime |
6977 | 3960 |
" |
3961 |
||
3962 |
"Created: / 9.7.1996 / 10:18:59 / cg" |
|
3963 |
"Modified: / 26.9.1997 / 13:05:39 / stefan" |
|
3964 |
"Modified: / 14.8.1998 / 17:42:50 / cg" |
|
3965 |
! |
|
3966 |
||
615 | 3967 |
dates |
16578 | 3968 |
"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
|
3969 |
that responds to the at: message with arguments |
615 | 3970 |
#modified, #accessed or #statusChanged." |
3971 |
||
2922 | 3972 |
|info dates osName| |
3973 |
||
2947 | 3974 |
osName := self osNameForAccess. |
2922 | 3975 |
info := OperatingSystem infoOf:osName. |
615 | 3976 |
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
|
3977 |
"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
|
3978 |
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
|
3979 |
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
|
3980 |
info isNil ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3981 |
^ nil |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3982 |
] |
615 | 3983 |
]. |
3984 |
dates := IdentityDictionary new. |
|
6978 | 3985 |
dates at:#created put:(info creationTime). |
6793
0d3e3fd18a70
modified -> modificationTime
Claus Gittinger <cg@exept.de>
parents:
6776
diff
changeset
|
3986 |
dates at:#modified put:(info modificationTime). |
0d3e3fd18a70
modified -> modificationTime
Claus Gittinger <cg@exept.de>
parents:
6776
diff
changeset
|
3987 |
dates at:#accessed put:(info accessTime). |
0d3e3fd18a70
modified -> modificationTime
Claus Gittinger <cg@exept.de>
parents:
6776
diff
changeset
|
3988 |
dates at:#statusChanged put:(info statusChangeTime). |
615 | 3989 |
^ dates |
3990 |
||
3991 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3992 |
Filename currentDirectory dates |
615 | 3993 |
'../regression' asFilename dates |
3994 |
" |
|
1859
7f6040320daf
changes for new return from OS>>infoOf:
Claus Gittinger <cg@exept.de>
parents:
1614
diff
changeset
|
3995 |
|
7f6040320daf
changes for new return from OS>>infoOf:
Claus Gittinger <cg@exept.de>
parents:
1614
diff
changeset
|
3996 |
"Modified: 1.11.1996 / 20:19:24 / cg" |
615 | 3997 |
! |
3998 |
||
3999 |
fileSize |
|
4000 |
"return the size of the file in bytes" |
|
4001 |
||
3768
4801b87c1cd7
care for non-existing info in #accessTime, #modTime and #fileSize
Claus Gittinger <cg@exept.de>
parents:
3763
diff
changeset
|
4002 |
|i| |
4801b87c1cd7
care for non-existing info in #accessTime, #modTime and #fileSize
Claus Gittinger <cg@exept.de>
parents:
3763
diff
changeset
|
4003 |
|
4801b87c1cd7
care for non-existing info in #accessTime, #modTime and #fileSize
Claus Gittinger <cg@exept.de>
parents:
3763
diff
changeset
|
4004 |
(i := self info) isNil ifTrue:[^ nil]. |
6794
498d85323172
use #fileSize instead of #size
Claus Gittinger <cg@exept.de>
parents:
6793
diff
changeset
|
4005 |
^ i fileSize |
3768
4801b87c1cd7
care for non-existing info in #accessTime, #modTime and #fileSize
Claus Gittinger <cg@exept.de>
parents:
3763
diff
changeset
|
4006 |
|
4801b87c1cd7
care for non-existing info in #accessTime, #modTime and #fileSize
Claus Gittinger <cg@exept.de>
parents:
3763
diff
changeset
|
4007 |
"Modified: / 17.8.1998 / 10:23:46 / cg" |
615 | 4008 |
! |
4009 |
||
4010 |
fileType |
|
4011 |
"this returns a string describing the type of contents of |
|
4012 |
the file. This is done using the unix 'file' command, |
|
4013 |
(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
|
4014 |
On non-unix systems, this may simply return 'file', |
2922 | 4015 |
not knowning about the contents. |
4016 |
Warning: |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4017 |
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
|
4018 |
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
|
4019 |
NOT as a tag to be used by a program." |
3665 | 4020 |
|
16755 | 4021 |
|suffix baseNm info mime| |
3665 | 4022 |
|
4023 |
"/ 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
|
4024 |
"/ do the most obvious ones here. |
3665 | 4025 |
"/ (also useful since the 'file' command takes some time, and the code |
4026 |
"/ 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
|
4027 |
|
8477
c962d56c1973
#linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents:
8280
diff
changeset
|
4028 |
info := self linkInfo. |
9060 | 4029 |
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
|
4030 |
^ 'removed' "/ could happen, when coming from a snapshot image |
9060 | 4031 |
]. |
4032 |
||
8477
c962d56c1973
#linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents:
8280
diff
changeset
|
4033 |
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
|
4034 |
^ 'symbolic link to ' , info path |
1601
1d57e1047323
avoid calling 'file' for symbolic links & directories
Claus Gittinger <cg@exept.de>
parents:
1540
diff
changeset
|
4035 |
]. |
8477
c962d56c1973
#linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents:
8280
diff
changeset
|
4036 |
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
|
4037 |
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
|
4038 |
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
|
4039 |
^ 'directory' |
2573 | 4040 |
]. |
8477
c962d56c1973
#linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents:
8280
diff
changeset
|
4041 |
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
|
4042 |
^ 'character device special file' |
3665 | 4043 |
]. |
8477
c962d56c1973
#linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents:
8280
diff
changeset
|
4044 |
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
|
4045 |
^ 'block device special file' |
3665 | 4046 |
]. |
8477
c962d56c1973
#linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents:
8280
diff
changeset
|
4047 |
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
|
4048 |
^ 'socket' |
3665 | 4049 |
]. |
8477
c962d56c1973
#linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents:
8280
diff
changeset
|
4050 |
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
|
4051 |
^ '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
|
4052 |
]. |
3665 | 4053 |
|
1602 | 4054 |
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
|
4055 |
info fileSize == 0 ifTrue:[^ 'empty']. |
1602 | 4056 |
|
17112 | 4057 |
"/ suffix := self suffix asLowercase. |
4058 |
"/ baseNm := self withoutSuffix baseName asLowercase. |
|
2922 | 4059 |
|
16755 | 4060 |
mime := self mimeTypeOfContents. |
4061 |
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
|
4062 |
"/ 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
|
4063 |
(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
|
4064 |
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
|
4065 |
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
|
4066 |
]. |
1602 | 4067 |
]. |
2906 | 4068 |
^ 'file' |
615 | 4069 |
|
4070 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4071 |
'Makefile' asFilename fileType |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4072 |
'.' asFilename fileType |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4073 |
'/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
|
4074 |
'/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
|
4075 |
'/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
|
4076 |
'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
|
4077 |
'bitmaps/SBrowser.xbm' asFilename fileType |
615 | 4078 |
" |
1601
1d57e1047323
avoid calling 'file' for symbolic links & directories
Claus Gittinger <cg@exept.de>
parents:
1540
diff
changeset
|
4079 |
|
3665 | 4080 |
"Modified: / 21.7.1998 / 11:25:56 / cg" |
615 | 4081 |
! |
4082 |
||
2836 | 4083 |
id |
16578 | 4084 |
"return the file's/directory's file-id (inode number)" |
2836 | 4085 |
|
2947 | 4086 |
^ OperatingSystem idOf:(self osNameForAccess) |
2836 | 4087 |
|
4088 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4089 |
Filename currentDirectory id |
2836 | 4090 |
" |
4091 |
||
4092 |
"Modified: 9.7.1996 / 10:19:27 / cg" |
|
4093 |
"Created: 5.8.1997 / 19:26:01 / cg" |
|
4094 |
! |
|
4095 |
||
615 | 4096 |
info |
16578 | 4097 |
"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
|
4098 |
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
|
4099 |
the returned object) is: |
7f6040320daf
changes for new return from OS>>infoOf:
Claus Gittinger <cg@exept.de>
parents:
1614
diff
changeset
|
4100 |
|
20798 | 4101 |
type - a symbol giving the files fileType |
4102 |
mode - numeric access mode |
|
4103 |
uid - owners user id |
|
4104 |
gid - owners group id |
|
4105 |
size - files size |
|
4106 |
id - files number (i.e. inode number) |
|
4107 |
accessed - last access time (as osTime-stamp) |
|
4108 |
modified - last modification time (as osTime-stamp) |
|
4109 |
statusChangeTime - last staus change (as osTime-stamp) |
|
615 | 4110 |
|
1859
7f6040320daf
changes for new return from OS>>infoOf:
Claus Gittinger <cg@exept.de>
parents:
1614
diff
changeset
|
4111 |
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
|
4112 |
all of the information. |
7f6040320daf
changes for new return from OS>>infoOf:
Claus Gittinger <cg@exept.de>
parents:
1614
diff
changeset
|
4113 |
The minimum returned info (i.e. on all OS's) will consist of at least: |
20798 | 4114 |
modified |
4115 |
size |
|
4116 |
type |
|
4117 |
||
4118 |
Don't expect things like uid/gid/mode to be non-nil; write your application |
|
1859
7f6040320daf
changes for new return from OS>>infoOf:
Claus Gittinger <cg@exept.de>
parents:
1614
diff
changeset
|
4119 |
to either handle nil values, |
615 | 4120 |
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
|
4121 |
(i.e. instead of: |
20798 | 4122 |
someFilename type == #directory |
1859
7f6040320daf
changes for new return from OS>>infoOf:
Claus Gittinger <cg@exept.de>
parents:
1614
diff
changeset
|
4123 |
use |
20798 | 4124 |
someFilename isDirectory |
615 | 4125 |
" |
4126 |
||
2947 | 4127 |
^ OperatingSystem infoOf:(self osNameForAccess) |
615 | 4128 |
|
4129 |
" |
|
4130 |
Filename currentDirectory info |
|
3768
4801b87c1cd7
care for non-existing info in #accessTime, #modTime and #fileSize
Claus Gittinger <cg@exept.de>
parents:
3763
diff
changeset
|
4131 |
'/dev/null' asFilename info |
615 | 4132 |
'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
|
4133 |
'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
|
4134 |
'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
|
4135 |
'../../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
|
4136 |
'.' asFilename info |
4801b87c1cd7
care for non-existing info in #accessTime, #modTime and #fileSize
Claus Gittinger <cg@exept.de>
parents:
3763
diff
changeset
|
4137 |
'..' asFilename info |
4801b87c1cd7
care for non-existing info in #accessTime, #modTime and #fileSize
Claus Gittinger <cg@exept.de>
parents:
3763
diff
changeset
|
4138 |
'..\..' asFilename info |
4801b87c1cd7
care for non-existing info in #accessTime, #modTime and #fileSize
Claus Gittinger <cg@exept.de>
parents:
3763
diff
changeset
|
4139 |
'..\..\..' asFilename info |
4801b87c1cd7
care for non-existing info in #accessTime, #modTime and #fileSize
Claus Gittinger <cg@exept.de>
parents:
3763
diff
changeset
|
4140 |
'..\..\..\..' asFilename info |
4801b87c1cd7
care for non-existing info in #accessTime, #modTime and #fileSize
Claus Gittinger <cg@exept.de>
parents:
3763
diff
changeset
|
4141 |
'c:\' asFilename info |
615 | 4142 |
" |
1859
7f6040320daf
changes for new return from OS>>infoOf:
Claus Gittinger <cg@exept.de>
parents:
1614
diff
changeset
|
4143 |
|
16272 | 4144 |
"Modified: / 17-08-1998 / 10:24:10 / cg" |
4145 |
"Modified (comment): / 21-03-2014 / 00:35:30 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
615 | 4146 |
! |
4147 |
||
4148 |
linkInfo |
|
16578 | 4149 |
"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
|
4150 |
instead of the link's target. |
615 | 4151 |
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
|
4152 |
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
|
4153 |
is returned |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4154 |
(while in this case, #info returns the info of the target file, |
615 | 4155 |
which is accessed via the symbolic link). |
4156 |
||
4157 |
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
|
4158 |
path -> the target files pathname |
615 | 4159 |
|
4160 |
See the comment in #info for more details." |
|
4161 |
||
2947 | 4162 |
^ OperatingSystem linkInfoOf:(self osNameForAccess) |
615 | 4163 |
|
4164 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4165 |
Filename currentDirectory linkInfo |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4166 |
'/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
|
4167 |
'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
|
4168 |
'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
|
4169 |
'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
|
4170 |
'../../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
|
4171 |
'/usr/tmp' asFilename linkInfo |
615 | 4172 |
" |
1862
e8f44f10f1ab
changes for new #infoOf: / #linkInfoOf: return
Claus Gittinger <cg@exept.de>
parents:
1859
diff
changeset
|
4173 |
|
e8f44f10f1ab
changes for new #infoOf: / #linkInfoOf: return
Claus Gittinger <cg@exept.de>
parents:
1859
diff
changeset
|
4174 |
"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
|
4175 |
! |
6b4c38b9090c
added #modificationTime & #accessTime (easier to use than #dates)
Claus Gittinger <cg@exept.de>
parents:
1523
diff
changeset
|
4176 |
|
6b4c38b9090c
added #modificationTime & #accessTime (easier to use than #dates)
Claus Gittinger <cg@exept.de>
parents:
1523
diff
changeset
|
4177 |
modificationTime |
16578 | 4178 |
"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
|
4179 |
|
3763
31d58d04ac15
care for nil-info in #modificationTime
Claus Gittinger <cg@exept.de>
parents:
3753
diff
changeset
|
4180 |
|i| |
31d58d04ac15
care for nil-info in #modificationTime
Claus Gittinger <cg@exept.de>
parents:
3753
diff
changeset
|
4181 |
|
31d58d04ac15
care for nil-info in #modificationTime
Claus Gittinger <cg@exept.de>
parents:
3753
diff
changeset
|
4182 |
(i := self info) isNil ifTrue:[^ nil]. "/ non-existing |
6793
0d3e3fd18a70
modified -> modificationTime
Claus Gittinger <cg@exept.de>
parents:
6776
diff
changeset
|
4183 |
^ i modificationTime |
1532
6b4c38b9090c
added #modificationTime & #accessTime (easier to use than #dates)
Claus Gittinger <cg@exept.de>
parents:
1523
diff
changeset
|
4184 |
|
6b4c38b9090c
added #modificationTime & #accessTime (easier to use than #dates)
Claus Gittinger <cg@exept.de>
parents:
1523
diff
changeset
|
4185 |
" |
6b4c38b9090c
added #modificationTime & #accessTime (easier to use than #dates)
Claus Gittinger <cg@exept.de>
parents:
1523
diff
changeset
|
4186 |
Filename currentDirectory modificationTime |
6b4c38b9090c
added #modificationTime & #accessTime (easier to use than #dates)
Claus Gittinger <cg@exept.de>
parents:
1523
diff
changeset
|
4187 |
" |
6b4c38b9090c
added #modificationTime & #accessTime (easier to use than #dates)
Claus Gittinger <cg@exept.de>
parents:
1523
diff
changeset
|
4188 |
|
3763
31d58d04ac15
care for nil-info in #modificationTime
Claus Gittinger <cg@exept.de>
parents:
3753
diff
changeset
|
4189 |
"Created: / 9.7.1996 / 10:18:59 / cg" |
31d58d04ac15
care for nil-info in #modificationTime
Claus Gittinger <cg@exept.de>
parents:
3753
diff
changeset
|
4190 |
"Modified: / 26.9.1997 / 13:05:39 / stefan" |
31d58d04ac15
care for nil-info in #modificationTime
Claus Gittinger <cg@exept.de>
parents:
3753
diff
changeset
|
4191 |
"Modified: / 14.8.1998 / 17:42:50 / cg" |
2836 | 4192 |
! |
4193 |
||
4194 |
type |
|
4195 |
"return the symbolic type of the file" |
|
4196 |
||
2947 | 4197 |
^ OperatingSystem typeOf:(self osNameForAccess) |
2836 | 4198 |
|
4199 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4200 |
Filename currentDirectory type |
2836 | 4201 |
" |
4202 |
||
4203 |
"Modified: 9.7.1996 / 10:19:27 / cg" |
|
4204 |
"Created: 5.8.1997 / 19:31:26 / cg" |
|
615 | 4205 |
! ! |
4206 |
||
4207 |
!Filename methodsFor:'file utilities'! |
|
4208 |
||
4209 |
edit |
|
4210 |
"start an editView on the file represented by the receiver" |
|
4211 |
||
4212 |
EditTextView openOn:self asString |
|
4213 |
||
4214 |
" |
|
4215 |
'smalltalk.rc' asFilename edit |
|
4216 |
" |
|
4217 |
! |
|
4218 |
||
4219 |
fileIn |
|
13424 | 4220 |
"load source code from the file" |
4221 |
||
4222 |
^ (ProgrammingLanguage forFile: self) fileIn: self |
|
4223 |
||
4224 |
"Modified: / 16-08-2009 / 13:27:36 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
542 | 4225 |
! ! |
4226 |
||
2 | 4227 |
!Filename methodsFor:'instance creation'! |
4228 |
||
10969
046b204c6ea2
New method: #/ as synonym of #construct:. Thanks to Jan Vrany, see Bug 823.
Stefan Vogel <sv@exept.de>
parents:
10902
diff
changeset
|
4229 |
/ subname |
046b204c6ea2
New method: #/ as synonym of #construct:. Thanks to Jan Vrany, see Bug 823.
Stefan Vogel <sv@exept.de>
parents:
10902
diff
changeset
|
4230 |
"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
|
4231 |
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
|
4232 |
(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
|
4233 |
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
|
4234 |
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
|
4235 |
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
|
4236 |
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
|
4237 |
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
|
4238 |
|
046b204c6ea2
New method: #/ as synonym of #construct:. Thanks to Jan Vrany, see Bug 823.
Stefan Vogel <sv@exept.de>
parents:
10902
diff
changeset
|
4239 |
^ 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
|
4240 |
|
046b204c6ea2
New method: #/ as synonym of #construct:. Thanks to Jan Vrany, see Bug 823.
Stefan Vogel <sv@exept.de>
parents:
10902
diff
changeset
|
4241 |
" |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4242 |
'/tmp' asFilename / 'foo' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4243 |
'/' 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
|
4244 |
'/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
|
4245 |
|
046b204c6ea2
New method: #/ as synonym of #construct:. Thanks to Jan Vrany, see Bug 823.
Stefan Vogel <sv@exept.de>
parents:
10902
diff
changeset
|
4246 |
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
|
4247 |
'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
|
4248 |
" |
046b204c6ea2
New method: #/ as synonym of #construct:. Thanks to Jan Vrany, see Bug 823.
Stefan Vogel <sv@exept.de>
parents:
10902
diff
changeset
|
4249 |
! |
046b204c6ea2
New method: #/ as synonym of #construct:. Thanks to Jan Vrany, see Bug 823.
Stefan Vogel <sv@exept.de>
parents:
10902
diff
changeset
|
4250 |
|
615 | 4251 |
construct:subname |
4252 |
"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
|
4253 |
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
|
4254 |
(i.e. for a file or a subdirectory in that directory). |
2922 | 4255 |
The argument may not specify an absolute path name. |
4256 |
Please do not use this to create filenames with suffixes, |
|
4257 |
since some systems require special naming conventions. |
|
4258 |
See also: #withSuffix: (which is different, but often needed)." |
|
615 | 4259 |
|
11784 | 4260 |
|constructedName| |
4261 |
||
4262 |
constructedName := self constructString:subname. |
|
15811 | 4263 |
^ self species named:constructedName. |
615 | 4264 |
|
4265 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4266 |
'/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
|
4267 |
'/' asFilename construct:'foo' |
615 | 4268 |
'/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
|
4269 |
'/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
|
4270 |
'/foo/bar' asFilename construct:'baz' asFilename |
2922 | 4271 |
|
4272 |
Bad example; works on UNIX, but may not on others: |
|
11784 | 4273 |
'foo/bar.baz' asFilename construct:'.suff' |
615 | 4274 |
" |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4275 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4276 |
"Modified: 29.2.1996 / 20:55:06 / cg" |
2911 | 4277 |
! |
4278 |
||
2922 | 4279 |
constructDirectory:subname |
4280 |
"same as #construct: on most systems. |
|
4281 |
(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
|
4282 |
|
15811 | 4283 |
^ self species named:(self constructDirectoryString:subname) |
2922 | 4284 |
! |
4285 |
||
4286 |
constructDirectoryString:subName |
|
4287 |
"same as #constructString: on most systems. |
|
4288 |
(may allow different/relaxed name syntax of the argument on some systems)" |
|
4289 |
||
4290 |
^ self constructString:subName |
|
4291 |
! |
|
4292 |
||
4293 |
constructString:subName |
|
2911 | 4294 |
"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
|
4295 |
filename-string for an entry within this directory |
2922 | 4296 |
(i.e. for a file or a subdirectory in that directory). |
2960 | 4297 |
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
|
4298 |
The code below works for UNIX & MSDOS; |
2960 | 4299 |
other filename classes (i.e. VMS) may want to redefine this method." |
4300 |
||
4301 |
|sepString sub| |
|
4302 |
||
4303 |
sub := subName asString. |
|
20069 | 4304 |
nameString size == 0 ifTrue:[ |
4305 |
^ sub |
|
4306 |
]. |
|
15811 | 4307 |
sepString := self species separatorString. |
3677
51542c86ba2a
md's changes for msdos compatibility.
Claus Gittinger <cg@exept.de>
parents:
3666
diff
changeset
|
4308 |
(nameString endsWith:sepString) ifTrue:[ |
20069 | 4309 |
^ nameString , sub |
6247 | 4310 |
]. |
2960 | 4311 |
^ nameString , sepString , sub |
2911 | 4312 |
|
4313 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4314 |
'/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
|
4315 |
'/' asFilename constructString:'foo' |
2911 | 4316 |
'/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
|
4317 |
'/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
|
4318 |
'' asFilename constructString:'baz' |
2911 | 4319 |
" |
4320 |
||
3677
51542c86ba2a
md's changes for msdos compatibility.
Claus Gittinger <cg@exept.de>
parents:
3666
diff
changeset
|
4321 |
"Modified: / 7.9.1995 / 10:15:22 / claus" |
51542c86ba2a
md's changes for msdos compatibility.
Claus Gittinger <cg@exept.de>
parents:
3666
diff
changeset
|
4322 |
"Created: / 9.9.1997 / 08:57:08 / cg" |
51542c86ba2a
md's changes for msdos compatibility.
Claus Gittinger <cg@exept.de>
parents:
3666
diff
changeset
|
4323 |
"Modified: / 20.1.1998 / 15:58:23 / md" |
51542c86ba2a
md's changes for msdos compatibility.
Claus Gittinger <cg@exept.de>
parents:
3666
diff
changeset
|
4324 |
"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
|
4325 |
! |
e1f1111afa12
Add #isImplicit to check for builtin dir names such as '.' and '..'.
Stefan Vogel <sv@exept.de>
parents:
2939
diff
changeset
|
4326 |
|
e1f1111afa12
Add #isImplicit to check for builtin dir names such as '.' and '..'.
Stefan Vogel <sv@exept.de>
parents:
2939
diff
changeset
|
4327 |
filenameFor:fileName |
6973 | 4328 |
"return a filename representing the argument, fileName |
4329 |
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
|
4330 |
|
e1f1111afa12
Add #isImplicit to check for builtin dir names such as '.' and '..'.
Stefan Vogel <sv@exept.de>
parents:
2939
diff
changeset
|
4331 |
|f| |
e1f1111afa12
Add #isImplicit to check for builtin dir names such as '.' and '..'.
Stefan Vogel <sv@exept.de>
parents:
2939
diff
changeset
|
4332 |
|
e1f1111afa12
Add #isImplicit to check for builtin dir names such as '.' and '..'.
Stefan Vogel <sv@exept.de>
parents:
2939
diff
changeset
|
4333 |
f := fileName asFilename. |
e1f1111afa12
Add #isImplicit to check for builtin dir names such as '.' and '..'.
Stefan Vogel <sv@exept.de>
parents:
2939
diff
changeset
|
4334 |
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
|
4335 |
^ (self construct:fileName) |
e1f1111afa12
Add #isImplicit to check for builtin dir names such as '.' and '..'.
Stefan Vogel <sv@exept.de>
parents:
2939
diff
changeset
|
4336 |
|
e1f1111afa12
Add #isImplicit to check for builtin dir names such as '.' and '..'.
Stefan Vogel <sv@exept.de>
parents:
2939
diff
changeset
|
4337 |
" |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4338 |
'/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
|
4339 |
'/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
|
4340 |
" |
e1f1111afa12
Add #isImplicit to check for builtin dir names such as '.' and '..'.
Stefan Vogel <sv@exept.de>
parents:
2939
diff
changeset
|
4341 |
|
e1f1111afa12
Add #isImplicit to check for builtin dir names such as '.' and '..'.
Stefan Vogel <sv@exept.de>
parents:
2939
diff
changeset
|
4342 |
"Created: 18.9.1997 / 14:34:14 / stefan" |
9263 | 4343 |
! |
4344 |
||
4345 |
secureConstruct:subname |
|
4346 |
"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
|
4347 |
filename for an entry within this directory |
9263 | 4348 |
(i.e. for a file or a subdirectory in that directory). |
4349 |
The argument may not specify an absolute path name. |
|
4350 |
Please do not use this to create filenames with suffixes, |
|
4351 |
since some systems require special naming conventions. |
|
4352 |
See also: #withSuffix: (which is different, but often needed). |
|
4353 |
||
4354 |
This method differs from #construct:, by not permitting subName |
|
4355 |
to navigate above (via ..) the current filename." |
|
4356 |
||
15811 | 4357 |
^ self species named:(self secureConstructString:subname) |
9263 | 4358 |
|
4359 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4360 |
'/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
|
4361 |
'/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
|
4362 |
'/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
|
4363 |
'/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
|
4364 |
'/' asFilename secureConstruct:'foo' |
9263 | 4365 |
'/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
|
4366 |
'/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
|
4367 |
'/foo/bar' asFilename secureConstruct:'baz' asFilename |
9263 | 4368 |
|
4369 |
Bad example; works on UNIX, but may not on others: |
|
4370 |
'foo/bar.baz' secureConstruct:'.suff' |
|
4371 |
" |
|
4372 |
||
4373 |
"Modified: 29.2.1996 / 20:55:06 / cg" |
|
4374 |
! |
|
4375 |
||
4376 |
secureConstructString:subName |
|
4377 |
"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
|
4378 |
filename-string for an entry within this directory |
9263 | 4379 |
(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
|
4380 |
|
9263 | 4381 |
This method differs from #constructString, by not permitting subName |
4382 |
to navigate above (via ..) the current filename. |
|
4383 |
||
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4384 |
The code below works for UNIX & MSDOS; |
9263 | 4385 |
other filename classes (i.e. VMS) may want to redefine this method." |
4386 |
||
4387 |
|sepString sub normalizedPath pathStream| |
|
4388 |
||
15811 | 4389 |
sepString := self species separatorString. |
9263 | 4390 |
sub := subName asString. |
4391 |
||
4392 |
sub := sub asCollectionOfSubstringsSeparatedByAll:sepString. |
|
4393 |
normalizedPath := OrderedCollection new:sub size. |
|
4394 |
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
|
4395 |
eachPathComponent = '..' ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4396 |
normalizedPath isEmpty ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4397 |
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
|
4398 |
]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4399 |
normalizedPath removeLast. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4400 |
] 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
|
4401 |
normalizedPath add:eachPathComponent. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4402 |
]] |
9263 | 4403 |
]. |
18272 | 4404 |
pathStream := CharacterWriteStream with:nameString. |
9263 | 4405 |
(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
|
4406 |
pathStream nextPutAll:sepString. |
9263 | 4407 |
]. |
4408 |
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
|
4409 |
pathStream nextPutAll:eachPathComponent. |
9263 | 4410 |
] separatedBy:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4411 |
pathStream nextPutAll:sepString. |
9263 | 4412 |
]. |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4413 |
|
9263 | 4414 |
^ pathStream contents. |
4415 |
||
4416 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4417 |
'/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
|
4418 |
'/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
|
4419 |
'/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
|
4420 |
'/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
|
4421 |
'/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
|
4422 |
'/' asFilename secureConstructString:'foo' |
9263 | 4423 |
'/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
|
4424 |
'/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
|
4425 |
'' asFilename secureConstructString:'baz' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4426 |
'' asFilename secureConstructString:'/baz' |
9263 | 4427 |
" |
2 | 4428 |
! ! |
4429 |
||
195 | 4430 |
!Filename methodsFor:'misc'! |
4431 |
||
4432 |
, aString |
|
4433 |
"this allows filenames to understand how names are concatenated. |
|
14072 | 4434 |
Returns a string consisting of the receiver's name, concatenated |
195 | 4435 |
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
|
4436 |
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
|
4437 |
See also: #withSuffix: which is new and better." |
195 | 4438 |
|
5866 | 4439 |
<resource:#obsolete> |
4440 |
||
2906 | 4441 |
self obsoleteMethodWarning:'use #construct:'. |
308 | 4442 |
^ (nameString , aString asString) |
195 | 4443 |
|
4444 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4445 |
'Makefile' asFilename , '.bak' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4446 |
('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
|
4447 |
'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
|
4448 |
'Makefile' asFilename construct:'.bak' |
195 | 4449 |
" |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4450 |
|
14072 | 4451 |
"Modified: / 07-09-1997 / 23:45:36 / cg" |
4452 |
"Modified (comment): / 01-04-2012 / 13:18:21 / cg" |
|
9263 | 4453 |
! |
4454 |
||
4455 |
canonicalize |
|
4456 |
"normalize a filename by removing all empty path components or dots, |
|
4457 |
and by resolving parent directory '..' references. |
|
4458 |
||
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4459 |
The code below works for UNIX & MSDOS; |
9263 | 4460 |
other filename classes (i.e. VMS) may want to redefine this method." |
4461 |
||
15811 | 4462 |
nameString := self species canonicalize:nameString. |
9263 | 4463 |
|
4464 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4465 |
'/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
|
4466 |
'/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
|
4467 |
'/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
|
4468 |
'..' asFilename canonicalize. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4469 |
'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
|
4470 |
'//bla/../fasel' asFilename canonicalize. |
9263 | 4471 |
" |
195 | 4472 |
! ! |
4473 |
||
14232 | 4474 |
!Filename methodsFor:'os shell'! |
4475 |
||
4476 |
openExplorer |
|
4477 |
"open a file-explorer on the directory represented by the receiver. |
|
4478 |
On non-windows systems, an error is raised" |
|
4479 |
||
4480 |
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
|
4481 |
self warn:'sorry - this operation is only available under windows'. |
14232 | 4482 |
]. |
4483 |
||
4484 |
OperatingSystem |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4485 |
openApplicationForDocument:self pathName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4486 |
operation:#explore. |
14232 | 4487 |
|
4488 |
"Created: / 21-07-2012 / 12:28:18 / cg" |
|
14804 | 4489 |
! |
4490 |
||
4491 |
openFinder |
|
4492 |
"open a finder on the directory represented by the receiver. |
|
4493 |
On non-osx systems, an error is raised" |
|
4494 |
||
4495 |
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
|
4496 |
self warn:'sorry - this operation is only available under osx'. |
14804 | 4497 |
]. |
4498 |
||
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4499 |
OperatingSystem executeCommand:'open "',self pathName,'"' |
14804 | 4500 |
! |
4501 |
||
4502 |
openTerminal |
|
16545 | 4503 |
"open a terminal window on the directory represented by the receiver; |
4504 |
on osx, a terminal app is opened, |
|
4505 |
on windows a cmd.exe window, |
|
4506 |
on unix, an xterm is opened." |
|
4507 |
||
4508 |
OperatingSystem isOSXlike ifTrue:[ |
|
20798 | 4509 |
"/ I don't know yet how to tell the terminal to |
20678 | 4510 |
"/ go to a particular directory. |
4511 |
"/ therefore, use the built in terminal |
|
4512 |
VT100TerminalView openShellIn:self pathName. |
|
4513 |
^ self. |
|
4514 |
]. |
|
4515 |
"/ using the code below seems to close the window immediately |
|
4516 |
"/ at least on win7. |
|
4517 |
"/ use out own terminal, to make sure. |
|
4518 |
(OperatingSystem isMSWINDOWSlike |
|
4519 |
and:[OperatingSystem isWin7Like]) ifTrue:[ |
|
20798 | 4520 |
"/ I don't know yet how to tell the terminal to |
20678 | 4521 |
"/ go to a particular directory. |
4522 |
"/ therefore, use the built in terminal |
|
4523 |
VT100TerminalView openShellIn:self pathName. |
|
4524 |
^ self. |
|
16545 | 4525 |
]. |
14804 | 4526 |
|
14941 | 4527 |
[ |
20678 | 4528 |
|cmd| |
4529 |
||
4530 |
OperatingSystem isOSXlike ifTrue:[ |
|
4531 |
cmd := '/Applications/Utilities/Terminal.app/Contents/MacOS/Terminal ' |
|
4532 |
] ifFalse:[ |
|
4533 |
OperatingSystem isMSWINDOWSlike ifTrue:[ |
|
4534 |
cmd := #('c:\windows\System32\cmd.exe') |
|
4535 |
] ifFalse:[ |
|
4536 |
"/ VT100TerminalView openShellIn:self pathName |
|
4537 |
cmd := 'xterm' |
|
4538 |
] |
|
4539 |
]. |
|
4540 |
OperatingSystem |
|
4541 |
executeCommand:cmd |
|
4542 |
inDirectory:self pathName |
|
4543 |
showWindow:#default. |
|
14941 | 4544 |
] fork |
20678 | 4545 |
|
4546 |
"Modified: / 18-10-2016 / 16:08:15 / cg" |
|
14232 | 4547 |
! ! |
4548 |
||
615 | 4549 |
!Filename methodsFor:'printing & storing'! |
174 | 4550 |
|
615 | 4551 |
printOn:aStream |
4392 | 4552 |
"append a user printed representation of the receiver to aStream. |
4553 |
The format is suitable for a human - not meant to be read back." |
|
174 | 4554 |
|
2906 | 4555 |
aStream nextPutAll:(self class name). |
4556 |
aStream nextPutAll:'('''. |
|
615 | 4557 |
nameString printOn:aStream. |
4558 |
aStream nextPutAll:''')' |
|
2906 | 4559 |
|
4560 |
"Modified: 7.9.1997 / 23:46:20 / cg" |
|
1 | 4561 |
! |
4562 |
||
615 | 4563 |
storeOn:aStream |
4564 |
"append a printed representation of the receiver to aStream, |
|
4565 |
which allows reconstructing it via readFrom:" |
|
328 | 4566 |
|
615 | 4567 |
aStream nextPut:$(. |
4568 |
nameString storeOn:aStream. |
|
4569 |
aStream nextPutAll:' asFilename)' |
|
1 | 4570 |
! ! |
4571 |
||
7258 | 4572 |
!Filename methodsFor:'private-accessing'! |
1 | 4573 |
|
6227 | 4574 |
getName |
4575 |
"get the raw filename" |
|
4576 |
||
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4577 |
^ nameString |
6227 | 4578 |
! |
4579 |
||
68 | 4580 |
setName:aString |
38 | 4581 |
"set the filename" |
4582 |
||
14220
2a3457b016be
Fix the '~/dir/name' resolution fow windows
Stefan Vogel <sv@exept.de>
parents:
14218
diff
changeset
|
4583 |
nameString := aString. |
3666 | 4584 |
|
4585 |
"Modified: / 21.7.1998 / 10:44:18 / cg" |
|
1 | 4586 |
! ! |
4587 |
||
2 | 4588 |
!Filename methodsFor:'queries'! |
4589 |
||
68 | 4590 |
exists |
92 | 4591 |
"return true, if such a file exists." |
68 | 4592 |
|
2947 | 4593 |
^ OperatingSystem isValidPath:(self osNameForAccess) |
68 | 4594 |
|
85 | 4595 |
" |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4596 |
'/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
|
4597 |
'/tmp' asFilename exists |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4598 |
'Makefile' asFilename exists |
85 | 4599 |
" |
77 | 4600 |
! |
4601 |
||
5928 | 4602 |
filenamesMatching:aPattern |
4603 |
"VW compatibility" |
|
4604 |
||
15811 | 4605 |
^ (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
|
4606 |
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
|
4607 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4608 |
" |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4609 |
'/etc' asFilename filenamesMatching:'a*;c*' |
5928 | 4610 |
" |
4611 |
||
4612 |
"Created: / 15.4.1997 / 15:40:02 / cg" |
|
4613 |
"Modified: / 3.8.1998 / 21:22:15 / cg" |
|
4614 |
! |
|
4615 |
||
2548
b6182b559ea2
made filesMatching ST-80 compatible.
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4616 |
filesMatching:aPattern |
2550 | 4617 |
"given the receiver, representing a directory; |
4618 |
return a collection of files matching a pattern. |
|
4619 |
The pattern may be a simple matchPattern, or a set of |
|
4620 |
multiple patterns separated by semicolons." |
|
4621 |
||
19821 | 4622 |
^ OrderedCollection withCollectedContents:[:coll | |
4623 |
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
|
4624 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4625 |
" |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4626 |
'/etc' asFilename filesMatching:'a*;c*' |
2548
b6182b559ea2
made filesMatching ST-80 compatible.
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4627 |
" |
b6182b559ea2
made filesMatching ST-80 compatible.
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4628 |
|
3719
ce88c6f64d37
ignore case for PC-filenames when searching for matches.
Claus Gittinger <cg@exept.de>
parents:
3713
diff
changeset
|
4629 |
"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
|
4630 |
"Modified: / 3.8.1998 / 21:22:15 / cg" |
2550 | 4631 |
! |
4632 |
||
19821 | 4633 |
filesMatching:aPattern caseSensitive:caseSensitive do:aBlock |
4634 |
"given the receiver, representing a directory; |
|
4635 |
evaluate aBlock for files which match a pattern. |
|
4636 |
The pattern may be a simple matchPattern, or a set of |
|
4637 |
multiple patterns separated by semicolons." |
|
4638 |
||
4639 |
|matchers| |
|
4640 |
||
4641 |
matchers := aPattern asCollectionOfSubstringsSeparatedBy:$;. |
|
4642 |
self directoryContentsDo:[:name | |
|
4643 |
(matchers contains:[:p | p match:name caseSensitive:caseSensitive]) ifTrue:[ |
|
4644 |
aBlock value:name |
|
4645 |
] |
|
4646 |
]. |
|
4647 |
||
4648 |
" |
|
4649 |
'/etc' asFilename filesMatching:'a*;c*' do:[:f | Transcript showCR:f] |
|
4650 |
" |
|
4651 |
||
4652 |
"Created: / 15.4.1997 / 15:40:02 / cg" |
|
4653 |
"Modified: / 3.8.1998 / 21:22:15 / cg" |
|
4654 |
! |
|
4655 |
||
4656 |
filesMatching:aPattern do:aBlock |
|
4657 |
"given the receiver, representing a directory; |
|
4658 |
evaluate aBlock for files which match a pattern. |
|
4659 |
The pattern may be a simple matchPattern, or a set of |
|
4660 |
multiple patterns separated by semicolons." |
|
4661 |
||
4662 |
self filesMatching:aPattern caseSensitive:self species isCaseSensitive do:aBlock |
|
4663 |
||
4664 |
" |
|
4665 |
'/etc' asFilename filesMatching:'a*;c*' do:[:f | Transcript showCR:f] |
|
4666 |
" |
|
4667 |
||
4668 |
"Created: / 15.4.1997 / 15:40:02 / cg" |
|
4669 |
"Modified: / 3.8.1998 / 21:22:15 / cg" |
|
4670 |
! |
|
4671 |
||
2550 | 4672 |
filesMatchingWithoutDotDirs:aPattern |
4673 |
"given the receiver, representing a directory; |
|
4674 |
return a collection of files matching a pattern. |
|
4675 |
Exclude '.' and '..' from the returned list. |
|
4676 |
The pattern may be a simple matchPattern, or a set of |
|
4677 |
multiple patterns separated by semicolons." |
|
4678 |
||
19821 | 4679 |
^ OrderedCollection withCollectedContents:[:coll | |
4680 |
self filesMatchingWithoutDotDirs:aPattern do:[:fn | coll add:fn]] |
|
4681 |
||
4682 |
" |
|
4683 |
Filename currentDirectory filesMatching:'.*' |
|
4684 |
Filename currentDirectory filesMatchingWithoutDotDirs:'*.*' |
|
4685 |
'/etc' asFilename filesMatchingWithoutDotDirs:'*' |
|
4686 |
" |
|
4687 |
||
4688 |
"Created: / 15.4.1997 / 12:52:10 / cg" |
|
4689 |
"Modified: / 3.8.1998 / 21:22:30 / cg" |
|
4690 |
! |
|
4691 |
||
4692 |
filesMatchingWithoutDotDirs:aPattern caseSensitive:caseSensitive do:aBlock |
|
4693 |
"given the receiver, representing a directory; |
|
4694 |
evaluate aBlock for files matching a pattern. |
|
4695 |
Exclude '.' and '..'. |
|
4696 |
The pattern may be a simple matchPattern, or a set of |
|
4697 |
multiple patterns separated by semicolons." |
|
4698 |
||
4699 |
|matchers| |
|
2550 | 4700 |
|
4701 |
matchers := aPattern asCollectionOfSubstringsSeparatedBy:$;. |
|
19821 | 4702 |
|
4703 |
self directoryContentsDo:[:name | |
|
4704 |
(name ~= '.' |
|
4705 |
and:[ name ~= '..' |
|
4706 |
and:[ (matchers contains:[:p | p match:name caseSensitive:caseSensitive]) ]]) |
|
4707 |
ifTrue:[ |
|
4708 |
aBlock value:name |
|
4709 |
] |
|
4710 |
]. |
|
4711 |
||
4712 |
" |
|
4713 |
Filename currentDirectory filesMatching:'M*' |
|
4714 |
'/etc' asFilename filesMatching:'[a-z]*' |
|
4715 |
'../../libbasic' asFilename filesMatching:'[A-D]*.st' |
|
4716 |
" |
|
4717 |
||
4718 |
"Created: / 15.4.1997 / 12:52:10 / cg" |
|
4719 |
"Modified: / 3.8.1998 / 21:22:30 / cg" |
|
4720 |
! |
|
4721 |
||
4722 |
filesMatchingWithoutDotDirs:aPattern do:aBlock |
|
4723 |
"given the receiver, representing a directory; |
|
4724 |
evaluate aBlock for files matching a pattern. |
|
4725 |
Exclude '.' and '..'. |
|
4726 |
The pattern may be a simple matchPattern, or a set of |
|
4727 |
multiple patterns separated by semicolons." |
|
4728 |
||
4729 |
self filesMatchingWithoutDotDirs:aPattern caseSensitive:self species isCaseSensitive do:aBlock |
|
2550 | 4730 |
|
4731 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4732 |
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
|
4733 |
'/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
|
4734 |
'../../libbasic' asFilename filesMatching:'[A-D]*.st' |
2550 | 4735 |
" |
4736 |
||
3719
ce88c6f64d37
ignore case for PC-filenames when searching for matches.
Claus Gittinger <cg@exept.de>
parents:
3713
diff
changeset
|
4737 |
"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
|
4738 |
"Modified: / 3.8.1998 / 21:22:30 / cg" |
2548
b6182b559ea2
made filesMatching ST-80 compatible.
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4739 |
! |
b6182b559ea2
made filesMatching ST-80 compatible.
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4740 |
|
9206 | 4741 |
fullAlternativePathName |
19821 | 4742 |
"some filesystems (aka: windows) have alternative (short) filenames. |
4743 |
Those systems redefine this method to return it. |
|
4744 |
Otherwise, the same as the regular name is returned here" |
|
4745 |
||
9206 | 4746 |
^ nameString |
4747 |
! |
|
4748 |
||
615 | 4749 |
isExecutable |
4750 |
"return true, if such a file exists and is executable (by Unix's definition). |
|
4751 |
For directories, true is returned if the directory can be entered. |
|
4752 |
See isExecutableProgram for a related check." |
|
4753 |
||
2947 | 4754 |
^ OperatingSystem isExecutable:(self osNameForAccess) |
615 | 4755 |
|
4756 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4757 |
'/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
|
4758 |
'/tmp' asFilename isExecutable |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4759 |
'Makefile' asFilename isExecutable |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4760 |
'/bin/ls' asFilename isExecutable |
356 | 4761 |
" |
4762 |
! |
|
4763 |
||
615 | 4764 |
isExecutableProgram |
4765 |
"return true, if such a file exists and is an executable program. |
|
4766 |
(i.e. for directories, false is returned.)" |
|
356 | 4767 |
|
2922 | 4768 |
|osName| |
4769 |
||
2947 | 4770 |
osName := self osNameForAccess. |
2922 | 4771 |
^ (OperatingSystem isExecutable:osName) |
4772 |
and:[(OperatingSystem isDirectory:osName) not] |
|
356 | 4773 |
|
4774 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4775 |
'/tmp' asFilename isExecutable |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4776 |
'/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
|
4777 |
'/tmp' asFilename isExecutableProgram |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4778 |
'/bin/ls' asFilename isExecutableProgram |
20457 | 4779 |
|
4780 |
'ls' asFilename isExecutableProgram |
|
4781 |
OperatingSystem canExecuteCommand:'ls' |
|
615 | 4782 |
" |
4783 |
! |
|
4784 |
||
2922 | 4785 |
isHidden |
4786 |
"return true, if the receiver represents a hidden file. |
|
4787 |
The definitions of hidden files depends on the OS used; |
|
4788 |
on UNIX, a name starting with a period is considered hidden; |
|
16578 | 4789 |
on MSDOS, the file's hidden attribute is also used. |
2922 | 4790 |
VMS has no concept of hidden files." |
4791 |
||
4792 |
^ false |
|
4793 |
! |
|
4794 |
||
6773
26415b61ad09
isMountPoint & isParentDirectoryOf & allParentDirsDo:
penk
parents:
6771
diff
changeset
|
4795 |
isMountPoint:aPathName |
26415b61ad09
isMountPoint & isParentDirectoryOf & allParentDirsDo:
penk
parents:
6771
diff
changeset
|
4796 |
"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
|
4797 |
Warning: |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4798 |
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
|
4799 |
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
|
4800 |
Aka: do not ask: '../../' asFilename isMountPoint; |
6773
26415b61ad09
isMountPoint & isParentDirectoryOf & allParentDirsDo:
penk
parents:
6771
diff
changeset
|
4801 |
" |
26415b61ad09
isMountPoint & isParentDirectoryOf & allParentDirsDo:
penk
parents:
6771
diff
changeset
|
4802 |
|
26415b61ad09
isMountPoint & isParentDirectoryOf & allParentDirsDo:
penk
parents:
6771
diff
changeset
|
4803 |
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
|
4804 |
self error:'this query must be done on an absolute pathname'. |
6773
26415b61ad09
isMountPoint & isParentDirectoryOf & allParentDirsDo:
penk
parents:
6771
diff
changeset
|
4805 |
]. |
26415b61ad09
isMountPoint & isParentDirectoryOf & allParentDirsDo:
penk
parents:
6771
diff
changeset
|
4806 |
^ OperatingSystem isMountPoint:(self name) |
26415b61ad09
isMountPoint & isParentDirectoryOf & allParentDirsDo:
penk
parents:
6771
diff
changeset
|
4807 |
! |
26415b61ad09
isMountPoint & isParentDirectoryOf & allParentDirsDo:
penk
parents:
6771
diff
changeset
|
4808 |
|
615 | 4809 |
isReadable |
4810 |
"return true, if such a file exists and is readable." |
|
4811 |
||
2947 | 4812 |
^ OperatingSystem isReadable:(self osNameForFile) |
615 | 4813 |
|
4814 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4815 |
'/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
|
4816 |
'/tmp' asFilename isReadable |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4817 |
'Makefile' asFilename isReadable |
328 | 4818 |
" |
4819 |
! |
|
4820 |
||
11529 | 4821 |
isSharedLibrary |
4822 |
"return true, if such a file exists and is a shared library." |
|
4823 |
||
4824 |
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
|
4825 |
"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
|
4826 |
^ false. |
11529 | 4827 |
]. |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4828 |
^ (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
|
4829 |
and:[self isRegularFile]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4830 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4831 |
" |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4832 |
'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
|
4833 |
'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
|
4834 |
'/tmp' asFilename isSharedLibrary |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4835 |
'/tmp.dll' asFilename isSharedLibrary |
11529 | 4836 |
" |
4837 |
! |
|
4838 |
||
615 | 4839 |
isWritable |
4840 |
"return true, if such a file exists and is writable." |
|
4841 |
||
2947 | 4842 |
^ OperatingSystem isWritable:(self osNameForFile) |
615 | 4843 |
|
4844 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4845 |
'/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
|
4846 |
'/tmp' asFilename isWritable |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4847 |
'Makefile' asFilename isWritable |
328 | 4848 |
" |
174 | 4849 |
! |
4850 |
||
15574 | 4851 |
isWritableDirectory |
4852 |
"return true, if such a directory exists and is writable. |
|
4853 |
Don't believe #isWritable, since on an NFS mounted filesystem |
|
4854 |
with UID mapping and attribute cache enabled, there may be false negatives." |
|
4855 |
||
4856 |
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
|
4857 |
^ false. |
15574 | 4858 |
]. |
4859 |
||
4860 |
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
|
4861 |
"/ 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
|
4862 |
"/ attribute cache enabled, |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4863 |
"/ 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
|
4864 |
"/ check again... |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4865 |
[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4866 |
|tempFile| |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4867 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4868 |
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
|
4869 |
tempFile close. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4870 |
tempFile fileName remove. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4871 |
] 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
|
4872 |
^ false. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4873 |
]. |
15574 | 4874 |
]. |
4875 |
^ true. |
|
4876 |
||
4877 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4878 |
'/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
|
4879 |
'/tmp' asFilename isWritableDirectory |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4880 |
'/etc' asFilename isWritableDirectory |
15574 | 4881 |
'Makefile' asFilename isWritableDirectory |
4882 |
'/net/exeptn/home2/office' asFilename isWritable |
|
4883 |
'/net/exeptn/home2/office' asFilename isWritableDirectory |
|
4884 |
" |
|
4885 |
! |
|
4886 |
||
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4887 |
separator |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4888 |
"return the directory-separator character" |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4889 |
|
15811 | 4890 |
^ self species separator |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4891 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4892 |
"Modified: 29.2.1996 / 20:52:01 / cg" |
8947 | 4893 |
! |
4894 |
||
11781
6488fd6cc498
Make AutoDeletedFilename work like Filename
Stefan Vogel <sv@exept.de>
parents:
11763
diff
changeset
|
4895 |
species |
15811 | 4896 |
"create only new instances of the concrete OS specific class. |
4897 |
Redefined in AutoDeletedFilename, to not create AutoDeleted instances |
|
4898 |
per default (from directories etc.)" |
|
4899 |
||
4900 |
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
|
4901 |
^ ConcreteClass. |
15811 | 4902 |
] ifFalse:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4903 |
^ self class. |
15811 | 4904 |
]. |
11781
6488fd6cc498
Make AutoDeletedFilename work like Filename
Stefan Vogel <sv@exept.de>
parents:
11763
diff
changeset
|
4905 |
! |
6488fd6cc498
Make AutoDeletedFilename work like Filename
Stefan Vogel <sv@exept.de>
parents:
11763
diff
changeset
|
4906 |
|
8947 | 4907 |
withSpecialExpansions |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4908 |
"return a new filename, expanding any OS specific macros. |
15811 | 4909 |
Here, a ~/ prefix is expanded to the users home dir (as in bash)" |
8947 | 4910 |
|
4911 |
|newName| |
|
4912 |
||
15811 | 4913 |
newName := self species nameWithSpecialExpansions:nameString. |
4914 |
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
|
4915 |
^ self. |
8947 | 4916 |
]. |
15811 | 4917 |
^ self species named:newName. |
8947 | 4918 |
|
4919 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4920 |
'~' asFilename withSpecialExpansions |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4921 |
'~/Desktop' asFilename withSpecialExpansions |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4922 |
'~stefan' asFilename withSpecialExpansions |
15811 | 4923 |
'~stefan/Desktop' asFilename withSpecialExpansions |
8947 | 4924 |
" |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4925 |
! ! |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4926 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4927 |
!Filename methodsFor:'queries-contents'! |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4928 |
|
7291 | 4929 |
mimeTypeFromName |
16578 | 4930 |
"return the mimeType as guessed from the file's name/and or extension. |
7291 | 4931 |
This could be less accurate than mimeTypeOfContents, but avoids |
4932 |
reading the file (is therefore much faster). |
|
4933 |
Also it works with non-existing files. |
|
4934 |
Returns nil for directories and other non-regular files." |
|
4935 |
||
17112 | 4936 |
|mimeTypes| |
4937 |
||
16755 | 4938 |
"/ kludge to avoid making libview a prereq. of libbasic |
17112 | 4939 |
(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
|
4940 |
^ mimeTypes mimeTypeForFilename:(self name) |
16755 | 4941 |
]. |
4942 |
^ nil |
|
7291 | 4943 |
|
4944 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4945 |
'Makefile' asFilename mimeTypeFromName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4946 |
'.' asFilename mimeTypeFromName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4947 |
'/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
|
4948 |
'/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
|
4949 |
'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
|
4950 |
'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
|
4951 |
'../../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
|
4952 |
'/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
|
4953 |
'/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
|
4954 |
'/x.gz' asFilename mimeTypeFromName |
7291 | 4955 |
" |
4956 |
! |
|
4957 |
||
5011 | 4958 |
mimeTypeOfContents |
4959 |
"this tries to guess the mime type of contents of |
|
4960 |
the file. Returns nil, if the file is unreadable, not a plain file |
|
4961 |
or the contents is unknown. |
|
4962 |
This is done using some heuristics, and may need some improvement" |
|
4963 |
||
17111 | 4964 |
|type buffer s size mimeTypes| |
5011 | 4965 |
|
7088
cc3233554827
Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents:
7075
diff
changeset
|
4966 |
type := self type. |
11406
af2c2118e164
refactored - mimetypeofdata now where it belongs to
Claus Gittinger <cg@exept.de>
parents:
11397
diff
changeset
|
4967 |
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
|
4968 |
type == #directory ifTrue:[ ^ nil ]. |
11406
af2c2118e164
refactored - mimetypeofdata now where it belongs to
Claus Gittinger <cg@exept.de>
parents:
11397
diff
changeset
|
4969 |
type == #characterSpecial ifTrue:[ ^ nil ]. |
af2c2118e164
refactored - mimetypeofdata now where it belongs to
Claus Gittinger <cg@exept.de>
parents:
11397
diff
changeset
|
4970 |
type == #blockSpecial ifTrue:[ ^ nil ]. |
af2c2118e164
refactored - mimetypeofdata now where it belongs to
Claus Gittinger <cg@exept.de>
parents:
11397
diff
changeset
|
4971 |
type == #socket ifTrue:[ ^ nil ]. |
5011 | 4972 |
self fileSize == 0 ifTrue:[^ nil]. |
4973 |
||
7088
cc3233554827
Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents:
7075
diff
changeset
|
4974 |
s := self readStreamOrNil. |
cc3233554827
Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents:
7075
diff
changeset
|
4975 |
s isNil ifTrue:[^ nil]. |
cc3233554827
Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents:
7075
diff
changeset
|
4976 |
|
5011 | 4977 |
"/ read some data from the file ... |
7685
535a69a7cd69
String new -> uninitializedNew: / basicNew:
Claus Gittinger <cg@exept.de>
parents:
7680
diff
changeset
|
4978 |
buffer := String new:2048. |
5011 | 4979 |
|
6943
910f4b17c342
care for unreadable contents in mimeTypeOfContents
Claus Gittinger <cg@exept.de>
parents:
6908
diff
changeset
|
4980 |
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
|
4981 |
size := 0. |
6943
910f4b17c342
care for unreadable contents in mimeTypeOfContents
Claus Gittinger <cg@exept.de>
parents:
6908
diff
changeset
|
4982 |
] do:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4983 |
size := s nextBytes:buffer size into:buffer. |
6943
910f4b17c342
care for unreadable contents in mimeTypeOfContents
Claus Gittinger <cg@exept.de>
parents:
6908
diff
changeset
|
4984 |
]. |
5011 | 4985 |
s close. |
11406
af2c2118e164
refactored - mimetypeofdata now where it belongs to
Claus Gittinger <cg@exept.de>
parents:
11397
diff
changeset
|
4986 |
|
16755 | 4987 |
"/ kludge to avoid making libview a prereq. of libbasic |
17111 | 4988 |
(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
|
4989 |
^ mimeTypes mimeTypeOfData:buffer suffix:self suffix. |
16755 | 4990 |
]. |
4991 |
^ nil |
|
5011 | 4992 |
|
4993 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4994 |
'Makefile' asFilename mimeTypeOfContents |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4995 |
'.' asFilename mimeTypeOfContents |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4996 |
'/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
|
4997 |
'/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
|
4998 |
'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
|
4999 |
'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
|
5000 |
'../../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
|
5001 |
'/bläh' asFilename mimeTypeOfContents |
10153 | 5002 |
'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
|
5003 |
'G:\A\A01.TOP' asFilename mimeTypeOfContents |
10153 | 5004 |
" |
5005 |
||
5006 |
"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
|
5007 |
! ! |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5008 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5009 |
!Filename methodsFor:'queries-path & name'! |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5010 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5011 |
baseName |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5012 |
"return my baseName as a string. |
20413 | 5013 |
- that's the file/directory name without leading parent-dirs. |
2922 | 5014 |
(i.e. '/usr/lib/st/file' asFilename baseName -> 'file' |
5015 |
and '/usr/lib' asFilename baseName -> lib). |
|
7075 | 5016 |
This method does not check if the path is valid. |
5017 |
The code here should work for Unix and MSDOS, but needs to be redefined |
|
5018 |
for VMS (and maybe others as well). |
|
2911 | 5019 |
See also: #pathName, #directoryName and #directoryPathName. |
5020 |
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
|
5021 |
|
2922 | 5022 |
|len index sep endIdx| |
5023 |
||
5024 |
sep := self separator. |
|
5025 |
len := nameString size. |
|
5026 |
((len == 1) and:[(nameString at:1) == sep]) ifTrue:[ |
|
20413 | 5027 |
^ nameString |
2922 | 5028 |
]. |
5029 |
||
5030 |
endIdx := len. |
|
5031 |
len > 1 ifTrue:[ |
|
20413 | 5032 |
(nameString at:len) == sep ifTrue:[endIdx := endIdx - 1]. |
2922 | 5033 |
]. |
5034 |
index := nameString lastIndexOf:sep startingAt:len-1. |
|
5035 |
^ 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
|
5036 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5037 |
" |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5038 |
'/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
|
5039 |
'/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
|
5040 |
'.' asFilename baseName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5041 |
'..' asFilename baseName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5042 |
'../..' asFilename baseName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5043 |
'../../libbasic' asFilename baseName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5044 |
'../../libpr' asFilename baseName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5045 |
'../../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
|
5046 |
'/' asFilename baseName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5047 |
'\' asFilename baseName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5048 |
'c:\' asFilename baseName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5049 |
'\\idefix' asFilename baseName |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5050 |
" |
2012 | 5051 |
|
3851 | 5052 |
"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
|
5053 |
! |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5054 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5055 |
directory |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5056 |
"return the directory name part of the file/directory as a new filename. |
20413 | 5057 |
- that's a filename for the directory where the file/dir represented by |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5058 |
the receiver is contained in. |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5059 |
(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
|
5060 |
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
|
5061 |
|
15811 | 5062 |
^ self species named:(self directoryName) |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5063 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5064 |
" |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5065 |
'/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
|
5066 |
'/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
|
5067 |
'/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
|
5068 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5069 |
'.' asFilename directory |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5070 |
'..' asFilename directory |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5071 |
'../..' asFilename directory |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5072 |
" |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5073 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5074 |
"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
|
5075 |
! |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5076 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5077 |
directoryName |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5078 |
"return the directory name part of the file/directory as a string. |
20413 | 5079 |
- that's the name of the directory where the file/dir represented by |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5080 |
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
|
5081 |
This method does not check if the path is valid. |
2922 | 5082 |
|
5083 |
(i.e. '/usr/lib/st/file' asFilename directoryName -> '/usr/lib/st' |
|
5084 |
and '/usr/lib' asFilename directoryName -> /usr'). |
|
5085 |
||
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5086 |
(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
|
5087 |
a string instead of a Filename instance). |
2922 | 5088 |
|
2012 | 5089 |
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
|
5090 |
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
|
5091 |
|
16389 | 5092 |
|index sep sepString p rest parentDirectoryString| |
2922 | 5093 |
|
5094 |
sep := self separator. |
|
5095 |
sepString := sep asString. |
|
5096 |
(nameString = sepString) ifTrue:[ |
|
20413 | 5097 |
"/ |
5098 |
"/ the trivial '/' case |
|
5099 |
"/ |
|
5100 |
^ sepString |
|
2922 | 5101 |
]. |
5102 |
||
5103 |
"/ |
|
3893 | 5104 |
"/ strip off multiple trailing slashes |
2922 | 5105 |
"/ |
5106 |
p := nameString. |
|
16389 | 5107 |
[p endsWith:sep] whileTrue:[ |
20413 | 5108 |
(p = sepString) ifTrue:[ |
5109 |
^ sepString |
|
5110 |
]. |
|
5111 |
p := p copyButLast:1 |
|
2922 | 5112 |
]. |
5113 |
||
16389 | 5114 |
parentDirectoryString := self class parentDirectoryName. |
5115 |
||
3886
e6efeb877eda
fixed #directory & #directoryName for
Claus Gittinger <cg@exept.de>
parents:
3876
diff
changeset
|
5116 |
"/ strip off trailing components |
3888
a528db31e5c0
had to change #directoryName again - it did not work.
Claus Gittinger <cg@exept.de>
parents:
3886
diff
changeset
|
5117 |
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
|
5118 |
index == 0 ifTrue:[ |
20413 | 5119 |
"/ no separator found |
5120 |
p = '.' ifTrue:[ |
|
5121 |
^ parentDirectoryString |
|
5122 |
]. |
|
5123 |
p = '..' ifTrue:[ |
|
5124 |
^ parentDirectoryString, sepString, parentDirectoryString |
|
5125 |
]. |
|
5126 |
^ '.' |
|
2922 | 5127 |
]. |
3888
a528db31e5c0
had to change #directoryName again - it did not work.
Claus Gittinger <cg@exept.de>
parents:
3886
diff
changeset
|
5128 |
rest := p copyFrom:(index+1). |
7342
4e9ff418113f
fixed for directory name ending with '/..'
Claus Gittinger <cg@exept.de>
parents:
7332
diff
changeset
|
5129 |
(rest = '.') ifTrue:[ |
20413 | 5130 |
^ p copyTo:index-1. |
7342
4e9ff418113f
fixed for directory name ending with '/..'
Claus Gittinger <cg@exept.de>
parents:
7332
diff
changeset
|
5131 |
]. |
16389 | 5132 |
(rest = parentDirectoryString) ifTrue:[ |
20413 | 5133 |
^ (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
|
5134 |
]. |
3893 | 5135 |
index == 1 ifTrue:[ |
20413 | 5136 |
^ sepString |
3893 | 5137 |
]. |
3888
a528db31e5c0
had to change #directoryName again - it did not work.
Claus Gittinger <cg@exept.de>
parents:
3886
diff
changeset
|
5138 |
^ p copyTo:(index - 1) |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5139 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5140 |
" |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5141 |
'/home' asFilename directoryName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5142 |
'/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
|
5143 |
'/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
|
5144 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5145 |
'/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
|
5146 |
'bitmaps' asFilename directoryName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5147 |
'bitmaps' asFilename directoryPathName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5148 |
'.' asFilename directoryName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5149 |
'.' asFilename directoryPathName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5150 |
'..' asFilename directoryName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5151 |
'..' asFilename directoryPathName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5152 |
'../..' asFilename directoryName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5153 |
'../..' asFilename directoryPathName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5154 |
'/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
|
5155 |
'/foo/bar/baz/.' asFilename directoryName |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5156 |
" |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5157 |
|
3886
e6efeb877eda
fixed #directory & #directoryName for
Claus Gittinger <cg@exept.de>
parents:
3876
diff
changeset
|
5158 |
"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
|
5159 |
"Modified: / 21.10.1998 / 22:52:25 / cg" |
3893 | 5160 |
"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
|
5161 |
! |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5162 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5163 |
directoryPathName |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5164 |
"return the full directory pathname part of the file/directory as a string. |
20413 | 5165 |
- that's the full pathname of the directory where the file/dir represented by |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5166 |
the receiver is contained in. |
2012 | 5167 |
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
|
5168 |
|
15811 | 5169 |
^ (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
|
5170 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5171 |
" |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5172 |
'/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
|
5173 |
'/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
|
5174 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5175 |
'.' asFilename directoryPathName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5176 |
'.' asFilename directoryName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5177 |
'.' asFilename directory |
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 |
'..' asFilename directoryPathName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5180 |
'..' asFilename directoryName |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5181 |
'..' asFilename directory |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5182 |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5183 |
'../..' asFilename directoryPathName |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5184 |
" |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5185 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5186 |
"Modified: 7.9.1995 / 10:42:13 / claus" |
2012 | 5187 |
"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
|
5188 |
! |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5189 |
|
14567 | 5190 |
encodedNameString |
5191 |
"answer the name as passed to OS system calls" |
|
5192 |
||
5193 |
^ OperatingSystem encodePath:nameString |
|
5194 |
! |
|
5195 |
||
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5196 |
filenameCompletion |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5197 |
"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
|
5198 |
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
|
5199 |
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
|
5200 |
it returns a collection of matching filename objects, |
19440 | 5201 |
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
|
5202 |
match. |
19440 | 5203 |
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
|
5204 |
If there is only one match, the size of the returned collection is exactly 1, |
19752 | 5205 |
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
|
5206 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5207 |
^ self filenameCompletionIn:nil |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5208 |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5209 |
" |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5210 |
'mak' asFilename filenameCompletion |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5211 |
'Make' asFilename filenameCompletion |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5212 |
'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
|
5213 |
'/u' asFilename filenameCompletion |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5214 |
'../../libpr' asFilename inspect filenameCompletion |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5215 |
" |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5216 |
|
1517 | 5217 |
"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
|
5218 |
! |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5219 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5220 |
filenameCompletionIn:aDirectory |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5221 |
"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
|
5222 |
|
6556
367bc84f51fc
filename completion better if an empty basename is shown
Claus Gittinger <cg@exept.de>
parents:
6529
diff
changeset
|
5223 |
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
|
5224 |
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
|
5225 |
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
|
5226 |
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
|
5227 |
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
|
5228 |
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
|
5229 |
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
|
5230 |
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
|
5231 |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5232 |
|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
|
5233 |
sepString parentString prefix nMatch nm caseless lcBaseName| |
3666 | 5234 |
|
15811 | 5235 |
mySpecies := self species. |
5236 |
||
5237 |
caseless := mySpecies isCaseSensitive not. |
|
6556
367bc84f51fc
filename completion better if an empty basename is shown
Claus Gittinger <cg@exept.de>
parents:
6529
diff
changeset
|
5238 |
matching := OrderedCollection new. |
367bc84f51fc
filename completion better if an empty basename is shown
Claus Gittinger <cg@exept.de>
parents:
6529
diff
changeset
|
5239 |
|
15811 | 5240 |
nm := mySpecies nameWithSpecialExpansions:nameString. |
5241 |
nm := mySpecies canonicalize:nm. |
|
5242 |
||
5243 |
sepString := mySpecies separatorString. |
|
3666 | 5244 |
(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
|
5245 |
"/ two exceptions here: |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5246 |
"/ 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
|
5247 |
"/ 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
|
5248 |
self isDirectory ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5249 |
|first longest| |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5250 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5251 |
first := nil. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5252 |
OpenError catch:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5253 |
self directoryContentsDo:[:fileName | |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5254 |
((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
|
5255 |
matching add:fileName. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5256 |
first isNil ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5257 |
first := longest := fileName. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5258 |
] ifFalse:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5259 |
"/ 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
|
5260 |
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
|
5261 |
longest isEmpty ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5262 |
^ #() |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5263 |
]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5264 |
] |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5265 |
] |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5266 |
]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5267 |
]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5268 |
longest notNil ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5269 |
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
|
5270 |
^ matching |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5271 |
]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5272 |
]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5273 |
^ #() |
1049
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 |
|
15811 | 5276 |
parentString := mySpecies parentDirectoryName. |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5277 |
baseName := self baseName. |
3666 | 5278 |
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
|
5279 |
prefix := self directoryName. |
1049
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 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5282 |
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
|
5283 |
dir := self directory |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5284 |
] ifFalse:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5285 |
aDirectory isNil ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5286 |
dir := self directory |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5287 |
] ifFalse:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5288 |
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
|
5289 |
] |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5290 |
]. |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5291 |
|
3774
e2a75c79c625
ignore case in fileNameCompletion, on systems where case is ignored
Claus Gittinger <cg@exept.de>
parents:
3768
diff
changeset
|
5292 |
caseless ifTrue:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5293 |
lcBaseName := baseName asLowercase |
3774
e2a75c79c625
ignore case in fileNameCompletion, on systems where case is ignored
Claus Gittinger <cg@exept.de>
parents:
3768
diff
changeset
|
5294 |
]. |
e2a75c79c625
ignore case in fileNameCompletion, on systems where case is ignored
Claus Gittinger <cg@exept.de>
parents:
3768
diff
changeset
|
5295 |
|
2978
e466e478fa43
Handle errors in #filenameCompletion:
Stefan Vogel <sv@exept.de>
parents:
2977
diff
changeset
|
5296 |
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
|
5297 |
^ #(). |
2978
e466e478fa43
Handle errors in #filenameCompletion:
Stefan Vogel <sv@exept.de>
parents:
2977
diff
changeset
|
5298 |
] do:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5299 |
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
|
5300 |
((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
|
5301 |
((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
|
5302 |
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
|
5303 |
matching add:fileName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5304 |
] |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5305 |
] |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5306 |
]. |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5307 |
]. |
6556
367bc84f51fc
filename completion better if an empty basename is shown
Claus Gittinger <cg@exept.de>
parents:
6529
diff
changeset
|
5308 |
|
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5309 |
(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
|
5310 |
" |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5311 |
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
|
5312 |
" |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5313 |
matchLen := baseName size. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5314 |
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
|
5315 |
try := baseName. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5316 |
allMatching := false |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5317 |
] ifFalse:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5318 |
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
|
5319 |
allMatching := true. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5320 |
]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5321 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5322 |
[allMatching] whileTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5323 |
matching do:[:aName | |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5324 |
((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
|
5325 |
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
|
5326 |
allMatching := false |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5327 |
] |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5328 |
]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5329 |
allMatching ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5330 |
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
|
5331 |
matchLen := matchLen + 1. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5332 |
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
|
5333 |
] ifFalse:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5334 |
allMatching := false |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5335 |
] |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5336 |
] ifFalse:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5337 |
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
|
5338 |
] |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5339 |
]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5340 |
" |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5341 |
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
|
5342 |
" |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5343 |
nameString := nm := try |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5344 |
]. |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5345 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5346 |
" |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5347 |
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
|
5348 |
" |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5349 |
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
|
5350 |
(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
|
5351 |
"/ 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
|
5352 |
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
|
5353 |
]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5354 |
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
|
5355 |
nMatch == 1 ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5356 |
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
|
5357 |
] ifFalse:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5358 |
nMatch > 1 ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5359 |
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
|
5360 |
] |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5361 |
] |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5362 |
] ifFalse:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5363 |
nMatch == 1 ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5364 |
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
|
5365 |
] |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5366 |
]. |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5367 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5368 |
" |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5369 |
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
|
5370 |
(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
|
5371 |
" |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5372 |
^ matching |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5373 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5374 |
" trivial cases: |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5375 |
|
11341
22494c109161
fixed filename completion for root directories (added another sep-char)
Claus Gittinger <cg@exept.de>
parents:
11192
diff
changeset
|
5376 |
'../' asFilename filenameCompletion -> empty |
22494c109161
fixed filename completion for root directories (added another sep-char)
Claus Gittinger <cg@exept.de>
parents:
11192
diff
changeset
|
5377 |
'/' asFilename filenameCompletion -> empty |
22494c109161
fixed filename completion for root directories (added another sep-char)
Claus Gittinger <cg@exept.de>
parents:
11192
diff
changeset
|
5378 |
'/usr/' asFilename filenameCompletion -> empty |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5379 |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5380 |
'mak' asFilename filenameCompletion |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5381 |
'Make' asFilename filenameCompletion |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5382 |
'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
|
5383 |
'/u' asFilename filenameCompletion |
7088
cc3233554827
Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents:
7075
diff
changeset
|
5384 |
'../../libpr' asFilename filenameCompletion |
cc3233554827
Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents:
7075
diff
changeset
|
5385 |
'/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
|
5386 |
|
22494c109161
fixed filename completion for root directories (added another sep-char)
Claus Gittinger <cg@exept.de>
parents:
11192
diff
changeset
|
5387 |
'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
|
5388 |
'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
|
5389 |
'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
|
5390 |
'c:\' asFilename filenameCompletion -> empty |
22494c109161
fixed filename completion for root directories (added another sep-char)
Claus Gittinger <cg@exept.de>
parents:
11192
diff
changeset
|
5391 |
'c:' asFilename filenameCompletion -> empty |
22494c109161
fixed filename completion for root directories (added another sep-char)
Claus Gittinger <cg@exept.de>
parents:
11192
diff
changeset
|
5392 |
'\' asFilename filenameCompletion -> empty |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5393 |
" |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5394 |
|
10793
0475c364e80a
care for bad (non-filename) arg in fileNameCompletion:
Claus Gittinger <cg@exept.de>
parents:
10780
diff
changeset
|
5395 |
"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
|
5396 |
"Modified: / 17-11-2007 / 14:31:08 / cg" |
2903 | 5397 |
! |
5398 |
||
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5399 |
head |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5400 |
"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
|
5401 |
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
|
5402 |
(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
|
5403 |
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
|
5404 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5405 |
^ self directoryName |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5406 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5407 |
" |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5408 |
Filename currentDirectory head |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5409 |
'Makefile' asFilename head |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5410 |
'/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
|
5411 |
" |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5412 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5413 |
"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
|
5414 |
! |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5415 |
|
7120 | 5416 |
isAbsolute |
5417 |
"return true, if the receiver represents an absolute pathname |
|
5418 |
(in contrast to one relative to the current directory)." |
|
5419 |
||
19670 | 5420 |
((nameString startsWith:self species separator) or:[nameString startsWith:$~]) ifTrue:[^ true]. |
7120 | 5421 |
^ self isVolumeAbsolute |
5422 |
||
5423 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5424 |
'/foo/bar' asFilename isAbsolute |
14220
2a3457b016be
Fix the '~/dir/name' resolution fow windows
Stefan Vogel <sv@exept.de>
parents:
14218
diff
changeset
|
5425 |
'~/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
|
5426 |
'..' asFilename isAbsolute |
20459 | 5427 |
'..' asFilename asAbsoluteFilename isAbsolute |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5428 |
'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
|
5429 |
'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
|
5430 |
'SBrowser.st' asFilename isRelative |
7120 | 5431 |
" |
5432 |
! |
|
5433 |
||
5434 |
isExplicitRelative |
|
5435 |
"return true, if this name is an explicit relative name |
|
5436 |
(i.e. starts with './' or '../', to avoid path-prepending)" |
|
5437 |
||
5438 |
^ false |
|
5439 |
! |
|
5440 |
||
5441 |
isImplicit |
|
5442 |
"return true, if the receiver represents a builtin file. |
|
5443 |
The definitions of builtin files depends on the OS used; |
|
5444 |
on UNIX, '.' and '..' are builtin names." |
|
5445 |
||
5446 |
^ false |
|
5447 |
||
5448 |
"Created: 18.9.1997 / 18:04:51 / stefan" |
|
5449 |
! |
|
5450 |
||
6773
26415b61ad09
isMountPoint & isParentDirectoryOf & allParentDirsDo:
penk
parents:
6771
diff
changeset
|
5451 |
isParentDirectoryOf:aFilenameOrString |
16389 | 5452 |
"Answer true, if myself is a parent directory of aFilenameOrString. |
5453 |
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
|
5454 |
not exist and relative and absolute path names are mixed |
18686 | 5455 |
('/' asFilename isParentDirectoryOf:'../noExistent' -> false) |
16389 | 5456 |
|
5457 |
Warning: maybe symbolic links must be resolved which could lead to automounting" |
|
5458 |
||
5459 |
|filenameArg otherNames myNames myName| |
|
6773
26415b61ad09
isMountPoint & isParentDirectoryOf & allParentDirsDo:
penk
parents:
6771
diff
changeset
|
5460 |
|
7236
2b8b8680f5b9
isParentDirectoryOf - fix for directories
Claus Gittinger <cg@exept.de>
parents:
7134
diff
changeset
|
5461 |
filenameArg := aFilenameOrString asFilename. |
16389 | 5462 |
|
5463 |
"first do a simple comparison" |
|
5464 |
otherNames := self class canonicalizedNameComponents:filenameArg name. |
|
5465 |
myNames := self class canonicalizedNameComponents:self name. |
|
5466 |
((otherNames startsWith:myNames) and:[myNames first ~= self class parentDirectoryName]) ifTrue:[ |
|
19599 | 5467 |
^ otherNames ~= myNames |
7236
2b8b8680f5b9
isParentDirectoryOf - fix for directories
Claus Gittinger <cg@exept.de>
parents:
7134
diff
changeset
|
5468 |
]. |
6773
26415b61ad09
isMountPoint & isParentDirectoryOf & allParentDirsDo:
penk
parents:
6771
diff
changeset
|
5469 |
|
16389 | 5470 |
"fall back - try it again with ~ substitution and symbolic links resolved" |
5471 |
otherNames := self class canonicalizedNameComponents:filenameArg pathName. |
|
5472 |
myNames := self class canonicalizedNameComponents:self pathName. |
|
5473 |
(otherNames startsWith:myNames) ifTrue:[ |
|
19599 | 5474 |
^ otherNames ~= myNames |
6773
26415b61ad09
isMountPoint & isParentDirectoryOf & allParentDirsDo:
penk
parents:
6771
diff
changeset
|
5475 |
]. |
26415b61ad09
isMountPoint & isParentDirectoryOf & allParentDirsDo:
penk
parents:
6771
diff
changeset
|
5476 |
|
16389 | 5477 |
myName := self class nameFromComponents:myNames. |
6773
26415b61ad09
isMountPoint & isParentDirectoryOf & allParentDirsDo:
penk
parents:
6771
diff
changeset
|
5478 |
filenameArg allParentDirectoriesDo:[:parent | |
19599 | 5479 |
parent pathName = myName ifTrue:[^ true]. |
6773
26415b61ad09
isMountPoint & isParentDirectoryOf & allParentDirsDo:
penk
parents:
6771
diff
changeset
|
5480 |
]. |
26415b61ad09
isMountPoint & isParentDirectoryOf & allParentDirsDo:
penk
parents:
6771
diff
changeset
|
5481 |
^ false. |
26415b61ad09
isMountPoint & isParentDirectoryOf & allParentDirsDo:
penk
parents:
6771
diff
changeset
|
5482 |
|
26415b61ad09
isMountPoint & isParentDirectoryOf & allParentDirsDo:
penk
parents:
6771
diff
changeset
|
5483 |
" |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5484 |
'/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
|
5485 |
'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
|
5486 |
'/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
|
5487 |
'/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
|
5488 |
'/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
|
5489 |
'/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
|
5490 |
'~' 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
|
5491 |
'~' asFilename isParentDirectoryOf:'.' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5492 |
'~' asFilename isParentDirectoryOf:'..' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5493 |
'~' asFilename isParentDirectoryOf:'../smalltalk' |
18686 | 5494 |
'../..' asFilename isParentDirectoryOf:'../nonExistent' |
5495 |
'..' asFilename isParentDirectoryOf:'../../nonExistent' |
|
5496 |
'/' 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
|
5497 |
'/' 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
|
5498 |
" |
6773
26415b61ad09
isMountPoint & isParentDirectoryOf & allParentDirsDo:
penk
parents:
6771
diff
changeset
|
5499 |
! |
26415b61ad09
isMountPoint & isParentDirectoryOf & allParentDirsDo:
penk
parents:
6771
diff
changeset
|
5500 |
|
7120 | 5501 |
isRelative |
5502 |
"return true, if this name is interpreted relative to some |
|
5503 |
directory (opposite of absolute)" |
|
5504 |
||
5505 |
^ self isAbsolute not |
|
5506 |
||
5507 |
" |
|
5508 |
'./foo/bar' asFilename isRelative |
|
5509 |
'../../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
|
5510 |
'/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
|
5511 |
'bar' asFilename isRelative |
7120 | 5512 |
" |
5513 |
||
5514 |
"Modified: 16.1.1997 / 01:19:14 / cg" |
|
5515 |
! |
|
5516 |
||
5517 |
isRootDirectory |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5518 |
"return true, if I represent the root directory |
7120 | 5519 |
(i.e. I have no parentDir)" |
5520 |
||
5521 |
"/ mhmh - should we use: |
|
5522 |
"/ |
|
5523 |
"/ parentDir := self construct:'..'. |
|
5524 |
"/ (parentDir exists |
|
5525 |
"/ and:[parentDir isDirectory |
|
5526 |
"/ and:[parentDir id ~= self id]]) ifTrue:[ |
|
5527 |
"/ ^ false |
|
5528 |
"/ ]. |
|
5529 |
"/ ^ true |
|
5530 |
"/ |
|
5531 |
||
5532 |
^ self pathName = Filename rootDirectory pathName |
|
5533 |
||
5534 |
"Modified: 23.10.1997 / 00:38:35 / cg" |
|
5535 |
! |
|
5536 |
||
5537 |
isVolumeAbsolute |
|
5538 |
"return true, if the receiver represents an absolute pathname |
|
5539 |
on some disk volume (MSDOS only)" |
|
5540 |
||
5541 |
^ false |
|
5542 |
||
5543 |
"Modified: 7.9.1997 / 23:54:33 / cg" |
|
5544 |
! |
|
5545 |
||
2987
87a7ad1f4519
Simplify #accessTime and #modificationTime
Stefan Vogel <sv@exept.de>
parents:
2982
diff
changeset
|
5546 |
localPathName |
87a7ad1f4519
Simplify #accessTime and #modificationTime
Stefan Vogel <sv@exept.de>
parents:
2982
diff
changeset
|
5547 |
"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
|
5548 |
but without any volume information. |
87a7ad1f4519
Simplify #accessTime and #modificationTime
Stefan Vogel <sv@exept.de>
parents:
2982
diff
changeset
|
5549 |
Only makes a difference on MSDOS & VMS systems." |
87a7ad1f4519
Simplify #accessTime and #modificationTime
Stefan Vogel <sv@exept.de>
parents:
2982
diff
changeset
|
5550 |
|
87a7ad1f4519
Simplify #accessTime and #modificationTime
Stefan Vogel <sv@exept.de>
parents:
2982
diff
changeset
|
5551 |
^ self pathName |
87a7ad1f4519
Simplify #accessTime and #modificationTime
Stefan Vogel <sv@exept.de>
parents:
2982
diff
changeset
|
5552 |
! |
87a7ad1f4519
Simplify #accessTime and #modificationTime
Stefan Vogel <sv@exept.de>
parents:
2982
diff
changeset
|
5553 |
|
615 | 5554 |
name |
5555 |
"return the name of the file represented by the receiver as a string. |
|
883 | 5556 |
This may or may not be a relative name (i.e. include ..'s). |
615 | 5557 |
See also: pathName" |
174 | 5558 |
|
6773
26415b61ad09
isMountPoint & isParentDirectoryOf & allParentDirsDo:
penk
parents:
6771
diff
changeset
|
5559 |
"/ self isAbsolute ifTrue:[^ self pathName]. |
615 | 5560 |
^ nameString |
174 | 5561 |
|
5562 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5563 |
'/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
|
5564 |
'/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
|
5565 |
'.' asFilename name |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5566 |
'.' asFilename pathName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5567 |
'../..' asFilename name |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5568 |
'../..' asFilename pathName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5569 |
'bitmaps' asFilename name |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5570 |
'bitmaps' asFilename pathName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5571 |
'/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
|
5572 |
'/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
|
5573 |
'source/..' asFilename name |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5574 |
'source/..' asFilename pathName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5575 |
'/tmp/..' asFilename name |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5576 |
'/tmp/..' asFilename pathName |
92 | 5577 |
" |
538
b9337c6c55bb
added recursiveRemove; remove now also removes directories
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
5578 |
|
883 | 5579 |
"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
|
5580 |
! |
b9337c6c55bb
added recursiveRemove; remove now also removes directories
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
5581 |
|
7308 | 5582 |
nameString |
5583 |
"raw access to nameString - req'd for xml-store/reload" |
|
5584 |
||
5585 |
^ nameString |
|
5586 |
! |
|
5587 |
||
5588 |
nameString:aString |
|
5589 |
"raw access to nameString - req'd for xml-store/reload" |
|
5590 |
||
5591 |
nameString := aString |
|
5592 |
! |
|
5593 |
||
615 | 5594 |
pathName |
5595 |
"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
|
5596 |
as a string. This will not include ..'s. |
1317 | 5597 |
If the path represented by the receiver does NOT represent a valid path, |
5598 |
no compression will be done (for now; this may change). |
|
5599 |
See also: name" |
|
538
b9337c6c55bb
added recursiveRemove; remove now also removes directories
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
5600 |
|
b9337c6c55bb
added recursiveRemove; remove now also removes directories
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
5601 |
|
1317 | 5602 |
"/ sep := self class separator. |
5603 |
"/ (nameString startsWith:sep) ifTrue:[ |
|
5604 |
"/ parentName := self class parentDirectoryName. |
|
5605 |
"/ (nameString findString:parentName) == 0 ifTrue:[ |
|
5606 |
"/ ^ nameString |
|
5607 |
"/ ] |
|
5608 |
"/ ]. |
|
15811 | 5609 |
^ OperatingSystem pathNameOf:(self species nameWithSpecialExpansions:nameString). |
2 | 5610 |
|
92 | 5611 |
" |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5612 |
'/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
|
5613 |
'.' asFilename pathName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5614 |
'../..' asFilename pathName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5615 |
'../..' asFilename name |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5616 |
'/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
|
5617 |
'/././usr' asFilename pathName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5618 |
'~/..' asFilename pathName |
92 | 5619 |
" |
159 | 5620 |
|
1317 | 5621 |
"Modified: 27.4.1996 / 18:19:52 / cg" |
174 | 5622 |
! |
5623 |
||
11658 | 5624 |
physicalFilename |
5625 |
"return the fileName representing the physical file as represented by the receiver, |
|
20413 | 5626 |
If the receiver represents a symbolic link, that's the fileName of the |
19440 | 5627 |
final target. Otherwise, its the receiver's pathName itself. |
11658 | 5628 |
If any file along the symbolic path does not exist (i.e. is a broken link), |
5629 |
nil is returned." |
|
5630 |
||
5631 |
|pathOrNil| |
|
5632 |
||
5633 |
pathOrNil := self physicalPathName. |
|
5634 |
pathOrNil isNil ifTrue:[ |
|
20413 | 5635 |
^ nil |
11658 | 5636 |
]. |
5637 |
^ pathOrNil asFilename |
|
5638 |
||
5639 |
" |
|
20708 | 5640 |
'/foo/bar' asFilename physicalFilename |
11658 | 5641 |
" |
5642 |
! |
|
5643 |
||
2013
5053effe0156
commentary; added #physicalPathName
Claus Gittinger <cg@exept.de>
parents:
2012
diff
changeset
|
5644 |
physicalPathName |
5053effe0156
commentary; added #physicalPathName
Claus Gittinger <cg@exept.de>
parents:
2012
diff
changeset
|
5645 |
"return the full pathname of the physical file represented by the receiver, |
20413 | 5646 |
If the receiver represents a symbolic link, that's the fileName of the |
19440 | 5647 |
final target. Otherwise, its the receiver's pathName itself. |
2013
5053effe0156
commentary; added #physicalPathName
Claus Gittinger <cg@exept.de>
parents:
2012
diff
changeset
|
5648 |
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
|
5649 |
nil is returned." |
5053effe0156
commentary; added #physicalPathName
Claus Gittinger <cg@exept.de>
parents:
2012
diff
changeset
|
5650 |
|
8477
c962d56c1973
#linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents:
8280
diff
changeset
|
5651 |
|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
|
5652 |
|
c962d56c1973
#linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents:
8280
diff
changeset
|
5653 |
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
|
5654 |
info isNil ifTrue:[ |
20413 | 5655 |
" I do not exist" |
5656 |
^ nil. |
|
2013
5053effe0156
commentary; added #physicalPathName
Claus Gittinger <cg@exept.de>
parents:
2012
diff
changeset
|
5657 |
]. |
8477
c962d56c1973
#linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents:
8280
diff
changeset
|
5658 |
info isSymbolicLink ifFalse:[ |
20413 | 5659 |
^ 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
|
5660 |
]. |
c962d56c1973
#linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents:
8280
diff
changeset
|
5661 |
|
2013
5053effe0156
commentary; added #physicalPathName
Claus Gittinger <cg@exept.de>
parents:
2012
diff
changeset
|
5662 |
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
|
5663 |
[ |
20413 | 5664 |
path := info path. |
5665 |
path isNil ifTrue:[ |
|
5666 |
"/ cannot happen |
|
5667 |
^ nil |
|
5668 |
]. |
|
5669 |
path asFilename isAbsolute ifTrue:[ |
|
5670 |
t := path asFilename |
|
5671 |
] ifFalse:[ |
|
5672 |
t := (self species named:t directoryName) construct:path. |
|
5673 |
]. |
|
5674 |
info := t linkInfo. |
|
5675 |
info isNil ifTrue:[ |
|
5676 |
"t does not exist" |
|
5677 |
^ nil |
|
5678 |
]. |
|
8477
c962d56c1973
#linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents:
8280
diff
changeset
|
5679 |
] 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
|
5680 |
|
2013
5053effe0156
commentary; added #physicalPathName
Claus Gittinger <cg@exept.de>
parents:
2012
diff
changeset
|
5681 |
^ t pathName |
5053effe0156
commentary; added #physicalPathName
Claus Gittinger <cg@exept.de>
parents:
2012
diff
changeset
|
5682 |
|
5053effe0156
commentary; added #physicalPathName
Claus Gittinger <cg@exept.de>
parents:
2012
diff
changeset
|
5683 |
" |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5684 |
'/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
|
5685 |
'.' asFilename physicalPathName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5686 |
'../..' asFilename physicalPathName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5687 |
'/usr/tmp' asFilename physicalPathName |
2013
5053effe0156
commentary; added #physicalPathName
Claus Gittinger <cg@exept.de>
parents:
2012
diff
changeset
|
5688 |
" |
5053effe0156
commentary; added #physicalPathName
Claus Gittinger <cg@exept.de>
parents:
2012
diff
changeset
|
5689 |
|
5053effe0156
commentary; added #physicalPathName
Claus Gittinger <cg@exept.de>
parents:
2012
diff
changeset
|
5690 |
"Modified: 21.12.1996 / 15:29:50 / cg" |
5053effe0156
commentary; added #physicalPathName
Claus Gittinger <cg@exept.de>
parents:
2012
diff
changeset
|
5691 |
! |
5053effe0156
commentary; added #physicalPathName
Claus Gittinger <cg@exept.de>
parents:
2012
diff
changeset
|
5692 |
|
615 | 5693 |
tail |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5694 |
"the file's name without directory prefix as a string. |
615 | 5695 |
An alias for baseName, for ST-80 compatiblity." |
174 | 5696 |
|
615 | 5697 |
^ self baseName |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5698 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5699 |
" |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5700 |
Filename currentDirectory tail |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5701 |
'Makefile' asFilename tail |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5702 |
'/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
|
5703 |
" |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5704 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5705 |
"Modified: 29.2.1996 / 20:19:50 / cg" |
2629 | 5706 |
! |
5707 |
||
7307
9cae11d1fea1
new tail: to get the last n path components (as String)
Stefan Vogel <sv@exept.de>
parents:
7291
diff
changeset
|
5708 |
tail:nComponents |
9cae11d1fea1
new tail: to get the last n path components (as String)
Stefan Vogel <sv@exept.de>
parents:
7291
diff
changeset
|
5709 |
"return the last n components of myself. |
20413 | 5710 |
- that's the file/directory name without leading parent-dirs. |
7307
9cae11d1fea1
new tail: to get the last n path components (as String)
Stefan Vogel <sv@exept.de>
parents:
7291
diff
changeset
|
5711 |
(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
|
5712 |
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
|
5713 |
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
|
5714 |
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
|
5715 |
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
|
5716 |
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
|
5717 |
|
9cae11d1fea1
new tail: to get the last n path components (as String)
Stefan Vogel <sv@exept.de>
parents:
7291
diff
changeset
|
5718 |
|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
|
5719 |
|
15811 | 5720 |
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
|
5721 |
components := self components. |
9cae11d1fea1
new tail: to get the last n path components (as String)
Stefan Vogel <sv@exept.de>
parents:
7291
diff
changeset
|
5722 |
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
|
5723 |
start < 1 ifTrue:[ |
20413 | 5724 |
start := 1. |
7307
9cae11d1fea1
new tail: to get the last n path components (as String)
Stefan Vogel <sv@exept.de>
parents:
7291
diff
changeset
|
5725 |
]. |
9cae11d1fea1
new tail: to get the last n path components (as String)
Stefan Vogel <sv@exept.de>
parents:
7291
diff
changeset
|
5726 |
start = 1 ifTrue:[ |
20413 | 5727 |
tail := '' |
7307
9cae11d1fea1
new tail: to get the last n path components (as String)
Stefan Vogel <sv@exept.de>
parents:
7291
diff
changeset
|
5728 |
] ifFalse:[ |
20413 | 5729 |
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
|
5730 |
]. |
9cae11d1fea1
new tail: to get the last n path components (as String)
Stefan Vogel <sv@exept.de>
parents:
7291
diff
changeset
|
5731 |
start+1 to:components size do:[:i| |
20413 | 5732 |
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
|
5733 |
]. |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5734 |
^ tail. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5735 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5736 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5737 |
" |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5738 |
'/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
|
5739 |
'/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
|
5740 |
'/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
|
5741 |
'/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
|
5742 |
'.' asFilename tail:3 |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5743 |
'..' asFilename tail:3 |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5744 |
'../..' asFilename tail:2 |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5745 |
'../../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
|
5746 |
'../../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
|
5747 |
'../../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
|
5748 |
'../../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
|
5749 |
'/' asFilename tail:2 |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5750 |
'\' asFilename tail:2 |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5751 |
'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
|
5752 |
'\\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
|
5753 |
" |
9cae11d1fea1
new tail: to get the last n path components (as String)
Stefan Vogel <sv@exept.de>
parents:
7291
diff
changeset
|
5754 |
! |
9cae11d1fea1
new tail: to get the last n path components (as String)
Stefan Vogel <sv@exept.de>
parents:
7291
diff
changeset
|
5755 |
|
2629 | 5756 |
volume |
5757 |
"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
|
5758 |
This is only used with MSDOS and VMS filenames |
2906 | 5759 |
- by default (and on unix), an empty string is returned" |
5760 |
||
2629 | 5761 |
^ '' |
2906 | 5762 |
|
5763 |
"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
|
5764 |
! ! |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5765 |
|
7120 | 5766 |
!Filename methodsFor:'queries-type'! |
5767 |
||
5768 |
isDirectory |
|
5769 |
"return true, if the receiver represents an existing, |
|
5770 |
readable directories pathname." |
|
5771 |
||
5772 |
^ OperatingSystem isDirectory:(self osNameForAccess) |
|
5773 |
||
5774 |
" |
|
5775 |
'/foo/bar' asFilename isDirectory |
|
5776 |
'/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
|
5777 |
'Makefile' asFilename isDirectory |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5778 |
'c:\' asFilename isDirectory |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5779 |
'd:\' asFilename isDirectory |
7120 | 5780 |
" |
5781 |
||
5782 |
"Modified: / 21.9.1998 / 15:53:10 / cg" |
|
5783 |
! |
|
5784 |
||
5785 |
isNonEmptyDirectory |
|
5786 |
"return true, if the receiver represents an existing, |
|
5787 |
readable directories pathname, and the directory is not empty." |
|
5788 |
||
8280
0caa2f092e45
avoid expensive full-blocks (which return)
Claus Gittinger <cg@exept.de>
parents:
8243
diff
changeset
|
5789 |
FileStream openErrorSignal |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5790 |
handle:[:ex| ] |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5791 |
do:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5792 |
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
|
5793 |
]. |
7120 | 5794 |
^ false. |
5795 |
||
5796 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5797 |
'/foo/bar' asFilename isNonEmptyDirectory |
7120 | 5798 |
'/tmp' asFilename isNonEmptyDirectory |
5799 |
'/tmp/empty' asFilename makeDirectory; isNonEmptyDirectory. |
|
5800 |
'/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
|
5801 |
'Makefile' asFilename isNonEmptyDirectory |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5802 |
'c:\' asFilename isNonEmptyDirectory |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5803 |
'd:\' asFilename isNonEmptyDirectory |
7120 | 5804 |
" |
5805 |
||
5806 |
"Modified: / 21.9.1998 / 15:53:10 / cg" |
|
5807 |
! |
|
5808 |
||
8836 | 5809 |
isRegularFile |
5810 |
"return true, if the receiver represents a plain, regular file" |
|
5811 |
||
5812 |
^ self type == #regular |
|
5813 |
||
5814 |
" |
|
5815 |
'/foo/bar' asFilename isRegularFile |
|
5816 |
'/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
|
5817 |
'Makefile' asFilename isRegularFile |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5818 |
'c:\' asFilename isRegularFile |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5819 |
'd:\' asFilename isRegularFile |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5820 |
'/dev/null' asFilename isRegularFile |
8836 | 5821 |
" |
5822 |
! |
|
5823 |
||
7120 | 5824 |
isSpecialFile |
5825 |
"return true, if the receiver represents a socket, named pipe, fifo |
|
5826 |
or device special file (i.e. anything non regular and non-directory)" |
|
5827 |
||
5828 |
|t| |
|
5829 |
||
5830 |
t := self type. |
|
5831 |
^ (t ~= #directory and:[t ~~ #regular and:[t ~~ #symbolicLink]]) |
|
5832 |
||
5833 |
" |
|
5834 |
'/foo/bar' asFilename isSpecialFile |
|
5835 |
'/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
|
5836 |
'Makefile' asFilename isSpecialFile |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5837 |
'c:\' asFilename isSpecialFile |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5838 |
'd:\' asFilename isSpecialFile |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5839 |
'/dev/null' asFilename isSpecialFile |
7120 | 5840 |
" |
5841 |
! |
|
5842 |
||
5843 |
isSymbolicLink |
|
5844 |
"return true, if the file represented by the receiver is a symbolic |
|
5845 |
link. Notice that not all OS's support symbolic links; those that do |
|
5846 |
not will always return false." |
|
5847 |
||
5848 |
^ OperatingSystem isSymbolicLink:(self osNameForFile) |
|
5849 |
||
5850 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5851 |
'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
|
5852 |
'Makefile' asFilename isSymbolicLink |
7120 | 5853 |
" |
5854 |
! ! |
|
5855 |
||
6529 | 5856 |
!Filename methodsFor:'reading-directories'! |
5857 |
||
5858 |
directoryContents |
|
5859 |
"return the contents of the directory as a collection of strings. |
|
5860 |
This excludes any entries for '.' or '..'. |
|
5861 |
Returns nil for non-existing directories; however, this behavior |
|
5862 |
may be changed in the near future, to raise an exception instead. |
|
5863 |
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
|
5864 |
Notice: |
19821 | 5865 |
this returns the file-names as strings; |
5866 |
see also #directoryContentsAsFilenames, which returns fileName instances." |
|
5867 |
||
5868 |
^ OrderedCollection withCollectedContents:[:coll | |
|
5869 |
self directoryContentsDo:[:each | coll add:each]] |
|
6529 | 5870 |
|
5871 |
" |
|
5872 |
'.' asFilename directoryContents |
|
5873 |
'/XXXdoesNotExist' asFilename directoryContents |
|
5874 |
" |
|
5875 |
||
5876 |
"Modified: / 18.9.1997 / 18:42:23 / stefan" |
|
5877 |
"Modified: / 3.8.1998 / 21:36:21 / cg" |
|
5878 |
! |
|
5879 |
||
5880 |
directoryContentsAsFilenames |
|
5881 |
"return the contents of the directory as a collection of filenames. |
|
5882 |
This excludes any entries for '.' or '..'. |
|
5883 |
Returns nil for non-existing directories; however, this behavior |
|
5884 |
may be changed in the near future, to raise an exception instead. |
|
5885 |
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
|
5886 |
Notice: |
19821 | 5887 |
this returns the file-names as fileName instances; |
5888 |
see also #directoryContents, which returns strings." |
|
5889 |
||
5890 |
^ OrderedCollection withCollectedContents:[:coll | |
|
5891 |
self directoryContentsAsFilenamesDo:[:each | coll add:each]] |
|
6529 | 5892 |
|
5893 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5894 |
'.' asFilename directoryContentsAsFilenames |
6529 | 5895 |
'/XXXdoesNotExist' asFilename directoryContentsAsFilenames |
5896 |
" |
|
5897 |
! |
|
5898 |
||
5899 |
fullDirectoryContents |
|
5900 |
"return the full contents of the directory as a collection of strings. |
|
5901 |
This is much like #directoryContents, but includes an entry for the |
|
5902 |
parent directory, if there is one. |
|
5903 |
Returns nil for non-existing directories; however, this behavior |
|
5904 |
may be changed in the near future, to raise an exception instead. |
|
5905 |
So users of this method better test for existing directory before." |
|
5906 |
||
5907 |
|files| |
|
5908 |
||
12910 | 5909 |
"here we get the files without '.' and '..'" |
6529 | 5910 |
files := self directoryContents. |
5911 |
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
|
5912 |
"/ 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
|
5913 |
^ files |
6529 | 5914 |
]. |
5915 |
||
12910 | 5916 |
files addFirst:'..'. |
6529 | 5917 |
^ files |
5918 |
||
5919 |
" |
|
5920 |
'.' asFilename fullDirectoryContents |
|
5921 |
'/XXXdoesNotExist' asFilename fullDirectoryContents |
|
5922 |
'd:\FET' asFilename fullDirectoryContents |
|
5923 |
" |
|
5924 |
||
5925 |
"Modified: / 21.9.1998 / 15:33:07 / cg" |
|
5926 |
! |
|
5927 |
||
5928 |
recursiveDirectoryContents |
|
5929 |
"return the contents of the directory and all subdirectories |
|
5930 |
as a collection of strings. |
|
5931 |
This excludes any entries for '.' or '..'. |
|
5932 |
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
|
5933 |
Notice: |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5934 |
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
|
5935 |
see also #recursiveDirectoryContentsAsFilenames, which returns fileName instances. |
7697
1cb1a31cd2c2
recursiveDirectoryContentsAsFilenames
Claus Gittinger <cg@exept.de>
parents:
7685
diff
changeset
|
5936 |
|
6529 | 5937 |
Warning: this may take a long time to execute." |
5938 |
||
5939 |
|fileNames dirNames| |
|
5940 |
||
5941 |
fileNames := OrderedCollection new. |
|
5942 |
dirNames := OrderedCollection new. |
|
5943 |
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
|
5944 |
(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
|
5945 |
dirNames add:f |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5946 |
] ifFalse:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5947 |
fileNames add:f |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5948 |
] |
6529 | 5949 |
]. |
5950 |
||
5951 |
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
|
5952 |
|dd subFiles| |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5953 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5954 |
dd := dN asFilename. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5955 |
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
|
5956 |
fileNames addAll:(subFiles collect:[:f | dd constructString:f]) |
6529 | 5957 |
]. |
5958 |
^ fileNames. |
|
5959 |
||
5960 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5961 |
'.' asFilename recursiveDirectoryContents |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5962 |
'../../clients' asFilename recursiveDirectoryContents |
6529 | 5963 |
" |
7697
1cb1a31cd2c2
recursiveDirectoryContentsAsFilenames
Claus Gittinger <cg@exept.de>
parents:
7685
diff
changeset
|
5964 |
! |
1cb1a31cd2c2
recursiveDirectoryContentsAsFilenames
Claus Gittinger <cg@exept.de>
parents:
7685
diff
changeset
|
5965 |
|
1cb1a31cd2c2
recursiveDirectoryContentsAsFilenames
Claus Gittinger <cg@exept.de>
parents:
7685
diff
changeset
|
5966 |
recursiveDirectoryContentsAsFilenames |
1cb1a31cd2c2
recursiveDirectoryContentsAsFilenames
Claus Gittinger <cg@exept.de>
parents:
7685
diff
changeset
|
5967 |
"return the contents of the directory and all subdirectories |
1cb1a31cd2c2
recursiveDirectoryContentsAsFilenames
Claus Gittinger <cg@exept.de>
parents:
7685
diff
changeset
|
5968 |
as a collection of filenames. |
1cb1a31cd2c2
recursiveDirectoryContentsAsFilenames
Claus Gittinger <cg@exept.de>
parents:
7685
diff
changeset
|
5969 |
This excludes any entries for '.' or '..'. |
1cb1a31cd2c2
recursiveDirectoryContentsAsFilenames
Claus Gittinger <cg@exept.de>
parents:
7685
diff
changeset
|
5970 |
Returns nil for non-existing directories; however, this behavior |
1cb1a31cd2c2
recursiveDirectoryContentsAsFilenames
Claus Gittinger <cg@exept.de>
parents:
7685
diff
changeset
|
5971 |
may be changed in the near future, to raise an exception instead. |
1cb1a31cd2c2
recursiveDirectoryContentsAsFilenames
Claus Gittinger <cg@exept.de>
parents:
7685
diff
changeset
|
5972 |
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
|
5973 |
Notice: |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5974 |
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
|
5975 |
see also #recursiveDirectoryContents, which returns strings. |
7697
1cb1a31cd2c2
recursiveDirectoryContentsAsFilenames
Claus Gittinger <cg@exept.de>
parents:
7685
diff
changeset
|
5976 |
|
1cb1a31cd2c2
recursiveDirectoryContentsAsFilenames
Claus Gittinger <cg@exept.de>
parents:
7685
diff
changeset
|
5977 |
Warning: this may take a long time to execute." |
1cb1a31cd2c2
recursiveDirectoryContentsAsFilenames
Claus Gittinger <cg@exept.de>
parents:
7685
diff
changeset
|
5978 |
|
1cb1a31cd2c2
recursiveDirectoryContentsAsFilenames
Claus Gittinger <cg@exept.de>
parents:
7685
diff
changeset
|
5979 |
|names| |
1cb1a31cd2c2
recursiveDirectoryContentsAsFilenames
Claus Gittinger <cg@exept.de>
parents:
7685
diff
changeset
|
5980 |
|
1cb1a31cd2c2
recursiveDirectoryContentsAsFilenames
Claus Gittinger <cg@exept.de>
parents:
7685
diff
changeset
|
5981 |
names := self recursiveDirectoryContents. |
1cb1a31cd2c2
recursiveDirectoryContentsAsFilenames
Claus Gittinger <cg@exept.de>
parents:
7685
diff
changeset
|
5982 |
names isNil ifTrue:[^ nil]. |
12910 | 5983 |
^ names collect:[:entry | self construct:entry]. |
7697
1cb1a31cd2c2
recursiveDirectoryContentsAsFilenames
Claus Gittinger <cg@exept.de>
parents:
7685
diff
changeset
|
5984 |
|
1cb1a31cd2c2
recursiveDirectoryContentsAsFilenames
Claus Gittinger <cg@exept.de>
parents:
7685
diff
changeset
|
5985 |
" |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5986 |
'.' asFilename recursiveDirectoryContentsAsFilenames |
7697
1cb1a31cd2c2
recursiveDirectoryContentsAsFilenames
Claus Gittinger <cg@exept.de>
parents:
7685
diff
changeset
|
5987 |
'/XXXdoesNotExist' asFilename recursiveDirectoryContentsAsFilenames |
1cb1a31cd2c2
recursiveDirectoryContentsAsFilenames
Claus Gittinger <cg@exept.de>
parents:
7685
diff
changeset
|
5988 |
" |
6529 | 5989 |
! ! |
5990 |
||
5991 |
!Filename methodsFor:'reading-files'! |
|
5992 |
||
5993 |
binaryContentsOfEntireFile |
|
5994 |
"return the binary contents of the file (as a byteArray); |
|
7680 | 5995 |
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
|
5996 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5997 |
^ self |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5998 |
readingFileDo:[:s | |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5999 |
|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
|
6000 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6001 |
s binary. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6002 |
nBytes := self fileSize. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6003 |
(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
|
6004 |
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
|
6005 |
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
|
6006 |
n == nBytes ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6007 |
result := bytes |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6008 |
] ifFalse:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6009 |
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
|
6010 |
] |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6011 |
] ifFalse:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6012 |
result := s contentsOfEntireFile |
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 |
result |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6015 |
] |
6529 | 6016 |
|
6017 |
" |
|
6018 |
'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
|
6019 |
'foobar' asFilename binaryContentsOfEntireFile |
6529 | 6020 |
" |
14446
479f02b4c705
changed: #binaryContentsOfEntireFile
Claus Gittinger <cg@exept.de>
parents:
14306
diff
changeset
|
6021 |
|
479f02b4c705
changed: #binaryContentsOfEntireFile
Claus Gittinger <cg@exept.de>
parents:
14306
diff
changeset
|
6022 |
"Modified: / 27-10-2012 / 19:42:07 / cg" |
6529 | 6023 |
! |
6024 |
||
6025 |
contents |
|
20156 | 6026 |
"Return the contents of the file as a collection of lines. |
6027 |
Raise an error if the file is unreadable/non-existing. |
|
6529 | 6028 |
See also #contentsOfEntireFile, which returns a string for textFiles. |
6029 |
CAVEAT: bad naming - but req'd for VW compatibility." |
|
6030 |
||
7888
e76fa60251dc
Remove obsolete nil-checks after opening streams
Stefan Vogel <sv@exept.de>
parents:
7846
diff
changeset
|
6031 |
^ self readingFileDo:[:s | s contents]. |
6529 | 6032 |
|
6033 |
" |
|
6034 |
'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
|
6035 |
'foobar' asFilename contents |
6529 | 6036 |
" |
6037 |
||
6038 |
"Modified: / 2.7.1996 / 12:49:45 / stefan" |
|
6039 |
"Created: / 11.7.1996 / 14:09:11 / cg" |
|
6040 |
"Modified: / 15.10.1998 / 11:41:45 / cg" |
|
6041 |
! |
|
6042 |
||
10780 | 6043 |
contentsAsString |
6044 |
"to compensate for the bad naming, use this to make things explicit. |
|
6045 |
See also #contents, which returns the lines as stringCollection for textFiles." |
|
6046 |
||
11397
872cd41bbe05
oops - contentsAsString was endlessly recursive
Claus Gittinger <cg@exept.de>
parents:
11341
diff
changeset
|
6047 |
^ self contentsOfEntireFile |
872cd41bbe05
oops - contentsAsString was endlessly recursive
Claus Gittinger <cg@exept.de>
parents:
11341
diff
changeset
|
6048 |
|
872cd41bbe05
oops - contentsAsString was endlessly recursive
Claus Gittinger <cg@exept.de>
parents:
11341
diff
changeset
|
6049 |
" |
872cd41bbe05
oops - contentsAsString was endlessly recursive
Claus Gittinger <cg@exept.de>
parents:
11341
diff
changeset
|
6050 |
'Makefile' asFilename contentsAsString |
872cd41bbe05
oops - contentsAsString was endlessly recursive
Claus Gittinger <cg@exept.de>
parents:
11341
diff
changeset
|
6051 |
'foobar' asFilename contentsAsString |
10780 | 6052 |
" |
6053 |
||
6054 |
"Modified: / 02-07-1996 / 12:49:45 / stefan" |
|
6055 |
"Created: / 08-11-2007 / 13:29:59 / cg" |
|
6056 |
! |
|
6057 |
||
6529 | 6058 |
contentsOfEntireFile |
6059 |
"return the contents of the file as a string; |
|
7680 | 6060 |
Raises an error, if the file is unreadable/non-existing. |
6529 | 6061 |
See also #contents, which returns the lines as stringCollection for textFiles. |
6062 |
CAVEAT: bad naming - but req'd for VW compatibility." |
|
6063 |
||
7888
e76fa60251dc
Remove obsolete nil-checks after opening streams
Stefan Vogel <sv@exept.de>
parents:
7846
diff
changeset
|
6064 |
^ self readingFileDo:[:s | s contentsOfEntireFile]. |
6529 | 6065 |
|
6066 |
" |
|
6067 |
'Makefile' asFilename contentsOfEntireFile |
|
19043 | 6068 |
'smalltalk.rc' asFilename contentsOfEntireFile |
6529 | 6069 |
'foobar' asFilename contentsOfEntireFile |
6070 |
" |
|
6071 |
||
6072 |
"Modified: / 2.7.1996 / 12:49:45 / stefan" |
|
6073 |
"Modified: / 15.10.1998 / 11:42:05 / cg" |
|
6074 |
! |
|
6075 |
||
6076 |
readingFileDo:aBlock |
|
20156 | 6077 |
"Create a read stream on the receiver file, evaluate aBlock, passing that stream as arg, |
6078 |
and return the block's value. |
|
7088
cc3233554827
Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents:
7075
diff
changeset
|
6079 |
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
|
6080 |
(old behavior, will vanish:)the block is evaluated with a nil argument. |
6529 | 6081 |
Ensures that the stream is closed." |
6082 |
||
6083 |
|stream result| |
|
6084 |
||
6085 |
stream := self readStream. |
|
6086 |
[ |
|
20156 | 6087 |
result := aBlock value:stream |
6529 | 6088 |
] ensure:[ |
20156 | 6089 |
stream notNil ifTrue:[stream close] |
6529 | 6090 |
]. |
6091 |
^ result |
|
6092 |
||
6093 |
" |
|
6094 |
read the first line from some file: |
|
6095 |
||
6096 |
|rslt| |
|
6097 |
||
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6098 |
rslt := |
20156 | 6099 |
'/etc/passwd' asFilename |
6100 |
readingFileDo:[:s | |
|
6101 |
s nextLine |
|
6102 |
]. |
|
6529 | 6103 |
Transcript showCR:rslt. |
6104 |
" |
|
6105 |
||
6106 |
" |
|
6107 |
find all used shells in /etc/passwd and count their usage: |
|
6108 |
||
6109 |
|rslt| |
|
6110 |
||
6111 |
rslt := |
|
20156 | 6112 |
'/etc/passwd' asFilename |
6113 |
readingFileDo: |
|
6114 |
[:s | |
|
6115 |
|shells| |
|
6116 |
||
6117 |
shells := Bag new. |
|
6118 |
s linesDo: |
|
6119 |
[:line | |
|
6120 |
|parts| |
|
6121 |
||
6122 |
parts := line asCollectionOfSubstringsSeparatedBy:$:. |
|
6123 |
shells add:(parts seventh). |
|
6124 |
]. |
|
6125 |
shells contents |
|
6126 |
]. |
|
6529 | 6127 |
Transcript showCR:rslt. |
6128 |
" |
|
6771 | 6129 |
! |
6130 |
||
6131 |
readingLinesDo:aBlock |
|
20158 | 6132 |
"Create a read stream on the receiver file and |
6771 | 6133 |
evaluate aBlock for each line read from the stream. |
6134 |
If the file cannot be opened, an error is raised. |
|
6135 |
Ensures that the stream is closed." |
|
6136 |
||
6137 |
self readingFileDo:[:stream | |
|
20158 | 6138 |
stream linesDo:aBlock |
6771 | 6139 |
]. |
6140 |
||
6141 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6142 |
'/etc/passwd' asFilename |
20158 | 6143 |
readingLinesDo:[:eachLine | |
6144 |
Transcript showCR:eachLine. |
|
6145 |
]. |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6146 |
" |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6147 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6148 |
" |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6149 |
'/etc/xxxxx' asFilename |
20158 | 6150 |
readingLinesDo:[:eachLine | |
6151 |
Transcript showCR:eachLine. |
|
6152 |
]. |
|
6771 | 6153 |
" |
6529 | 6154 |
! ! |
6155 |
||
2922 | 6156 |
!Filename methodsFor:'special accessing'! |
6157 |
||
6158 |
osName |
|
6159 |
"special - return the OS's name for the receiver." |
|
6160 |
||
6161 |
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
|
6162 |
^ self osNameForDirectory |
2922 | 6163 |
]. |
6164 |
^ self osNameForFile |
|
6165 |
! |
|
6166 |
||
2978
e466e478fa43
Handle errors in #filenameCompletion:
Stefan Vogel <sv@exept.de>
parents:
2977
diff
changeset
|
6167 |
osNameForAccess |
e466e478fa43
Handle errors in #filenameCompletion:
Stefan Vogel <sv@exept.de>
parents:
2977
diff
changeset
|
6168 |
"internal - return the OS's name for the receiver to |
3665 | 6169 |
access its fileInfo. |
6170 |
This may be redefined for systems, where a special suffix must be |
|
6171 |
added in order to access directories (or others) as a file. |
|
6172 |
(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
|
6173 |
|
7064 | 6174 |
^ self osNameForFile |
3665 | 6175 |
|
6176 |
"Modified: / 21.7.1998 / 10:40:40 / cg" |
|
2978
e466e478fa43
Handle errors in #filenameCompletion:
Stefan Vogel <sv@exept.de>
parents:
2977
diff
changeset
|
6177 |
! |
e466e478fa43
Handle errors in #filenameCompletion:
Stefan Vogel <sv@exept.de>
parents:
2977
diff
changeset
|
6178 |
|
2922 | 6179 |
osNameForDirectory |
3753 | 6180 |
"internal - return the OS's name for the receiver to |
2922 | 6181 |
access it as a directory." |
6182 |
||
14218 | 6183 |
^ self osNameForFile |
3753 | 6184 |
|
6185 |
"Modified: / 12.8.1998 / 14:44:32 / cg" |
|
2922 | 6186 |
! |
6187 |
||
3720
d2529646d235
oops - needed a kludge to read the top directory under win32
Claus Gittinger <cg@exept.de>
parents:
3719
diff
changeset
|
6188 |
osNameForDirectoryContents |
3753 | 6189 |
"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
|
6190 |
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
|
6191 |
|
d2529646d235
oops - needed a kludge to read the top directory under win32
Claus Gittinger <cg@exept.de>
parents:
3719
diff
changeset
|
6192 |
^ self osNameForDirectory |
d2529646d235
oops - needed a kludge to read the top directory under win32
Claus Gittinger <cg@exept.de>
parents:
3719
diff
changeset
|
6193 |
|
d2529646d235
oops - needed a kludge to read the top directory under win32
Claus Gittinger <cg@exept.de>
parents:
3719
diff
changeset
|
6194 |
"Created: / 3.8.1998 / 21:36:06 / cg" |
3753 | 6195 |
"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
|
6196 |
! |
d2529646d235
oops - needed a kludge to read the top directory under win32
Claus Gittinger <cg@exept.de>
parents:
3719
diff
changeset
|
6197 |
|
2922 | 6198 |
osNameForFile |
6199 |
"internal - return the OS's name for the receiver to |
|
6200 |
access it as a file." |
|
6201 |
||
19670 | 6202 |
(nameString startsWith:$~) ifFalse:[ |
6203 |
^ nameString. |
|
14220
2a3457b016be
Fix the '~/dir/name' resolution fow windows
Stefan Vogel <sv@exept.de>
parents:
14218
diff
changeset
|
6204 |
]. |
2a3457b016be
Fix the '~/dir/name' resolution fow windows
Stefan Vogel <sv@exept.de>
parents:
14218
diff
changeset
|
6205 |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6206 |
^ self species nameWithSpecialExpansions:nameString. |
2922 | 6207 |
! ! |
6208 |
||
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
6209 |
!Filename methodsFor:'suffixes'! |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
6210 |
|
11748 | 6211 |
addSuffix:aSuffix |
19440 | 6212 |
"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
|
6213 |
The new suffix is simply appended to the name, |
14306
f41ca29d9b54
comment/format in: #addSuffix:
Stefan Vogel <sv@exept.de>
parents:
14232
diff
changeset
|
6214 |
regardless whether there is already an existing suffix. |
f41ca29d9b54
comment/format in: #addSuffix:
Stefan Vogel <sv@exept.de>
parents:
14232
diff
changeset
|
6215 |
See also #withSuffix:" |
11748 | 6216 |
|
6217 |
|prefixName| |
|
6218 |
||
6219 |
prefixName := self name. |
|
6220 |
aSuffix isEmptyOrNil ifTrue:[ |
|
19599 | 6221 |
^ self species named:prefixName |
11748 | 6222 |
]. |
6223 |
||
15811 | 6224 |
^ self species named: |
19599 | 6225 |
(prefixName |
6226 |
, self species suffixSeparator asString |
|
6227 |
, aSuffix asString) |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6228 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6229 |
" |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6230 |
'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
|
6231 |
'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
|
6232 |
'.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
|
6233 |
'.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
|
6234 |
'.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
|
6235 |
'.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
|
6236 |
'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
|
6237 |
'.' asFilename addSuffix:nil |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6238 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6239 |
'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
|
6240 |
'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
|
6241 |
'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
|
6242 |
'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
|
6243 |
'.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
|
6244 |
'.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
|
6245 |
'.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
|
6246 |
'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
|
6247 |
'.' asFilename addSuffix:'o' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6248 |
'/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
|
6249 |
'/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
|
6250 |
'/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
|
6251 |
'/foo/bar.c/baz' asFilename addSuffix:'st' |
11748 | 6252 |
" |
6253 |
! |
|
6254 |
||
2906 | 6255 |
hasSuffix:aSuffixString |
6256 |
"return true if my suffix is the same as aString. |
|
6257 |
This cares for systems, where case is ignored in filenames" |
|
6258 |
||
6259 |
|mySuffix| |
|
6260 |
||
6261 |
mySuffix := self suffix. |
|
15811 | 6262 |
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
|
6263 |
^ mySuffix = aSuffixString |
2906 | 6264 |
]. |
6265 |
^ mySuffix asLowercase = aSuffixString asLowercase |
|
6266 |
||
6267 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6268 |
'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
|
6269 |
'abc.ST' asFilename hasSuffix:'st' |
7115
dea26def3167
prefix/suffix definition changed for files beginning with
Claus Gittinger <cg@exept.de>
parents:
7088
diff
changeset
|
6270 |
'.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
|
6271 |
'.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
|
6272 |
'.foorc.sav' asFilename hasSuffix:'sav' |
2906 | 6273 |
" |
6274 |
||
6275 |
"Modified: 7.9.1997 / 02:55:25 / cg" |
|
6276 |
! |
|
6277 |
||
10155 | 6278 |
nameWithoutSuffix |
19440 | 6279 |
"return the receiver's name without the suffix. |
10155 | 6280 |
If the name has no suffix, the original name is returned." |
6281 |
||
6282 |
|nm idx idxFromEnd| |
|
6283 |
||
6284 |
nm := self baseName. |
|
15811 | 6285 |
idx := nm lastIndexOf:(self species suffixSeparator). |
10155 | 6286 |
(idx == 0) ifTrue:[^ nameString]. |
6287 |
"/ be careful: if the name consists only of suffix (i.e '.foo'), |
|
6288 |
"/ the suffix is considered empty. |
|
6289 |
(idx == 1) ifTrue:[^ nameString]. |
|
6290 |
||
6291 |
idxFromEnd := nm size - idx. |
|
6292 |
idx := nameString size - idxFromEnd. |
|
6293 |
||
6294 |
^ nameString copyTo:(idx - 1) |
|
6295 |
||
6296 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6297 |
'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
|
6298 |
'abc' asFilename nameWithoutSuffix |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6299 |
'/abc' asFilename nameWithoutSuffix |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6300 |
'/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
|
6301 |
'./abc' asFilename nameWithoutSuffix |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6302 |
'./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
|
6303 |
'./.abc' asFilename nameWithoutSuffix |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6304 |
'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
|
6305 |
'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
|
6306 |
'.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
|
6307 |
'.b.' asFilename nameWithoutSuffix |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6308 |
'.b' asFilename nameWithoutSuffix |
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.c' asFilename nameWithoutSuffix |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6310 |
'/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
|
6311 |
'/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
|
6312 |
'/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
|
6313 |
'/foo/bar/baz/foo.c/bar.c' asFilename nameWithoutSuffix |
10155 | 6314 |
" |
6315 |
||
6316 |
"Modified: / 07-09-1995 / 11:15:42 / claus" |
|
6317 |
"Created: / 07-11-2006 / 13:55:18 / cg" |
|
6318 |
! |
|
6319 |
||
9453 | 6320 |
prefix |
6321 |
"return my prefix. |
|
6322 |
The suffix is the namepart after the final period character, |
|
6323 |
or the empty string, if the name does not contain a period." |
|
6324 |
||
6325 |
^ self prefixAndSuffix at:1 |
|
6326 |
||
6327 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6328 |
'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
|
6329 |
'abc' asFilename prefix |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6330 |
'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
|
6331 |
'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
|
6332 |
'a.' asFilename prefix |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6333 |
'.a' asFilename prefix |
9453 | 6334 |
" |
6335 |
||
6336 |
"Modified: / 07-09-1995 / 11:09:03 / claus" |
|
6337 |
"Created: / 13-07-2006 / 10:27:19 / fm" |
|
6338 |
! |
|
6339 |
||
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
6340 |
prefixAndSuffix |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
6341 |
"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
|
6342 |
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
|
6343 |
the prefix everything before, except for the period. |
1517 | 6344 |
The directory name part is stripped off (i.e. the returned prefix |
16578 | 6345 |
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
|
6346 |
(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
|
6347 |
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
|
6348 |
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
|
6349 |
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
|
6350 |
'.foorc'. |
1517 | 6351 |
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
|
6352 |
Notice: |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6353 |
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
|
6354 |
the period character as suffixCharacter." |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
6355 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
6356 |
|nm idx| |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
6357 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
6358 |
nm := self baseName. |
15811 | 6359 |
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
|
6360 |
"/ 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
|
6361 |
"/ the suffix is considered empty. |
dea26def3167
prefix/suffix definition changed for files beginning with
Claus Gittinger <cg@exept.de>
parents:
7088
diff
changeset
|
6362 |
((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
|
6363 |
^ Array with:nm with:'' |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
6364 |
]. |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6365 |
^ Array |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6366 |
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
|
6367 |
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
|
6368 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6369 |
" |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6370 |
'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
|
6371 |
'abc' asFilename prefixAndSuffix |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6372 |
'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
|
6373 |
'/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
|
6374 |
'a.' asFilename prefixAndSuffix |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6375 |
'.a' asFilename prefixAndSuffix |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6376 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6377 |
|parts| |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
6378 |
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
|
6379 |
((parts at:1) , '.o') asFilename |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
6380 |
" |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
6381 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
6382 |
"Modified: 7.9.1995 / 11:15:42 / claus" |
1517 | 6383 |
"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
|
6384 |
! |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
6385 |
|
2906 | 6386 |
suffix |
6387 |
"return my suffix. |
|
6388 |
The suffix is the namepart after the final period character, |
|
6389 |
or the empty string, if the name does not contain a period." |
|
6390 |
||
6391 |
^ self prefixAndSuffix at:2 |
|
6392 |
||
6393 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6394 |
'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
|
6395 |
'abc' asFilename suffix |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6396 |
'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
|
6397 |
'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
|
6398 |
'a.' asFilename suffix |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6399 |
'.a' asFilename suffix |
2906 | 6400 |
" |
6401 |
||
6402 |
"Modified: 7.9.1995 / 11:09:03 / claus" |
|
6403 |
! |
|
6404 |
||
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
6405 |
withSuffix:aSuffix |
19440 | 6406 |
"return a new filename for the receiver's name with a different suffix. |
6256 | 6407 |
If the name already has a suffix, the new suffix replaces it; |
1993 | 6408 |
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
|
6409 |
|
7115
dea26def3167
prefix/suffix definition changed for files beginning with
Claus Gittinger <cg@exept.de>
parents:
7088
diff
changeset
|
6410 |
|prefixName| |
dea26def3167
prefix/suffix definition changed for files beginning with
Claus Gittinger <cg@exept.de>
parents:
7088
diff
changeset
|
6411 |
|
10155 | 6412 |
prefixName := self nameWithoutSuffix. |
7115
dea26def3167
prefix/suffix definition changed for files beginning with
Claus Gittinger <cg@exept.de>
parents:
7088
diff
changeset
|
6413 |
aSuffix isEmptyOrNil ifTrue:[ |
19599 | 6414 |
^ self species named:prefixName |
6262 | 6415 |
]. |
6416 |
||
15811 | 6417 |
^ self species named: |
19599 | 6418 |
(prefixName |
6419 |
, self class suffixSeparator asString |
|
6420 |
, aSuffix asString) |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6421 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6422 |
" |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6423 |
'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
|
6424 |
'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
|
6425 |
'.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
|
6426 |
'.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
|
6427 |
'.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
|
6428 |
'.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
|
6429 |
'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
|
6430 |
'.' asFilename withSuffix:nil |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6431 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6432 |
'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
|
6433 |
'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
|
6434 |
'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
|
6435 |
'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
|
6436 |
'.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
|
6437 |
'.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
|
6438 |
'.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
|
6439 |
'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
|
6440 |
'.' asFilename withSuffix:'o' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6441 |
'/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
|
6442 |
'/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
|
6443 |
'/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
|
6444 |
'/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
|
6445 |
" |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
6446 |
|
10155 | 6447 |
"Modified: / 07-09-1995 / 11:15:42 / claus" |
6448 |
"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
|
6449 |
! |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
6450 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
6451 |
withoutSuffix |
19440 | 6452 |
"return a new filename for the receiver's name without the suffix. |
10155 | 6453 |
If the name has no suffix, a filename representing the same file as the receiver is returned." |
6454 |
||
6455 |
|n| |
|
6456 |
||
6457 |
n := self nameWithoutSuffix. |
|
6458 |
n = nameString ifTrue:[^ self]. |
|
15811 | 6459 |
^ self species named:n |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
6460 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
6461 |
" |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6462 |
'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
|
6463 |
'abc' asFilename withoutSuffix |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6464 |
'/abc' asFilename withoutSuffix |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6465 |
'/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
|
6466 |
'./abc' asFilename withoutSuffix |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6467 |
'./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
|
6468 |
'./.abc' asFilename withoutSuffix |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6469 |
'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
|
6470 |
'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
|
6471 |
'.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
|
6472 |
'.b.' asFilename withoutSuffix |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6473 |
'.b' asFilename withoutSuffix |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6474 |
'/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
|
6475 |
'/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
|
6476 |
'/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
|
6477 |
'/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
|
6478 |
'/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
|
6479 |
" |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
6480 |
|
10155 | 6481 |
"Modified: / 07-09-1995 / 11:15:42 / claus" |
6482 |
"Modified: / 07-11-2006 / 13:57:45 / cg" |
|
174 | 6483 |
! ! |
6484 |
||
5597 | 6485 |
!Filename methodsFor:'testing'! |
6486 |
||
6487 |
isFilename |
|
6488 |
"return true, if the receiver is some kind of filename; |
|
6489 |
false is returned here - the method is redefined from Object." |
|
6490 |
||
6491 |
^true |
|
6492 |
||
6493 |
||
6494 |
! ! |
|
6495 |
||
10271 | 6496 |
!Filename methodsFor:'writing-files'! |
6497 |
||
14512 | 6498 |
appendingFileDo:aBlock |
6499 |
"create a append-stream on the receiver file, evaluate aBlock, passing that stream as arg, |
|
19088 | 6500 |
and return the block's value. |
14512 | 6501 |
If the file cannot be opened, an exception is raised. |
6502 |
Ensures that the stream is closed." |
|
6503 |
||
6504 |
|stream result| |
|
6505 |
||
6506 |
stream := self appendStream. |
|
6507 |
[ |
|
19599 | 6508 |
result := aBlock value:stream |
14512 | 6509 |
] ensure:[ |
19599 | 6510 |
stream close |
14512 | 6511 |
]. |
6512 |
^ result |
|
6513 |
||
6514 |
" |
|
14513 | 6515 |
'ttt' asFilename appendingFileDo:[:s | |
19599 | 6516 |
s nextPutLine:'hello'. |
6517 |
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
|
6518 |
] |
14512 | 6519 |
" |
6520 |
||
6521 |
"Created: / 09-11-2012 / 10:07:41 / sr" |
|
6522 |
! |
|
6523 |
||
10779 | 6524 |
contents:aStringOrCollectionOfLines |
10271 | 6525 |
"create (or overwrite) a file given its contents as a collection of lines. |
6526 |
Raises an error, if the file is unwritable." |
|
6527 |
||
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6528 |
^ self |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6529 |
writingFileDo:[:s | |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6530 |
aStringOrCollectionOfLines isNonByteCollection ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6531 |
"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
|
6532 |
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
|
6533 |
] ifFalse:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6534 |
"something string-like" |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6535 |
aStringOrCollectionOfLines isString ifFalse:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6536 |
s binary |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6537 |
]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6538 |
s nextPutAll:aStringOrCollectionOfLines |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6539 |
] |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6540 |
]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6541 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6542 |
" |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6543 |
'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
|
6544 |
'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
|
6545 |
'foo3' asFilename contents:#[1 2 3 4 5] |
10271 | 6546 |
" |
6547 |
||
6548 |
"Created: / 11-12-2006 / 14:11:21 / cg" |
|
10779 | 6549 |
"Modified: / 08-11-2007 / 13:28:41 / cg" |
10271 | 6550 |
! |
6551 |
||
6552 |
writingFileDo:aBlock |
|
6553 |
"create a write-stream on the receiver file, evaluate aBlock, passing that stream as arg, |
|
19088 | 6554 |
and return the block's value. |
10271 | 6555 |
If the file cannot be opened, an exception is raised. |
6556 |
Ensures that the stream is closed." |
|
6557 |
||
6558 |
|stream result| |
|
6559 |
||
6560 |
stream := self writeStream. |
|
6561 |
[ |
|
19599 | 6562 |
result := aBlock value:stream |
10271 | 6563 |
] ensure:[ |
19599 | 6564 |
stream close |
10271 | 6565 |
]. |
6566 |
^ result |
|
6567 |
||
6568 |
" |
|
6569 |
'ttt' asFilename writingFileDo:[:s | |
|
19599 | 6570 |
s nextPutLine:'hello'. |
6571 |
s nextPutLine:'world'. |
|
10271 | 6572 |
] |
6573 |
" |
|
6574 |
||
6575 |
"Created: / 11-12-2006 / 14:09:39 / cg" |
|
6576 |
! ! |
|
6577 |
||
1859
7f6040320daf
changes for new return from OS>>infoOf:
Claus Gittinger <cg@exept.de>
parents:
1614
diff
changeset
|
6578 |
!Filename class methodsFor:'documentation'! |
630 | 6579 |
|
6580 |
version |
|
18490 | 6581 |
^ '$Header$' |
12318 | 6582 |
! |
6583 |
||
6584 |
version_CVS |
|
18490 | 6585 |
^ '$Header$' |
20731
bee58777b1f7
Separate temporary directories for different users
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
20728
diff
changeset
|
6586 |
! |
bee58777b1f7
Separate temporary directories for different users
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
20728
diff
changeset
|
6587 |
|
bee58777b1f7
Separate temporary directories for different users
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
20728
diff
changeset
|
6588 |
version_HG |
bee58777b1f7
Separate temporary directories for different users
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
20728
diff
changeset
|
6589 |
|
bee58777b1f7
Separate temporary directories for different users
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
20728
diff
changeset
|
6590 |
^ '$Changeset: <not expanded> $' |
630 | 6591 |
! ! |
6771 | 6592 |
|
14628 | 6593 |
|
2906 | 6594 |
Filename initialize! |