author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Tue, 15 Mar 2016 07:14:51 +0000 | |
branch | jv |
changeset 19406 | faccbadf3034 |
parent 19127 | 940613fe6659 |
parent 19362 | dd6ee6342985 |
child 19478 | 1f5aa87f6170 |
permissions | -rw-r--r-- |
18272 | 1 |
"{ Encoding: utf8 }" |
2 |
||
1 | 3 |
" |
5 | 4 |
COPYRIGHT (c) 1992 by Claus Gittinger |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5 |
All Rights Reserved |
1 | 6 |
|
7 |
This software is furnished under a license and may be used |
|
8 |
only in accordance with the terms of that license and with the |
|
9 |
inclusion of the above copyright notice. This software may not |
|
10 |
be provided or otherwise made available to, or used by, any |
|
11 |
other person. No title to or ownership of the software is |
|
12 |
hereby transferred. |
|
13 |
" |
|
5507
e8c61b1741c6
in #moveTo: - try a link first, then do a copy-remove.
Claus Gittinger <cg@exept.de>
parents:
5303
diff
changeset
|
14 |
"{ Package: 'stx:libbasic' }" |
e8c61b1741c6
in #moveTo: - try a link first, then do a copy-remove.
Claus Gittinger <cg@exept.de>
parents:
5303
diff
changeset
|
15 |
|
17310 | 16 |
"{ NameSpace: Smalltalk }" |
17 |
||
1 | 18 |
Object subclass:#Filename |
14567 | 19 |
instanceVariableNames:'nameString' |
15459 | 20 |
classVariableNames:'TempDirectory DefaultTempDirectory ConcreteClass' |
14567 | 21 |
poolDictionaries:'' |
22 |
category:'System-Support' |
|
615 | 23 |
! |
1 | 24 |
|
1859
7f6040320daf
changes for new return from OS>>infoOf:
Claus Gittinger <cg@exept.de>
parents:
1614
diff
changeset
|
25 |
!Filename class methodsFor:'documentation'! |
88 | 26 |
|
27 |
copyright |
|
28 |
" |
|
29 |
COPYRIGHT (c) 1992 by Claus Gittinger |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
30 |
All Rights Reserved |
1 | 31 |
|
88 | 32 |
This software is furnished under a license and may be used |
33 |
only in accordance with the terms of that license and with the |
|
34 |
inclusion of the above copyright notice. This software may not |
|
35 |
be provided or otherwise made available to, or used by, any |
|
36 |
other person. No title to or ownership of the software is |
|
37 |
hereby transferred. |
|
38 |
" |
|
39 |
! |
|
40 |
||
41 |
documentation |
|
42 |
" |
|
43 |
Filenames; originally added for ST-80 compatibility, is |
|
44 |
taking over functionality from other classes (FileDirectory). |
|
92 | 45 |
|
46 |
Instances of Filename do not nescessarily represent valid or existing |
|
47 |
files - i.e. it is possible (and useful) to have instances for non-existing |
|
48 |
files around. In other words: the name-string is not checked automatically |
|
49 |
for being correct or existing. |
|
50 |
Thus, it is possible to do queries such as: |
|
51 |
||
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
52 |
'/fee/foo/foe' asFilename exists |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
53 |
'/not_existing' asFilename isDirectory |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
54 |
'/foo/bar' asFilename isReadable |
92 | 55 |
|
195 | 56 |
(all of the above examples will probably return false on your machine ;-). |
276 | 57 |
|
58 |
examples: |
|
59 |
||
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
60 |
'Makefile' asFilename readStream |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
61 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
62 |
'newFile' asFilename writeStream |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
63 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
64 |
Filename newTemporary writeStream |
276 | 65 |
|
1318 | 66 |
Beside lots of protocol to query for a files attributes, the class |
67 |
protocol offers methods for filename completion, to construct pathes |
|
68 |
(in an OS-independent way) and to create temporary files. |
|
2911 | 69 |
Especially the path-construction methods (i.e. #construct:) are highly |
1318 | 70 |
recommended in order to avoid having OS details (like directory separators |
71 |
being slash or backslash) spreaded in your application. |
|
72 |
||
8738 | 73 |
Since Filenames have different semantics under different operating systems, |
74 |
class methods are delegated to concrete implementations in various subclasses like |
|
75 |
UnixFilename, PCFilename, ... |
|
76 |
The delegation is implemented in a way, so that some methods of |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
77 |
specific OS Filenames might be used, even if ST/X is currently running |
8738 | 78 |
on a different OS (as long as the method does not depend on the OperatingSystem class). |
79 |
||
1286 | 80 |
[author:] |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
81 |
Claus Gittinger |
276 | 82 |
|
1286 | 83 |
[see also:] |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
84 |
String |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
85 |
FileStream DirectoryStream PipeStream Socket |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
86 |
OperatingSystem |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
87 |
Date Time |
88 | 88 |
" |
360 | 89 |
! |
90 |
||
91 |
examples |
|
92 |
" |
|
93 |
does a file/directory exist ?: |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
94 |
[exBegin] |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
95 |
|f| |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
96 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
97 |
f := 'foobar' asFilename. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
98 |
^ f exists |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
99 |
[exEnd] |
360 | 100 |
|
101 |
||
102 |
is it a directory ?: |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
103 |
[exBegin] |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
104 |
|f| |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
105 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
106 |
f := '/tmp' asFilename. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
107 |
^ f isDirectory. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
108 |
[exEnd] |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
109 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
110 |
|
360 | 111 |
get the working directory: |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
112 |
[exBegin] |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
113 |
^ Filename defaultDirectory |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
114 |
[exEnd] |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
115 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
116 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
117 |
get a files full pathname |
360 | 118 |
(caring for relative names or symbolic links): |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
119 |
[exBegin] |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
120 |
|f| |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
121 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
122 |
f := '..' asFilename. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
123 |
^ f pathName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
124 |
[exEnd] |
360 | 125 |
|
126 |
||
127 |
get a directories directory: |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
128 |
[exBegin] |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
129 |
|f| |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
130 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
131 |
f := Filename defaultDirectory. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
132 |
^ f directory |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
133 |
[exEnd] |
360 | 134 |
|
135 |
||
136 |
get a files directory: |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
137 |
[exBegin] |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
138 |
|f| |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
139 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
140 |
f := './smalltalk' asFilename. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
141 |
^ f directory |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
142 |
[exEnd] |
360 | 143 |
|
144 |
||
145 |
getting access & modification times: |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
146 |
[exBegin] |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
147 |
|f| |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
148 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
149 |
f := '/tmp' asFilename. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
150 |
^ f dates |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
151 |
[exEnd] |
360 | 152 |
|
153 |
access time only: |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
154 |
[exBegin] |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
155 |
|f| |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
156 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
157 |
f := '/tmp' asFilename. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
158 |
^ f dates at:#accessed |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
159 |
[exEnd] |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
160 |
|
360 | 161 |
|
162 |
getting all information on a file/directory: |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
163 |
[exBegin] |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
164 |
|f| |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
165 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
166 |
f := '/tmp' asFilename. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
167 |
^ f info |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
168 |
[exEnd] |
360 | 169 |
|
170 |
||
171 |
getting a temporary file (unique name): |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
172 |
[exBegin] |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
173 |
|f| |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
174 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
175 |
f := Filename newTemporary. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
176 |
^ f |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
177 |
[exEnd] |
360 | 178 |
|
179 |
creating, writing, reading and removing a temporary file: |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
180 |
[exBegin] |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
181 |
|f writeStream readStream| |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
182 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
183 |
f := Filename newTemporary. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
184 |
writeStream := f writeStream. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
185 |
writeStream nextPutAll:'hello world'. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
186 |
writeStream cr. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
187 |
writeStream close. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
188 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
189 |
'contents (as seen by unix''s cat command:' printNL. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
190 |
OperatingSystem executeCommand:('cat ' , f pathName). |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
191 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
192 |
readStream := f readStream. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
193 |
Transcript showCR:'contents as seen by smalltalk:'. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
194 |
Transcript showCR:(readStream upToEnd). |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
195 |
readStream close. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
196 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
197 |
f delete. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
198 |
[exEnd] |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
199 |
|
360 | 200 |
|
201 |
getting a directories contents: |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
202 |
[exBegin] |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
203 |
|f files| |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
204 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
205 |
f := Filename currentDirectory. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
206 |
files := f directoryContents. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
207 |
Transcript showCR:'the files are:'. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
208 |
Transcript showCR:(files printString). |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
209 |
[exEnd] |
360 | 210 |
|
211 |
||
212 |
editing a file: |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
213 |
[exBegin] |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
214 |
|f| |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
215 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
216 |
f := Filename newTemporary. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
217 |
(f writeStream) nextPutAll:'hello world'; close. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
218 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
219 |
f edit |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
220 |
[exEnd] |
360 | 221 |
" |
88 | 222 |
! ! |
1 | 223 |
|
2906 | 224 |
!Filename class methodsFor:'initialization'! |
225 |
||
226 |
initialize |
|
227 |
"initialize for the OS we are running on" |
|
228 |
||
8754 | 229 |
ConcreteClass isNil ifTrue:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
230 |
self initializeConcreteClass |
7702 | 231 |
]. |
2906 | 232 |
|
233 |
" |
|
234 |
self initialize |
|
235 |
" |
|
236 |
||
237 |
"Created: 7.9.1997 / 23:32:55 / cg" |
|
238 |
! |
|
239 |
||
240 |
initializeConcreteClass |
|
241 |
"initialize for the OS we are running on" |
|
242 |
||
8754 | 243 |
OperatingSystem isUNIXlike ifTrue:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
244 |
ConcreteClass := UnixFilename |
8754 | 245 |
] ifFalse:[OperatingSystem isMSDOSlike ifTrue:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
246 |
ConcreteClass := PCFilename |
8754 | 247 |
] ifFalse:[OperatingSystem isVMSlike ifTrue:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
248 |
ConcreteClass := OpenVMSFilename |
2906 | 249 |
] ifFalse:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
250 |
self error:'Filename: unknown OperatingSystem when initializing concrete Filename class'. |
8754 | 251 |
]]]. |
252 |
||
253 |
ConcreteClass isNil ifTrue:[ |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
254 |
self error:'Filename: Missing concrete Filename class'. |
8754 | 255 |
]. |
256 |
||
257 |
" |
|
258 |
self initializeConcreteClass |
|
2906 | 259 |
" |
260 |
||
261 |
"Modified: 7.9.1997 / 23:32:37 / cg" |
|
262 |
! |
|
263 |
||
264 |
reinitialize |
|
8738 | 265 |
"initialize for the OS we are running on (after a restart)" |
2906 | 266 |
|
9806 | 267 |
TempDirectory := nil. |
268 |
self initializeConcreteClass. |
|
2906 | 269 |
|
270 |
" |
|
8754 | 271 |
self reinitialize |
2906 | 272 |
" |
273 |
||
9806 | 274 |
"Created: / 07-09-1997 / 23:33:02 / cg" |
275 |
"Modified: / 29-08-2006 / 12:40:28 / cg" |
|
2906 | 276 |
! ! |
277 |
||
3959 | 278 |
!Filename class methodsFor:'instance creation'! |
279 |
||
17227 | 280 |
applicationDataDirectory |
281 |
"return the directory, where user-and-application-specific private files are to be |
|
282 |
located (ini-files, preferences etc.). |
|
283 |
Under windows, something like 'C:\Users\Administrator\AppData\Roaming\<appName>' |
|
284 |
is returned, under unix, we use ~/.<appName> (but see details in UnixOS). |
|
285 |
For smalltalk itself (the IDE), 'smalltalk' is used as appName. |
|
286 |
If the directory does not exist, it is created" |
|
287 |
||
288 |
|exeName| |
|
289 |
||
290 |
Smalltalk isStandAloneApp ifTrue:[ |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
291 |
exeName := OperatingSystem nameOfSTXExecutable. |
17227 | 292 |
] ifFalse:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
293 |
exeName := 'smalltalk' |
17227 | 294 |
]. |
295 |
^ self applicationDataDirectoryFor:exeName |
|
296 |
||
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
297 |
" |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
298 |
Filename applicationDataDirectory |
17227 | 299 |
" |
300 |
! |
|
301 |
||
12972 | 302 |
applicationDataDirectoryFor:appName |
303 |
"return the directory, where user-and-application-specific private files are to be |
|
304 |
located (ini-files, preferences etc.). |
|
305 |
Under windows, something like 'C:\Users\Administrator\AppData\Roaming\<appName>' |
|
12973 | 306 |
is returned, under unix, we use ~/.<appName> (but see details in UnixOS). |
12974 | 307 |
If the directory does not exist, it is created" |
308 |
||
309 |
|s dir| |
|
12972 | 310 |
|
311 |
s := OperatingSystem getApplicationDataDirectoryFor:appName. |
|
312 |
s isNil ifTrue:[ |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
313 |
^ self homeDirectory |
12972 | 314 |
]. |
12974 | 315 |
dir := self named:s. |
316 |
dir exists ifFalse:[ |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
317 |
dir makeDirectory |
12974 | 318 |
]. |
319 |
^ dir |
|
12972 | 320 |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
321 |
" |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
322 |
Filename applicationDataDirectoryFor:'smalltalk' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
323 |
Filename applicationDataDirectoryFor:'expecco' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
324 |
applicationDataDirectoryFor:'expecco' |
12972 | 325 |
" |
326 |
||
327 |
"Created: / 29-07-2010 / 12:05:35 / sr" |
|
328 |
! |
|
329 |
||
3959 | 330 |
currentDirectory |
331 |
"return a filename for the current directory" |
|
332 |
||
13109 | 333 |
^ self named:(OperatingSystem getCurrentDirectory). |
3959 | 334 |
|
335 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
336 |
Filename currentDirectory |
3959 | 337 |
" |
338 |
! |
|
339 |
||
340 |
defaultDirectory |
|
341 |
"ST80 compatibility: same as currentDirectory" |
|
342 |
||
343 |
^ self currentDirectory |
|
344 |
||
345 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
346 |
Filename defaultDirectory |
3959 | 347 |
" |
348 |
! |
|
349 |
||
12336
7610de9a7e4b
provide access to the default (original, unchanged) tempDirectory
Claus Gittinger <cg@exept.de>
parents:
12318
diff
changeset
|
350 |
defaultTempDirectory |
7610de9a7e4b
provide access to the default (original, unchanged) tempDirectory
Claus Gittinger <cg@exept.de>
parents:
12318
diff
changeset
|
351 |
"return the default temp directory as a filename. |
7610de9a7e4b
provide access to the default (original, unchanged) tempDirectory
Claus Gittinger <cg@exept.de>
parents:
12318
diff
changeset
|
352 |
That is the same as TempDirectory, except that TempDirectory can be changed |
17048 | 353 |
from the outside (via tempDirectory:) whereas this is the OS's original default. |
12336
7610de9a7e4b
provide access to the default (original, unchanged) tempDirectory
Claus Gittinger <cg@exept.de>
parents:
12318
diff
changeset
|
354 |
Use this for files which MUST remain the same (stx_sourceCache)" |
7610de9a7e4b
provide access to the default (original, unchanged) tempDirectory
Claus Gittinger <cg@exept.de>
parents:
12318
diff
changeset
|
355 |
|
7610de9a7e4b
provide access to the default (original, unchanged) tempDirectory
Claus Gittinger <cg@exept.de>
parents:
12318
diff
changeset
|
356 |
DefaultTempDirectory isNil ifTrue:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
357 |
self tempDirectory. "/ actually sets DefaultTempDirectory as side effect |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
358 |
DefaultTempDirectory isNil ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
359 |
DefaultTempDirectory := TempDirectory |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
360 |
]. |
12336
7610de9a7e4b
provide access to the default (original, unchanged) tempDirectory
Claus Gittinger <cg@exept.de>
parents:
12318
diff
changeset
|
361 |
]. |
7610de9a7e4b
provide access to the default (original, unchanged) tempDirectory
Claus Gittinger <cg@exept.de>
parents:
12318
diff
changeset
|
362 |
|
7610de9a7e4b
provide access to the default (original, unchanged) tempDirectory
Claus Gittinger <cg@exept.de>
parents:
12318
diff
changeset
|
363 |
DefaultTempDirectory exists ifFalse:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
364 |
DefaultTempDirectory |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
365 |
makeDirectory; |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
366 |
addAccessRights:#(readUser readGroup readOthers |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
367 |
writeUser writeGroup writeOthers |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
368 |
executeUser executeGroup executeOthers |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
369 |
removeOnlyByOwner). |
12336
7610de9a7e4b
provide access to the default (original, unchanged) tempDirectory
Claus Gittinger <cg@exept.de>
parents:
12318
diff
changeset
|
370 |
]. |
7610de9a7e4b
provide access to the default (original, unchanged) tempDirectory
Claus Gittinger <cg@exept.de>
parents:
12318
diff
changeset
|
371 |
^ DefaultTempDirectory |
7610de9a7e4b
provide access to the default (original, unchanged) tempDirectory
Claus Gittinger <cg@exept.de>
parents:
12318
diff
changeset
|
372 |
|
7610de9a7e4b
provide access to the default (original, unchanged) tempDirectory
Claus Gittinger <cg@exept.de>
parents:
12318
diff
changeset
|
373 |
" |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
374 |
Filename tempDirectory |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
375 |
Filename defaultTempDirectory |
12336
7610de9a7e4b
provide access to the default (original, unchanged) tempDirectory
Claus Gittinger <cg@exept.de>
parents:
12318
diff
changeset
|
376 |
" |
7610de9a7e4b
provide access to the default (original, unchanged) tempDirectory
Claus Gittinger <cg@exept.de>
parents:
12318
diff
changeset
|
377 |
|
7610de9a7e4b
provide access to the default (original, unchanged) tempDirectory
Claus Gittinger <cg@exept.de>
parents:
12318
diff
changeset
|
378 |
"Created: / 07-03-1996 / 14:51:18 / cg" |
7610de9a7e4b
provide access to the default (original, unchanged) tempDirectory
Claus Gittinger <cg@exept.de>
parents:
12318
diff
changeset
|
379 |
"Modified: / 29-08-2006 / 12:57:16 / cg" |
7610de9a7e4b
provide access to the default (original, unchanged) tempDirectory
Claus Gittinger <cg@exept.de>
parents:
12318
diff
changeset
|
380 |
! |
7610de9a7e4b
provide access to the default (original, unchanged) tempDirectory
Claus Gittinger <cg@exept.de>
parents:
12318
diff
changeset
|
381 |
|
10546 | 382 |
desktopDirectory |
383 |
"return your desktop directory. |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
384 |
Under windows, thats the real desktop directory; |
10546 | 385 |
under other OperatingSystems, the home directory is returned." |
386 |
||
387 |
|s| |
|
388 |
||
389 |
s := OperatingSystem getDesktopDirectory. |
|
390 |
s isNil ifTrue:[ |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
391 |
^ self homeDirectory |
10546 | 392 |
]. |
393 |
^ self named:s |
|
394 |
||
395 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
396 |
Filename desktopDirectory |
10546 | 397 |
" |
398 |
||
399 |
"Created: / 16-05-2007 / 13:18:34 / cg" |
|
400 |
! |
|
401 |
||
11763 | 402 |
documentsDirectory |
403 |
"return your documents directory. |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
404 |
Under windows, thats the real 'Documents' or 'My Documents'; |
11763 | 405 |
under other OperatingSystems, the home directory is returned." |
406 |
||
407 |
|s| |
|
408 |
||
409 |
s := OperatingSystem getDocumentsDirectory. |
|
410 |
s isNil ifTrue:[ |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
411 |
^ self homeDirectory |
11763 | 412 |
]. |
413 |
^ self named:s |
|
414 |
||
415 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
416 |
Filename documentsDirectory |
11763 | 417 |
" |
418 |
||
419 |
"Created: / 16-05-2007 / 13:18:34 / cg" |
|
420 |
! |
|
421 |
||
3959 | 422 |
findDefaultDirectory |
423 |
"same as #defaultDirectory for ST80 compatibility" |
|
424 |
||
425 |
^ self defaultDirectory |
|
426 |
||
427 |
"Created: 20.6.1997 / 17:00:29 / cg" |
|
428 |
! |
|
429 |
||
430 |
fromComponents:aCollectionOfDirectoryNames |
|
431 |
"create & return a new filename from components given in |
|
432 |
aCollectionOfDirectoryNames. If the first component is the name of the |
|
433 |
root directory (i.e. '/') an absolute path-filename is returned." |
|
434 |
||
11781
6488fd6cc498
Make AutoDeletedFilename work like Filename
Stefan Vogel <sv@exept.de>
parents:
11763
diff
changeset
|
435 |
self isAbstract ifTrue:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
436 |
^ ConcreteClass fromComponents:aCollectionOfDirectoryNames |
3959 | 437 |
]. |
438 |
||
6802 | 439 |
^ self named:(self nameFromComponents:aCollectionOfDirectoryNames) |
3959 | 440 |
|
441 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
442 |
Filename fromComponents:#('/' 'foo' 'bar' 'baz') |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
443 |
PCFilename fromComponents:#('/' 'foo' 'bar' 'baz') |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
444 |
UnixFilename fromComponents:#('/' 'foo' 'bar' 'baz') |
8754 | 445 |
OpenVMSFilename fromComponents:#('foo' 'bar' 'baz') |
446 |
||
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
447 |
Filename fromComponents:#('foo' 'bar' 'baz') |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
448 |
Filename fromComponents:#('/') |
3959 | 449 |
|
450 |
Filename fromComponents: |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
451 |
(Filename components:('.' asFilename pathName)) |
3959 | 452 |
|
453 |
Filename fromComponents: |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
454 |
(Filename components:('.' asFilename name)) |
3959 | 455 |
" |
456 |
||
457 |
"Modified: 8.9.1997 / 00:23:16 / cg" |
|
458 |
! |
|
459 |
||
460 |
fromUser |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
461 |
"show a box to enter a filename. |
3959 | 462 |
Return a filename instance or nil (if cancel was pressed)." |
463 |
||
464 |
|name| |
|
465 |
||
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
466 |
name := Dialog |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
467 |
requestFileName:'filename:' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
468 |
default:nil |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
469 |
fromDirectory:(FileSelectionBox lastFileSelectionDirectory). |
8738 | 470 |
|
471 |
name notEmptyOrNil ifTrue:[ |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
472 |
^ self named:name |
3978
b2babde0857b
use remembered last filenames directory (in #fromUser)
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
473 |
]. |
3959 | 474 |
^ nil |
475 |
||
476 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
477 |
Filename fromUser |
3959 | 478 |
" |
479 |
||
480 |
"Modified: 19.4.1996 / 13:57:44 / cg" |
|
481 |
! |
|
482 |
||
483 |
homeDirectory |
|
484 |
"return your homeDirectory. |
|
485 |
Some OperatingSystems do not support this - on those, the defaultDirectory |
|
17113 | 486 |
(which is the currentDirectory) is returned. |
487 |
Notice: services under windows also do not have a home directory." |
|
3959 | 488 |
|
489 |
|s| |
|
490 |
||
491 |
s := OperatingSystem getHomeDirectory. |
|
492 |
s isNil ifTrue:[ |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
493 |
^ self defaultDirectory |
3959 | 494 |
]. |
495 |
^ self named:s |
|
496 |
||
497 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
498 |
Filename homeDirectory |
3959 | 499 |
" |
500 |
||
501 |
"Modified: 8.9.1997 / 00:25:23 / cg" |
|
502 |
! |
|
503 |
||
504 |
named:aString |
|
505 |
"return a filename for a directory named aString. |
|
506 |
This is the same as 'aString asFilename'." |
|
507 |
||
11781
6488fd6cc498
Make AutoDeletedFilename work like Filename
Stefan Vogel <sv@exept.de>
parents:
11763
diff
changeset
|
508 |
self isAbstract ifTrue:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
509 |
^ ConcreteClass named:aString |
3959 | 510 |
]. |
8738 | 511 |
^ self basicNew setName:aString |
3959 | 512 |
|
513 |
" |
|
514 |
Filename named:'/tmp/fooBar' |
|
515 |
" |
|
516 |
||
517 |
"Modified: 7.9.1997 / 23:30:06 / cg" |
|
518 |
! |
|
519 |
||
520 |
newTemporary |
|
521 |
"return a new unique filename - use this for temporary files. |
|
522 |
The filenames returned are '/tmp/stxtmp_xx_nn' where xx is our |
|
523 |
unix process id, and nn is a unique number, incremented with every |
|
524 |
call to this method. |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
525 |
If any of the environment variables ST_TMPDIR or TMPDIR is set, |
4757 | 526 |
its value defines the temp directory. |
527 |
Notice, that no file is created by this - only a unique name |
|
15459 | 528 |
is generated. |
529 |
||
16787 | 530 |
DO NOT USE THIS FOR PLAIN FILES - IT IS UNSECURE use FileStream>>#newTemporary |
531 |
(the insecurity is due to a small chance for some other program to open/create |
|
532 |
the file, as only a name is generated here. However, chances are small as the name |
|
533 |
is reasonably random - but for security relevant applications, this may be relevant) |
|
534 |
" |
|
3959 | 535 |
|
9912 | 536 |
^ self newTemporaryIn:(self tempDirectory) |
3959 | 537 |
|
538 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
539 |
Filename newTemporary |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
540 |
Filename newTemporary |
3959 | 541 |
" |
542 |
||
543 |
"Modified: 7.9.1995 / 10:48:31 / claus" |
|
544 |
"Modified: 7.3.1996 / 14:51:33 / cg" |
|
545 |
! |
|
546 |
||
9912 | 547 |
newTemporaryDirectory |
548 |
"return a new unique temporary directory - use this for temporary files. |
|
549 |
The directories returned are '/tmp/stxtmp_xx_nn' where xx is our |
|
550 |
unix process id, and nn is a unique number, incremented with every |
|
551 |
call to this method. |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
552 |
If any of the environment variables ST_TMPDIR or TMPDIR is set, |
9912 | 553 |
its value defines the temp directory." |
554 |
||
555 |
^ self newTemporaryDirectoryIn:(self tempDirectory) |
|
556 |
! |
|
557 |
||
558 |
newTemporaryDirectoryIn:aDirectoryOrNil |
|
559 |
"return a new unique temporary directory in another directory, or the current dir. |
|
560 |
Use this for temporary files. |
|
561 |
The directories returned are '/tmp/stxtmp_xx_nn' where xx is our |
|
562 |
unix process id, and nn is a unique number, incremented with every |
|
563 |
call to this method. |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
564 |
If any of the environment variables ST_TMPDIR or TMPDIR is set, |
9912 | 565 |
its value defines the temp directory." |
566 |
||
567 |
|tempdir| |
|
568 |
||
15811 | 569 |
tempdir := self newTemporaryIn:aDirectoryOrNil. |
9912 | 570 |
tempdir exists ifTrue:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
571 |
tempdir recursiveRemove. |
9912 | 572 |
]. |
573 |
tempdir makeDirectory. |
|
574 |
^ tempdir |
|
575 |
! |
|
576 |
||
577 |
newTemporaryIn:aDirectoryOrNil |
|
3959 | 578 |
"return a new unique filename - use this for temporary files. |
579 |
The filenames returned are in aDirectoryPrefix and named 'stxtmp_xx_nn', |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
580 |
where xx is our unix process id, and nn is a unique number, incremented |
3959 | 581 |
with every call to this method. |
582 |
Notice: only a unique filename object is created and returned - no physical |
|
583 |
file is created by this method (i.e. you have to send #writeStream or |
|
584 |
whatever to it in order to really create something). |
|
15459 | 585 |
See also: #newTemporary which looks for a good temp directory. |
586 |
||
587 |
DO NOT USE THIS FOR PLAIN FILES - IT IS UNSECURE use FileStream>>#newTemporaryIn:" |
|
3959 | 588 |
|
12617 | 589 |
^ self newTemporaryIn:aDirectoryOrNil nameTemplate:(self tempFileNameTemplate) |
3959 | 590 |
|
591 |
"temp files in '/tmp': |
|
592 |
||
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
593 |
Filename newTemporary |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
594 |
" |
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 |
"temp files somewhere |
3959 | 597 |
(not recommended - use above since it can be controlled via shell variables): |
598 |
||
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
599 |
UnixFilename newTemporaryIn:'/tmp' |
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:'/usr/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:'/' |
3959 | 603 |
" |
604 |
||
605 |
"a local temp file: |
|
606 |
||
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
607 |
Filename newTemporaryIn:'' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
608 |
Filename newTemporaryIn:nil |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
609 |
Filename newTemporaryIn:'.' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
610 |
Filename newTemporaryIn:('source' asFilename) |
3959 | 611 |
" |
612 |
||
613 |
"Modified: / 7.9.1995 / 10:48:31 / claus" |
|
614 |
"Modified: / 11.8.1998 / 22:51:43 / cg" |
|
615 |
! |
|
616 |
||
9912 | 617 |
newTemporaryIn:aDirectoryOrNil nameTemplate:template |
6893
9aa286d3a644
added newTemporary with template
Claus Gittinger <cg@exept.de>
parents:
6839
diff
changeset
|
618 |
"return a new unique filename - use this for temporary files. |
9912 | 619 |
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
|
620 |
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
|
621 |
with every call to this method respectively. |
9aa286d3a644
added newTemporary with template
Claus Gittinger <cg@exept.de>
parents:
6839
diff
changeset
|
622 |
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
|
623 |
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
|
624 |
whatever to it in order to really create something). |
15459 | 625 |
See also: #newTemporary which looks for a good temp directory. |
626 |
||
627 |
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
|
628 |
|
8738 | 629 |
|nameString newTempFilename| |
630 |
||
11781
6488fd6cc498
Make AutoDeletedFilename work like Filename
Stefan Vogel <sv@exept.de>
parents:
11763
diff
changeset
|
631 |
self isAbstract ifTrue:[ |
19362 | 632 |
^ ConcreteClass newTemporaryIn:aDirectoryOrNil nameTemplate:template |
6893
9aa286d3a644
added newTemporary with template
Claus Gittinger <cg@exept.de>
parents:
6839
diff
changeset
|
633 |
]. |
9aa286d3a644
added newTemporary with template
Claus Gittinger <cg@exept.de>
parents:
6839
diff
changeset
|
634 |
|
8738 | 635 |
"although the above allows things to be redefined in concrete classes, |
636 |
the following should work on all systems ..." |
|
637 |
||
638 |
[ |
|
19362 | 639 |
"Use random numbers in order to improve the security |
640 |
by making the generated names less predictable" |
|
641 |
nameString := template bindWith:(OperatingSystem getProcessId) with:(RandomGenerator nextLettersOrDigits:4). |
|
642 |
||
643 |
aDirectoryOrNil isNil ifTrue:[ |
|
644 |
newTempFilename := self named:nameString |
|
645 |
] ifFalse:[ |
|
646 |
newTempFilename := aDirectoryOrNil asFilename construct:nameString |
|
647 |
] |
|
8738 | 648 |
] doWhile:[ |
19362 | 649 |
"care for existing leftOver tempFiles |
650 |
from a previous boot of the OS |
|
651 |
i.e. my pid could be the same as when executed |
|
652 |
the last time before system reboot ...)" |
|
653 |
||
654 |
newTempFilename exists |
|
6893
9aa286d3a644
added newTemporary with template
Claus Gittinger <cg@exept.de>
parents:
6839
diff
changeset
|
655 |
]. |
8738 | 656 |
^ newTempFilename |
6893
9aa286d3a644
added newTemporary with template
Claus Gittinger <cg@exept.de>
parents:
6839
diff
changeset
|
657 |
|
9aa286d3a644
added newTemporary with template
Claus Gittinger <cg@exept.de>
parents:
6839
diff
changeset
|
658 |
"temp files in '/tmp': |
9aa286d3a644
added newTemporary with template
Claus Gittinger <cg@exept.de>
parents:
6839
diff
changeset
|
659 |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
660 |
Filename newTemporary |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
661 |
" |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
662 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
663 |
"temp files somewhere |
6893
9aa286d3a644
added newTemporary with template
Claus Gittinger <cg@exept.de>
parents:
6839
diff
changeset
|
664 |
(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
|
665 |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
666 |
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
|
667 |
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
|
668 |
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
|
669 |
UnixFilename newTemporaryIn:'/' nameTemplate:'foo%1_%2' |
6893
9aa286d3a644
added newTemporary with template
Claus Gittinger <cg@exept.de>
parents:
6839
diff
changeset
|
670 |
" |
9aa286d3a644
added newTemporary with template
Claus Gittinger <cg@exept.de>
parents:
6839
diff
changeset
|
671 |
|
9aa286d3a644
added newTemporary with template
Claus Gittinger <cg@exept.de>
parents:
6839
diff
changeset
|
672 |
"a local temp file: |
9aa286d3a644
added newTemporary with template
Claus Gittinger <cg@exept.de>
parents:
6839
diff
changeset
|
673 |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
674 |
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
|
675 |
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
|
676 |
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
|
677 |
Filename newTemporaryIn:('source' asFilename) nameTemplate:'foo%1_%2' |
6893
9aa286d3a644
added newTemporary with template
Claus Gittinger <cg@exept.de>
parents:
6839
diff
changeset
|
678 |
" |
9aa286d3a644
added newTemporary with template
Claus Gittinger <cg@exept.de>
parents:
6839
diff
changeset
|
679 |
|
12918
a9de9243a951
changed: #newTemporaryIn:nameTemplate:
Claus Gittinger <cg@exept.de>
parents:
12910
diff
changeset
|
680 |
"Modified: / 07-09-1995 / 10:48:31 / claus" |
a9de9243a951
changed: #newTemporaryIn:nameTemplate:
Claus Gittinger <cg@exept.de>
parents:
12910
diff
changeset
|
681 |
"Modified: / 07-05-2010 / 11:46:05 / cg" |
6893
9aa286d3a644
added newTemporary with template
Claus Gittinger <cg@exept.de>
parents:
6839
diff
changeset
|
682 |
! |
9aa286d3a644
added newTemporary with template
Claus Gittinger <cg@exept.de>
parents:
6839
diff
changeset
|
683 |
|
4199 | 684 |
nullDevice |
685 |
"return the filename of the nullDevice (if available). |
|
686 |
returns nil, if the OperatingSystem does not support this." |
|
687 |
||
688 |
|s| |
|
689 |
||
8754 | 690 |
s := self nullFilename. |
4199 | 691 |
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
|
692 |
^ nil |
4199 | 693 |
]. |
694 |
^ self named:s |
|
695 |
||
696 |
" |
|
8754 | 697 |
Filename nullDevice |
698 |
UnixFilename nullDevice |
|
699 |
PCFilename nullDevice |
|
4199 | 700 |
" |
701 |
||
702 |
"Created: / 19.5.1999 / 12:24:26 / cg" |
|
703 |
! |
|
704 |
||
6256 | 705 |
remoteHost:remoteHostString rootComponents:aCollectionOfDirectoryNames |
706 |
"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
|
707 |
aCollectionOfDirectoryNames on a host named remoteHostString. |
6256 | 708 |
An absolute network-filename is returned." |
709 |
||
11781
6488fd6cc498
Make AutoDeletedFilename work like Filename
Stefan Vogel <sv@exept.de>
parents:
11763
diff
changeset
|
710 |
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
|
711 |
^ ConcreteClass remoteHost:remoteHostString |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
712 |
rootComponents:aCollectionOfDirectoryNames |
6256 | 713 |
]. |
714 |
||
10390 | 715 |
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
|
716 |
self error:'remote hosts are not supported by OS' |
10390 | 717 |
]. |
718 |
||
719 |
^ self rootComponents:aCollectionOfDirectoryNames |
|
720 |
||
721 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
722 |
'file:///tmp/test' asURI asFilename |
10390 | 723 |
" |
6256 | 724 |
! |
725 |
||
726 |
rootComponents:aCollectionOfDirectoryNames |
|
727 |
"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
|
728 |
aCollectionOfDirectoryNames. |
6256 | 729 |
An absolute path-filename is returned." |
730 |
||
731 |
|sep s| |
|
732 |
||
11781
6488fd6cc498
Make AutoDeletedFilename work like Filename
Stefan Vogel <sv@exept.de>
parents:
11763
diff
changeset
|
733 |
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
|
734 |
^ ConcreteClass rootComponents:aCollectionOfDirectoryNames |
6256 | 735 |
]. |
736 |
||
737 |
"/ fallBack - works on Unix & MSDOS |
|
738 |
||
8243 | 739 |
sep := self separatorString. |
18272 | 740 |
s := CharacterWriteStream new. |
6256 | 741 |
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
|
742 |
component ~= sep ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
743 |
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
|
744 |
] |
6256 | 745 |
]. |
746 |
s := s contents. |
|
747 |
s size == 0 ifTrue:[s := sep]. |
|
748 |
^ self named:s |
|
749 |
||
750 |
" |
|
8754 | 751 |
Filename rootComponents:#('/' 'foo' 'bar' 'baz') |
752 |
||
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
753 |
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
|
754 |
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
|
755 |
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
|
756 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
757 |
Filename rootComponents:#('/') |
6256 | 758 |
|
759 |
Filename rootComponents: |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
760 |
(Filename components:('.' asFilename pathName)) |
6256 | 761 |
|
762 |
Filename rootComponents: |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
763 |
(Filename components:('.' asFilename name)) |
6256 | 764 |
" |
765 |
||
766 |
"Modified: 8.9.1997 / 00:23:16 / cg" |
|
767 |
! |
|
768 |
||
3959 | 769 |
rootDirectory |
770 |
"return a filename for the root directory" |
|
771 |
||
11781
6488fd6cc498
Make AutoDeletedFilename work like Filename
Stefan Vogel <sv@exept.de>
parents:
11763
diff
changeset
|
772 |
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
|
773 |
^ ConcreteClass rootDirectory |
3959 | 774 |
]. |
775 |
||
776 |
"/ fallBack - works on Unix & MSDOS (but not on VMS) |
|
777 |
||
8243 | 778 |
^ self named:(self separatorString) |
3959 | 779 |
|
780 |
" |
|
781 |
Filename rootDirectory |
|
782 |
" |
|
783 |
||
784 |
"Modified: 8.9.1997 / 00:24:15 / cg" |
|
785 |
! |
|
786 |
||
787 |
rootDirectoryOnVolume:aVolumeName |
|
788 |
"return a filename for the root directory on some volume" |
|
789 |
||
11781
6488fd6cc498
Make AutoDeletedFilename work like Filename
Stefan Vogel <sv@exept.de>
parents:
11763
diff
changeset
|
790 |
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
|
791 |
^ ConcreteClass rootDirectoryOnVolume:aVolumeName |
3959 | 792 |
]. |
793 |
||
794 |
"/ fallBack - works on Unix (not on MSDOS or VMS) |
|
795 |
||
796 |
^ self rootDirectory |
|
797 |
||
798 |
" |
|
799 |
Filename rootDirectoryOnVolume:'/phys/idefix' |
|
800 |
Filename rootDirectoryOnVolume:'d:' |
|
801 |
" |
|
802 |
||
803 |
"Modified: / 5.10.1998 / 12:45:39 / cg" |
|
804 |
! |
|
805 |
||
806 |
tempDirectory |
|
807 |
"return the temp directory as a filename. |
|
808 |
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
|
809 |
TMPDIR or TEMPDIR is set, its value defines the name, |
3959 | 810 |
otherwise, '/tmp' is used. (at least on unix ...). |
811 |
||
812 |
Notice: do not hardcode '/tmp' into your programs - things may be |
|
19114 | 813 |
different on other operating systems. Also, the user may want to set the |
814 |
TMPDIR environment variable to have her temp files somewhere else." |
|
3959 | 815 |
|
816 |
|tempDir| |
|
817 |
||
9806 | 818 |
TempDirectory isNil ifTrue:[ |
19114 | 819 |
tempDir := self named:(self defaultTempDirectoryName pathName). |
820 |
tempDir exists ifFalse:[ |
|
821 |
tempDir |
|
822 |
makeDirectory; |
|
823 |
addAccessRights:#(readUser readGroup readOthers |
|
824 |
writeUser writeGroup writeOthers |
|
825 |
executeUser executeGroup executeOthers |
|
826 |
removeOnlyByOwner). |
|
827 |
]. |
|
828 |
TempDirectory := DefaultTempDirectory := tempDir construct:'stx_tmp'. |
|
3959 | 829 |
]. |
10551
4924bf1ce2e3
#tempDirectory - make sure, that it exists
Stefan Vogel <sv@exept.de>
parents:
10546
diff
changeset
|
830 |
|
4924bf1ce2e3
#tempDirectory - make sure, that it exists
Stefan Vogel <sv@exept.de>
parents:
10546
diff
changeset
|
831 |
"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
|
832 |
by a cleanup (cron) job. |
19114 | 833 |
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
|
834 |
|
4924bf1ce2e3
#tempDirectory - make sure, that it exists
Stefan Vogel <sv@exept.de>
parents:
10546
diff
changeset
|
835 |
TempDirectory exists ifFalse:[ |
19114 | 836 |
TempDirectory |
837 |
makeDirectory; |
|
838 |
addAccessRights:#(readUser readGroup readOthers |
|
839 |
writeUser writeGroup writeOthers |
|
840 |
executeUser executeGroup executeOthers |
|
841 |
removeOnlyByOwner). |
|
10551
4924bf1ce2e3
#tempDirectory - make sure, that it exists
Stefan Vogel <sv@exept.de>
parents:
10546
diff
changeset
|
842 |
]. |
9806 | 843 |
^ TempDirectory |
3959 | 844 |
|
845 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
846 |
Filename tempDirectory |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
847 |
Filename tempDirectory pathName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
848 |
Filename tempDirectory exists |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
849 |
Filename tempDirectory isWritable |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
850 |
(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
|
851 |
(Filename tempDirectory construct:'foo') remove |
3959 | 852 |
" |
853 |
||
9806 | 854 |
"Created: / 07-03-1996 / 14:51:18 / cg" |
13781 | 855 |
"Modified: / 07-10-2011 / 18:39:25 / cg" |
11757
a2ce2d0ab680
new Filename class>>#tempFilename
Stefan Vogel <sv@exept.de>
parents:
11748
diff
changeset
|
856 |
! |
a2ce2d0ab680
new Filename class>>#tempFilename
Stefan Vogel <sv@exept.de>
parents:
11748
diff
changeset
|
857 |
|
a2ce2d0ab680
new Filename class>>#tempFilename
Stefan Vogel <sv@exept.de>
parents:
11748
diff
changeset
|
858 |
tempDirectory:aFilename |
17048 | 859 |
"set the default temporary directory. |
860 |
This allows overwriting the automatically determined tmpDirectory |
|
861 |
by a knowledgable stand alone startup program. |
|
19114 | 862 |
Do not use elsewhere (and only if absolutely required)" |
11757
a2ce2d0ab680
new Filename class>>#tempFilename
Stefan Vogel <sv@exept.de>
parents:
11748
diff
changeset
|
863 |
|
a2ce2d0ab680
new Filename class>>#tempFilename
Stefan Vogel <sv@exept.de>
parents:
11748
diff
changeset
|
864 |
|temp| |
a2ce2d0ab680
new Filename class>>#tempFilename
Stefan Vogel <sv@exept.de>
parents:
11748
diff
changeset
|
865 |
|
a2ce2d0ab680
new Filename class>>#tempFilename
Stefan Vogel <sv@exept.de>
parents:
11748
diff
changeset
|
866 |
aFilename isNil ifTrue:[ |
19114 | 867 |
TempDirectory := nil. |
868 |
^ self. |
|
11757
a2ce2d0ab680
new Filename class>>#tempFilename
Stefan Vogel <sv@exept.de>
parents:
11748
diff
changeset
|
869 |
]. |
a2ce2d0ab680
new Filename class>>#tempFilename
Stefan Vogel <sv@exept.de>
parents:
11748
diff
changeset
|
870 |
|
a2ce2d0ab680
new Filename class>>#tempFilename
Stefan Vogel <sv@exept.de>
parents:
11748
diff
changeset
|
871 |
temp := aFilename asFilename. |
a2ce2d0ab680
new Filename class>>#tempFilename
Stefan Vogel <sv@exept.de>
parents:
11748
diff
changeset
|
872 |
self assert:temp isDirectory. |
a2ce2d0ab680
new Filename class>>#tempFilename
Stefan Vogel <sv@exept.de>
parents:
11748
diff
changeset
|
873 |
TempDirectory := temp. |
16382 | 874 |
! |
875 |
||
876 |
trashDirectoryOrNil |
|
877 |
"if the underlying OS uses/supports a trash folder, |
|
878 |
return it. Otherwise return nil. |
|
879 |
Asks the OS for the pathname; for example, on OSX, '~/.Trash' is returned." |
|
880 |
||
881 |
|s| |
|
882 |
||
883 |
s := OperatingSystem getTrashDirectory. |
|
884 |
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
|
885 |
^ nil |
16382 | 886 |
]. |
887 |
^ self named:s |
|
888 |
||
889 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
890 |
Filename desktopDirectory |
16382 | 891 |
" |
892 |
||
893 |
"Created: / 16-05-2007 / 13:18:34 / cg" |
|
16648 | 894 |
! |
895 |
||
896 |
usersPrivateSmalltalkDirectory |
|
897 |
^ Filename homeDirectory / '.smalltalk' |
|
898 |
||
899 |
" |
|
900 |
Filename usersPrivateSmalltalkDirectory |
|
901 |
" |
|
3959 | 902 |
! ! |
903 |
||
2168
649e90de1312
added filesMatching: in class protocol;
Claus Gittinger <cg@exept.de>
parents:
2013
diff
changeset
|
904 |
!Filename class methodsFor:'defaults'! |
649e90de1312
added filesMatching: in class protocol;
Claus Gittinger <cg@exept.de>
parents:
2013
diff
changeset
|
905 |
|
649e90de1312
added filesMatching: in class protocol;
Claus Gittinger <cg@exept.de>
parents:
2013
diff
changeset
|
906 |
concreteClass |
6256 | 907 |
"different subclasses of Filename are used for different |
908 |
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
|
909 |
|
2906 | 910 |
^ ConcreteClass ? self |
2168
649e90de1312
added filesMatching: in class protocol;
Claus Gittinger <cg@exept.de>
parents:
2013
diff
changeset
|
911 |
|
649e90de1312
added filesMatching: in class protocol;
Claus Gittinger <cg@exept.de>
parents:
2013
diff
changeset
|
912 |
"Created: 14.2.1997 / 16:36:13 / cg" |
2906 | 913 |
"Modified: 7.9.1997 / 23:29:20 / cg" |
2168
649e90de1312
added filesMatching: in class protocol;
Claus Gittinger <cg@exept.de>
parents:
2013
diff
changeset
|
914 |
! |
649e90de1312
added filesMatching: in class protocol;
Claus Gittinger <cg@exept.de>
parents:
2013
diff
changeset
|
915 |
|
649e90de1312
added filesMatching: in class protocol;
Claus Gittinger <cg@exept.de>
parents:
2013
diff
changeset
|
916 |
defaultClass |
6256 | 917 |
"different subclasses of Filename are used for different |
918 |
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
|
919 |
|
2906 | 920 |
^ ConcreteClass |
921 |
||
922 |
"Modified: 8.9.1997 / 00:36:01 / cg" |
|
7836 | 923 |
! |
924 |
||
925 |
defaultTempDirectoryName |
|
926 |
"return the default temp directory as a filename. |
|
927 |
This is used, if no special preferences were defined in |
|
928 |
any of the TEMP-environment variables (see tempDirectory)." |
|
929 |
||
11781
6488fd6cc498
Make AutoDeletedFilename work like Filename
Stefan Vogel <sv@exept.de>
parents:
11763
diff
changeset
|
930 |
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
|
931 |
^ ConcreteClass defaultTempDirectoryName |
7836 | 932 |
]. |
933 |
||
10994
1a3776d0b845
always return a fileName from defaultTempDirectoryName
fm
parents:
10969
diff
changeset
|
934 |
^ '/tmp' asFilename |
7836 | 935 |
|
936 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
937 |
Filename defaultTempDirectoryName |
7836 | 938 |
" |
939 |
||
940 |
"Modified: 7.9.1995 / 10:48:31 / claus" |
|
941 |
"Created: 7.3.1996 / 14:51:18 / cg" |
|
942 |
"Modified: 8.9.1997 / 00:24:53 / cg" |
|
2168
649e90de1312
added filesMatching: in class protocol;
Claus Gittinger <cg@exept.de>
parents:
2013
diff
changeset
|
943 |
! ! |
649e90de1312
added filesMatching: in class protocol;
Claus Gittinger <cg@exept.de>
parents:
2013
diff
changeset
|
944 |
|
2922 | 945 |
!Filename class methodsFor:'misc'! |
946 |
||
3077 | 947 |
filterSeps:aFilenameString |
948 |
"ST80 compatibility: |
|
949 |
filter out (invalid) separators in aFilenameString. |
|
950 |
We recommend using #makeLegalFilename" |
|
951 |
||
16762 | 952 |
^ aFilenameString copyReplaceAll:(Character space) with:$_ ifNone:aFilenameString. |
3077 | 953 |
|
954 |
"Created: / 1.11.1997 / 12:39:50 / cg" |
|
3658 | 955 |
"Modified: / 18.7.1998 / 22:53:24 / cg" |
3077 | 956 |
! |
957 |
||
14220
2a3457b016be
Fix the '~/dir/name' resolution fow windows
Stefan Vogel <sv@exept.de>
parents:
14218
diff
changeset
|
958 |
nameWithSpecialExpansions:aString |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
959 |
"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
|
960 |
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
|
961 |
|
2a3457b016be
Fix the '~/dir/name' resolution fow windows
Stefan Vogel <sv@exept.de>
parents:
14218
diff
changeset
|
962 |
|dir user cutIdx idx userInfo| |
2a3457b016be
Fix the '~/dir/name' resolution fow windows
Stefan Vogel <sv@exept.de>
parents:
14218
diff
changeset
|
963 |
|
2a3457b016be
Fix the '~/dir/name' resolution fow windows
Stefan Vogel <sv@exept.de>
parents:
14218
diff
changeset
|
964 |
(aString startsWith:'~') ifFalse:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
965 |
^ aString. |
14220
2a3457b016be
Fix the '~/dir/name' resolution fow windows
Stefan Vogel <sv@exept.de>
parents:
14218
diff
changeset
|
966 |
]. |
2a3457b016be
Fix the '~/dir/name' resolution fow windows
Stefan Vogel <sv@exept.de>
parents:
14218
diff
changeset
|
967 |
|
2a3457b016be
Fix the '~/dir/name' resolution fow windows
Stefan Vogel <sv@exept.de>
parents:
14218
diff
changeset
|
968 |
aString 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
|
969 |
idx := aString indexOf:self separator. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
970 |
idx == 0 ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
971 |
"aString is '~user'" |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
972 |
user := aString copyFrom:2. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
973 |
cutIdx := aString size + 1. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
974 |
] ifFalse:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
975 |
"aString is '~user/something'" |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
976 |
user := aString copyFrom:2 to:(idx - 1). |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
977 |
cutIdx := idx. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
978 |
]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
979 |
user notEmpty ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
980 |
userInfo := OperatingSystem userInfoOf:user. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
981 |
userInfo notNil ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
982 |
dir := userInfo at:#dir ifAbsent:nil. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
983 |
]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
984 |
dir isNil ifTrue:[ |
14220
2a3457b016be
Fix the '~/dir/name' resolution fow windows
Stefan Vogel <sv@exept.de>
parents:
14218
diff
changeset
|
985 |
"/ ('Filename [info]: unknown user: ' , user) infoPrintCR. |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
986 |
^ aString |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
987 |
]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
988 |
]. |
14220
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 |
dir isNil ifTrue:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
991 |
"aString is '~' or '~/'" |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
992 |
dir := OperatingSystem getHomeDirectory. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
993 |
cutIdx := 2. |
14220
2a3457b016be
Fix the '~/dir/name' resolution fow windows
Stefan Vogel <sv@exept.de>
parents:
14218
diff
changeset
|
994 |
]. |
2a3457b016be
Fix the '~/dir/name' resolution fow windows
Stefan Vogel <sv@exept.de>
parents:
14218
diff
changeset
|
995 |
|
2a3457b016be
Fix the '~/dir/name' resolution fow windows
Stefan Vogel <sv@exept.de>
parents:
14218
diff
changeset
|
996 |
^ dir , (aString copyFrom:cutIdx) |
2a3457b016be
Fix the '~/dir/name' resolution fow windows
Stefan Vogel <sv@exept.de>
parents:
14218
diff
changeset
|
997 |
|
2a3457b016be
Fix the '~/dir/name' resolution fow windows
Stefan Vogel <sv@exept.de>
parents:
14218
diff
changeset
|
998 |
" |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
999 |
Filename new nameWithSpecialExpansions:'~' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1000 |
Filename new nameWithSpecialExpansions:'~\work' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1001 |
Filename new nameWithSpecialExpansions:'~stefan' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1002 |
Filename new nameWithSpecialExpansions:'~stefan\work' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1003 |
Filename new nameWithSpecialExpansions:'~foo' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1004 |
Filename new nameWithSpecialExpansions:'~foo\bar' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1005 |
" |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1006 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1007 |
" |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1008 |
UnixFilename new nameWithSpecialExpansions:'~' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1009 |
UnixFilename new nameWithSpecialExpansions:'~/work' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1010 |
UnixFilename new nameWithSpecialExpansions:'~stefan' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1011 |
UnixFilename new nameWithSpecialExpansions:'~stefan/work' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1012 |
UnixFilename new nameWithSpecialExpansions:'~foo' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1013 |
UnixFilename new nameWithSpecialExpansions:'~foo/bar' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1014 |
" |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1015 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1016 |
" |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1017 |
PCFilename new nameWithSpecialExpansions:'~' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1018 |
PCFilename new nameWithSpecialExpansions:'~\work' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1019 |
PCFilename new nameWithSpecialExpansions:'~stefan' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1020 |
PCFilename new nameWithSpecialExpansions:'~stefan\work' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1021 |
PCFilename new nameWithSpecialExpansions:'~foo' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1022 |
PCFilename new nameWithSpecialExpansions:'~foo\bar' |
14220
2a3457b016be
Fix the '~/dir/name' resolution fow windows
Stefan Vogel <sv@exept.de>
parents:
14218
diff
changeset
|
1023 |
" |
2a3457b016be
Fix the '~/dir/name' resolution fow windows
Stefan Vogel <sv@exept.de>
parents:
14218
diff
changeset
|
1024 |
! |
2a3457b016be
Fix the '~/dir/name' resolution fow windows
Stefan Vogel <sv@exept.de>
parents:
14218
diff
changeset
|
1025 |
|
16999 | 1026 |
possiblyQuotedPathname:aPath |
1027 |
"return a filename path usable as command line argument, |
|
1028 |
by quoting in double quotes if there are any embedded special characters. |
|
1029 |
On Unix systems, special characters might also be prefixed by a backslash character." |
|
1030 |
||
1031 |
(aPath startsWith:'"') ifFalse:[ |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1032 |
(aPath includes:Character space) ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1033 |
^ '"',aPath,'"' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1034 |
]. |
16999 | 1035 |
]. |
1036 |
^ aPath |
|
1037 |
||
1038 |
||
1039 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1040 |
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
|
1041 |
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
|
1042 |
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
|
1043 |
" |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1044 |
! |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1045 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1046 |
suggest:aFilenameString |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1047 |
"return a fileNamestring based on the argument, |
3077 | 1048 |
which is legal on the current platform." |
1049 |
||
1050 |
^ self canonicalize:aFilenameString |
|
1051 |
||
1052 |
"Created: / 1.11.1997 / 12:42:39 / cg" |
|
2922 | 1053 |
! ! |
1054 |
||
1859
7f6040320daf
changes for new return from OS>>infoOf:
Claus Gittinger <cg@exept.de>
parents:
1614
diff
changeset
|
1055 |
!Filename class methodsFor:'queries'! |
2 | 1056 |
|
10663
b95f903be43e
Make temp dir accessible to all users
Stefan Vogel <sv@exept.de>
parents:
10583
diff
changeset
|
1057 |
currentDirectoryName |
b95f903be43e
Make temp dir accessible to all users
Stefan Vogel <sv@exept.de>
parents:
10583
diff
changeset
|
1058 |
"return a filename for the current directory" |
b95f903be43e
Make temp dir accessible to all users
Stefan Vogel <sv@exept.de>
parents:
10583
diff
changeset
|
1059 |
|
11781
6488fd6cc498
Make AutoDeletedFilename work like Filename
Stefan Vogel <sv@exept.de>
parents:
11763
diff
changeset
|
1060 |
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
|
1061 |
^ ConcreteClass currentDirectoryName |
10663
b95f903be43e
Make temp dir accessible to all users
Stefan Vogel <sv@exept.de>
parents:
10583
diff
changeset
|
1062 |
]. |
b95f903be43e
Make temp dir accessible to all users
Stefan Vogel <sv@exept.de>
parents:
10583
diff
changeset
|
1063 |
|
b95f903be43e
Make temp dir accessible to all users
Stefan Vogel <sv@exept.de>
parents:
10583
diff
changeset
|
1064 |
"/ 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
|
1065 |
|
b95f903be43e
Make temp dir accessible to all users
Stefan Vogel <sv@exept.de>
parents:
10583
diff
changeset
|
1066 |
^ '.' |
b95f903be43e
Make temp dir accessible to all users
Stefan Vogel <sv@exept.de>
parents:
10583
diff
changeset
|
1067 |
|
b95f903be43e
Make temp dir accessible to all users
Stefan Vogel <sv@exept.de>
parents:
10583
diff
changeset
|
1068 |
" |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1069 |
Filename currentDirectoryName |
10663
b95f903be43e
Make temp dir accessible to all users
Stefan Vogel <sv@exept.de>
parents:
10583
diff
changeset
|
1070 |
" |
b95f903be43e
Make temp dir accessible to all users
Stefan Vogel <sv@exept.de>
parents:
10583
diff
changeset
|
1071 |
|
b95f903be43e
Make temp dir accessible to all users
Stefan Vogel <sv@exept.de>
parents:
10583
diff
changeset
|
1072 |
"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
|
1073 |
"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
|
1074 |
! |
b95f903be43e
Make temp dir accessible to all users
Stefan Vogel <sv@exept.de>
parents:
10583
diff
changeset
|
1075 |
|
b95f903be43e
Make temp dir accessible to all users
Stefan Vogel <sv@exept.de>
parents:
10583
diff
changeset
|
1076 |
defaultDirectoryName |
b95f903be43e
Make temp dir accessible to all users
Stefan Vogel <sv@exept.de>
parents:
10583
diff
changeset
|
1077 |
"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
|
1078 |
|
b95f903be43e
Make temp dir accessible to all users
Stefan Vogel <sv@exept.de>
parents:
10583
diff
changeset
|
1079 |
^ self defaultDirectory name |
b95f903be43e
Make temp dir accessible to all users
Stefan Vogel <sv@exept.de>
parents:
10583
diff
changeset
|
1080 |
|
b95f903be43e
Make temp dir accessible to all users
Stefan Vogel <sv@exept.de>
parents:
10583
diff
changeset
|
1081 |
" |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1082 |
Filename defaultDirectoryName |
10663
b95f903be43e
Make temp dir accessible to all users
Stefan Vogel <sv@exept.de>
parents:
10583
diff
changeset
|
1083 |
" |
b95f903be43e
Make temp dir accessible to all users
Stefan Vogel <sv@exept.de>
parents:
10583
diff
changeset
|
1084 |
! |
b95f903be43e
Make temp dir accessible to all users
Stefan Vogel <sv@exept.de>
parents:
10583
diff
changeset
|
1085 |
|
2963 | 1086 |
directorySuffix |
1087 |
"Return the OS dependent directory suffix string, or nil if there is none. |
|
1088 |
The default is nil here, redefined for VMS" |
|
1089 |
||
11781
6488fd6cc498
Make AutoDeletedFilename work like Filename
Stefan Vogel <sv@exept.de>
parents:
11763
diff
changeset
|
1090 |
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
|
1091 |
^ ConcreteClass directorySuffix |
2963 | 1092 |
]. |
1093 |
||
1094 |
^ nil |
|
1095 |
! |
|
1096 |
||
1523 | 1097 |
errorReporter |
1098 |
"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
|
1099 |
|
1523 | 1100 |
^ FileStream |
1101 |
||
1102 |
"Created: 2.7.1996 / 12:30:25 / stefan" |
|
1103 |
! |
|
1104 |
||
440 | 1105 |
filenameCompletionFor:aString directory:inDirectory directoriesOnly:directoriesOnly filesOnly:filesOnly ifMultiple:aBlock |
1106 |
"perform filename completion on aString in some directory; |
|
1107 |
return the longest matching filename prefix as a string. |
|
1318 | 1108 |
The boolean directoriesOnly and filesOnly control respectively, |
1109 |
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
|
1110 |
If multiple files match, the exception block aBlock is evaluated with a |
1318 | 1111 |
filename representing the directory (where the match was done) as argument. |
440 | 1112 |
(this may be different from the inDirectory argument, if aString is absolute |
1113 |
or starts with ../)" |
|
1114 |
||
11781
6488fd6cc498
Make AutoDeletedFilename work like Filename
Stefan Vogel <sv@exept.de>
parents:
11763
diff
changeset
|
1115 |
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
|
1116 |
^ ConcreteClass |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1117 |
filenameCompletionFor:aString |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1118 |
directory:inDirectory |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1119 |
directoriesOnly:directoriesOnly |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1120 |
filesOnly:filesOnly |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1121 |
ifMultiple:aBlock |
2906 | 1122 |
]. |
6839
d5bc53f68bab
can evaluate block for matchList on filename completition
penk
parents:
6826
diff
changeset
|
1123 |
^ 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
|
1124 |
! |
d5bc53f68bab
can evaluate block for matchList on filename completition
penk
parents:
6826
diff
changeset
|
1125 |
|
d5bc53f68bab
can evaluate block for matchList on filename completition
penk
parents:
6826
diff
changeset
|
1126 |
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
|
1127 |
"perform filename completion on aString in some directory; |
d5bc53f68bab
can evaluate block for matchList on filename completition
penk
parents:
6826
diff
changeset
|
1128 |
return the longest matching filename prefix as a string. |
d5bc53f68bab
can evaluate block for matchList on filename completition
penk
parents:
6826
diff
changeset
|
1129 |
The boolean directoriesOnly and filesOnly control respectively, |
d5bc53f68bab
can evaluate block for matchList on filename completition
penk
parents:
6826
diff
changeset
|
1130 |
if only directories or only regular files are to be considered for completion. |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1131 |
If multiple files match, the exception block aBlock is evaluated with a |
6839
d5bc53f68bab
can evaluate block for matchList on filename completition
penk
parents:
6826
diff
changeset
|
1132 |
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
|
1133 |
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
|
1134 |
(list of matched filenames) as arguments. |
d5bc53f68bab
can evaluate block for matchList on filename completition
penk
parents:
6826
diff
changeset
|
1135 |
(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
|
1136 |
or starts with ../)" |
d5bc53f68bab
can evaluate block for matchList on filename completition
penk
parents:
6826
diff
changeset
|
1137 |
|
d5bc53f68bab
can evaluate block for matchList on filename completition
penk
parents:
6826
diff
changeset
|
1138 |
|s f matchSet nMatch name dir isAbsolute sep| |
2906 | 1139 |
|
5642
87ad71e66acb
fileNameCompletion now does exactly that;
Claus Gittinger <cg@exept.de>
parents:
5602
diff
changeset
|
1140 |
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
|
1141 |
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
|
1142 |
^ '' |
440 | 1143 |
]. |
1144 |
||
5642
87ad71e66acb
fileNameCompletion now does exactly that;
Claus Gittinger <cg@exept.de>
parents:
5602
diff
changeset
|
1145 |
sep := self separator. |
87ad71e66acb
fileNameCompletion now does exactly that;
Claus Gittinger <cg@exept.de>
parents:
5602
diff
changeset
|
1146 |
|
87ad71e66acb
fileNameCompletion now does exactly that;
Claus Gittinger <cg@exept.de>
parents:
5602
diff
changeset
|
1147 |
"/ 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
|
1148 |
|
87ad71e66acb
fileNameCompletion now does exactly that;
Claus Gittinger <cg@exept.de>
parents:
5602
diff
changeset
|
1149 |
f := self named:aString. |
3854
a13d0d489365
care for absolute fileNames in fileNameCompletion.
Claus Gittinger <cg@exept.de>
parents:
3852
diff
changeset
|
1150 |
isAbsolute := f isAbsolute. |
6556
367bc84f51fc
filename completion better if an empty basename is shown
Claus Gittinger <cg@exept.de>
parents:
6529
diff
changeset
|
1151 |
matchSet := f filenameCompletionIn:inDirectory. "/ BAD DESIGN: has side effect on f |
440 | 1152 |
dir := f directory. |
1153 |
||
4131
f370ebc75bf9
fixed filenameCompletion for caseless systems (win32)
Claus Gittinger <cg@exept.de>
parents:
3978
diff
changeset
|
1154 |
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
|
1155 |
|f isDir| |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1156 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1157 |
isAbsolute ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1158 |
f := aFilename asFilename |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1159 |
] ifFalse:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1160 |
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
|
1161 |
]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1162 |
isDir := f isDirectory. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1163 |
directoriesOnly ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1164 |
isDir |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1165 |
] ifFalse:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1166 |
filesOnly ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1167 |
isDir not |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1168 |
] ifFalse:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1169 |
true |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1170 |
] |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1171 |
] |
440 | 1172 |
]. |
1173 |
||
6803 | 1174 |
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
|
1175 |
(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
|
1176 |
" |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1177 |
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
|
1178 |
" |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1179 |
aMultipleBlock notNil ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1180 |
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
|
1181 |
]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1182 |
aBlock value:f |
440 | 1183 |
]. |
4131
f370ebc75bf9
fixed filenameCompletion for caseless systems (win32)
Claus Gittinger <cg@exept.de>
parents:
3978
diff
changeset
|
1184 |
|
440 | 1185 |
" |
1186 |
even with more than one possible completion, |
|
1187 |
f's name is now the common prefix |
|
1188 |
" |
|
1189 |
name := f asString. |
|
4323
8b3752e1b060
add trailing filename separator if match is a directory
Claus Gittinger <cg@exept.de>
parents:
4246
diff
changeset
|
1190 |
|
8b3752e1b060
add trailing filename separator if match is a directory
Claus Gittinger <cg@exept.de>
parents:
4246
diff
changeset
|
1191 |
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
|
1192 |
" |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1193 |
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
|
1194 |
" |
3752 | 1195 |
"/ 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
|
1196 |
false "directoriesOnly" ifFalse:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1197 |
(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
|
1198 |
(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
|
1199 |
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
|
1200 |
]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1201 |
]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1202 |
] |
440 | 1203 |
]. |
1204 |
||
5642
87ad71e66acb
fileNameCompletion now does exactly that;
Claus Gittinger <cg@exept.de>
parents:
5602
diff
changeset
|
1205 |
s := name. |
440 | 1206 |
|
1207 |
"/ special: if there was no change, and the string represented |
|
1208 |
"/ 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
|
1209 |
((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
|
1210 |
(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
|
1211 |
(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
|
1212 |
^ s , sep asString |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1213 |
] |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1214 |
]. |
440 | 1215 |
]. |
1216 |
||
1217 |
^ s |
|
1318 | 1218 |
|
4131
f370ebc75bf9
fixed filenameCompletion for caseless systems (win32)
Claus Gittinger <cg@exept.de>
parents:
3978
diff
changeset
|
1219 |
"Modified: / 30.4.1999 / 09:40:13 / cg" |
615 | 1220 |
! |
1221 |
||
2168
649e90de1312
added filesMatching: in class protocol;
Claus Gittinger <cg@exept.de>
parents:
2013
diff
changeset
|
1222 |
filesMatching:aPattern |
649e90de1312
added filesMatching: in class protocol;
Claus Gittinger <cg@exept.de>
parents:
2013
diff
changeset
|
1223 |
"return a collection of strings, representing the names |
649e90de1312
added filesMatching: in class protocol;
Claus Gittinger <cg@exept.de>
parents:
2013
diff
changeset
|
1224 |
of files matching aPattern. |
2547
4467d25fe057
filesMatching class method returns names as given
Claus Gittinger <cg@exept.de>
parents:
2503
diff
changeset
|
1225 |
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
|
1226 |
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
|
1227 |
The returned strings are the expanded names, in the same form |
2550 | 1228 |
as given in pattern. |
1229 |
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
|
1230 |
|
4467d25fe057
filesMatching class method returns names as given
Claus Gittinger <cg@exept.de>
parents:
2503
diff
changeset
|
1231 |
|basePattern dir d files| |
2168
649e90de1312
added filesMatching: in class protocol;
Claus Gittinger <cg@exept.de>
parents:
2013
diff
changeset
|
1232 |
|
11781
6488fd6cc498
Make AutoDeletedFilename work like Filename
Stefan Vogel <sv@exept.de>
parents:
11763
diff
changeset
|
1233 |
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
|
1234 |
^ ConcreteClass filesMatching:aPattern |
2906 | 1235 |
]. |
1236 |
||
1237 |
"/ the following works on Unix & MSDOS (but not on openVMS) |
|
1238 |
||
2168
649e90de1312
added filesMatching: in class protocol;
Claus Gittinger <cg@exept.de>
parents:
2013
diff
changeset
|
1239 |
dir := aPattern asFilename directoryName. |
2547
4467d25fe057
filesMatching class method returns names as given
Claus Gittinger <cg@exept.de>
parents:
2503
diff
changeset
|
1240 |
basePattern := aPattern asFilename baseName. |
4467d25fe057
filesMatching class method returns names as given
Claus Gittinger <cg@exept.de>
parents:
2503
diff
changeset
|
1241 |
d := dir asFilename. |
2548
b6182b559ea2
made filesMatching ST-80 compatible.
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
1242 |
files := dir asFilename filesMatchingWithoutDotDirs:basePattern. |
2547
4467d25fe057
filesMatching class method returns names as given
Claus Gittinger <cg@exept.de>
parents:
2503
diff
changeset
|
1243 |
dir = '.' ifTrue:[^ files]. |
4467d25fe057
filesMatching class method returns names as given
Claus Gittinger <cg@exept.de>
parents:
2503
diff
changeset
|
1244 |
^ files collect:[:base | d constructString:base]. |
2168
649e90de1312
added filesMatching: in class protocol;
Claus Gittinger <cg@exept.de>
parents:
2013
diff
changeset
|
1245 |
|
649e90de1312
added filesMatching: in class protocol;
Claus Gittinger <cg@exept.de>
parents:
2013
diff
changeset
|
1246 |
" |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1247 |
Filename filesMatching:'*' |
2168
649e90de1312
added filesMatching: in class protocol;
Claus Gittinger <cg@exept.de>
parents:
2013
diff
changeset
|
1248 |
Filename filesMatching:'/*' |
2547
4467d25fe057
filesMatching class method returns names as given
Claus Gittinger <cg@exept.de>
parents:
2503
diff
changeset
|
1249 |
Filename filesMatching:'/usr/local/*' |
2168
649e90de1312
added filesMatching: in class protocol;
Claus Gittinger <cg@exept.de>
parents:
2013
diff
changeset
|
1250 |
" |
649e90de1312
added filesMatching: in class protocol;
Claus Gittinger <cg@exept.de>
parents:
2013
diff
changeset
|
1251 |
|
2906 | 1252 |
"Modified: 8.9.1997 / 00:32:31 / cg" |
615 | 1253 |
! |
1254 |
||
11781
6488fd6cc498
Make AutoDeletedFilename work like Filename
Stefan Vogel <sv@exept.de>
parents:
11763
diff
changeset
|
1255 |
isAbstract |
6488fd6cc498
Make AutoDeletedFilename work like Filename
Stefan Vogel <sv@exept.de>
parents:
11763
diff
changeset
|
1256 |
"return true, if this is not a concrete class" |
6488fd6cc498
Make AutoDeletedFilename work like Filename
Stefan Vogel <sv@exept.de>
parents:
11763
diff
changeset
|
1257 |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1258 |
^ self == Filename |
11781
6488fd6cc498
Make AutoDeletedFilename work like Filename
Stefan Vogel <sv@exept.de>
parents:
11763
diff
changeset
|
1259 |
! |
6488fd6cc498
Make AutoDeletedFilename work like Filename
Stefan Vogel <sv@exept.de>
parents:
11763
diff
changeset
|
1260 |
|
2903 | 1261 |
isBadCharacter:aCharacter |
1262 |
"return true, if aCharacter is unallowed in a filename." |
|
1263 |
||
11781
6488fd6cc498
Make AutoDeletedFilename work like Filename
Stefan Vogel <sv@exept.de>
parents:
11763
diff
changeset
|
1264 |
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
|
1265 |
^ ConcreteClass isBadCharacter:aCharacter |
2906 | 1266 |
]. |
1267 |
||
8095
bfbd1309a4a6
Use #codePoint instead of deprecated #asciiValue
Stefan Vogel <sv@exept.de>
parents:
8036
diff
changeset
|
1268 |
^ aCharacter isControlCharacter |
2903 | 1269 |
! |
1270 |
||
1271 |
isCaseSensitive |
|
1272 |
"return true, if filenames are case sensitive. |
|
1273 |
We ask the OS about this, to be independent here." |
|
1274 |
||
11781
6488fd6cc498
Make AutoDeletedFilename work like Filename
Stefan Vogel <sv@exept.de>
parents:
11763
diff
changeset
|
1275 |
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
|
1276 |
^ ConcreteClass isCaseSensitive |
2906 | 1277 |
]. |
1278 |
||
2903 | 1279 |
^ OperatingSystem caseSensitiveFilenames |
2906 | 1280 |
|
1281 |
"Modified: 8.9.1997 / 00:33:32 / cg" |
|
2903 | 1282 |
! |
1283 |
||
615 | 1284 |
localNameStringFrom:aString |
1285 |
"ST-80 compatibility. |
|
1286 |
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
|
1287 |
GUESS: |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1288 |
does it strip off any volume characters and make a path relative ?" |
2922 | 1289 |
|
11781
6488fd6cc498
Make AutoDeletedFilename work like Filename
Stefan Vogel <sv@exept.de>
parents:
11763
diff
changeset
|
1290 |
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
|
1291 |
^ ConcreteClass localNameStringFrom:aString |
2906 | 1292 |
]. |
1293 |
||
15227 | 1294 |
^ aString withoutPrefix:self separatorString |
615 | 1295 |
|
1296 |
"Modified: 7.9.1995 / 10:44:56 / claus" |
|
2906 | 1297 |
"Modified: 8.9.1997 / 00:33:51 / cg" |
615 | 1298 |
! |
1299 |
||
2908 | 1300 |
maxComponentLength |
1301 |
"return the maximum number of characters a filename component may |
|
1302 |
be in size. This depends on the OperatingSystem." |
|
1303 |
||
11781
6488fd6cc498
Make AutoDeletedFilename work like Filename
Stefan Vogel <sv@exept.de>
parents:
11763
diff
changeset
|
1304 |
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
|
1305 |
^ ConcreteClass maxComponentLength |
2908 | 1306 |
]. |
1307 |
^ OperatingSystem maxFileNameLength |
|
1308 |
! |
|
1309 |
||
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1310 |
maxLength |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1311 |
"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
|
1312 |
This depends on the OperatingSystem." |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1313 |
|
11781
6488fd6cc498
Make AutoDeletedFilename work like Filename
Stefan Vogel <sv@exept.de>
parents:
11763
diff
changeset
|
1314 |
self isAbstract ifTrue:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1315 |
^ ConcreteClass maxLength |
2908 | 1316 |
]. |
1317 |
^ OperatingSystem maxPathLength |
|
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1318 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1319 |
"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
|
1320 |
"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
|
1321 |
! |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1322 |
|
3171 | 1323 |
nullFilename |
1324 |
"Return the OS dependent filename for /dev/null, or nil if there is none. |
|
1325 |
The default is nil here" |
|
1326 |
||
11781
6488fd6cc498
Make AutoDeletedFilename work like Filename
Stefan Vogel <sv@exept.de>
parents:
11763
diff
changeset
|
1327 |
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
|
1328 |
^ ConcreteClass nullFilename |
3171 | 1329 |
]. |
1330 |
||
8754 | 1331 |
^ OperatingSystem getNullDevice |
3171 | 1332 |
|
1333 |
"Created: / 12.1.1998 / 12:15:30 / stefan" |
|
1334 |
! |
|
1335 |
||
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1336 |
parentDirectoryName |
615 | 1337 |
"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
|
1338 |
This is '..' for unix and dos-like systems. |
615 | 1339 |
(there may be more in the future." |
1340 |
||
11781
6488fd6cc498
Make AutoDeletedFilename work like Filename
Stefan Vogel <sv@exept.de>
parents:
11763
diff
changeset
|
1341 |
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
|
1342 |
^ ConcreteClass parentDirectoryName |
2906 | 1343 |
]. |
1344 |
||
1345 |
^ OperatingSystem parentDirectoryName |
|
1346 |
||
1347 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1348 |
Filename parentDirectoryName |
2906 | 1349 |
" |
1350 |
||
1351 |
"Modified: 8.9.1997 / 00:34:39 / cg" |
|
615 | 1352 |
! |
1353 |
||
1354 |
separator |
|
1355 |
"return the file/directory separator. |
|
15246 | 1356 |
This is to be redefined in concrete classes." |
1357 |
||
1358 |
^ ConcreteClass separator |
|
8243 | 1359 |
|
1360 |
" |
|
8754 | 1361 |
Filename separator |
1362 |
PCFilename separator |
|
8243 | 1363 |
" |
2906 | 1364 |
|
1365 |
"Modified: 8.9.1997 / 00:20:28 / cg" |
|
615 | 1366 |
! |
1367 |
||
8243 | 1368 |
separatorString |
1369 |
"return the file/directory separator as a string." |
|
1370 |
||
1371 |
^ self separator asString |
|
1372 |
||
1373 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1374 |
Filename separatorString |
8243 | 1375 |
" |
1376 |
! |
|
1377 |
||
615 | 1378 |
suffixSeparator |
1379 |
"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
|
1380 |
Usually, this is $. for unix-like and msdos systems |
1318 | 1381 |
(there is currently no known system, where this differs)" |
615 | 1382 |
|
1383 |
^ $. |
|
1384 |
||
1385 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1386 |
Filename suffixSeparator |
615 | 1387 |
" |
1388 |
||
1389 |
"Modified: 7.9.1995 / 11:10:43 / claus" |
|
1318 | 1390 |
"Modified: 30.4.1996 / 12:14:25 / cg" |
615 | 1391 |
! |
1392 |
||
2906 | 1393 |
tempFileNameTemplate |
1394 |
"return a template for temporary files. |
|
1395 |
This is expanded with the current processID and a sequenceNumber |
|
1396 |
to generate a unique filename." |
|
1397 |
||
11781
6488fd6cc498
Make AutoDeletedFilename work like Filename
Stefan Vogel <sv@exept.de>
parents:
11763
diff
changeset
|
1398 |
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
|
1399 |
^ ConcreteClass tempFileNameTemplate |
2906 | 1400 |
]. |
1401 |
||
1402 |
^ 'stxtmp_%1_%2' |
|
1403 |
||
1404 |
"Created: 8.9.1997 / 00:01:46 / cg" |
|
1405 |
"Modified: 8.9.1997 / 00:35:02 / cg" |
|
1406 |
! |
|
1407 |
||
615 | 1408 |
volumes |
1409 |
"ST-80 compatibility. |
|
2896 | 1410 |
GUESS: does it return the available drives on MSDOS systems ? |
1411 |
Q: what does this do on Unix systems ? (used in FileNavigator-goody)." |
|
1412 |
||
11781
6488fd6cc498
Make AutoDeletedFilename work like Filename
Stefan Vogel <sv@exept.de>
parents:
11763
diff
changeset
|
1413 |
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
|
1414 |
^ ConcreteClass volumes |
2906 | 1415 |
]. |
1416 |
||
2896 | 1417 |
^ OperatingSystem getDriveList |
615 | 1418 |
|
8679 | 1419 |
" |
1420 |
Filename volumes |
|
1421 |
" |
|
615 | 1422 |
! ! |
1423 |
||
6383 | 1424 |
!Filename class methodsFor:'utilities'! |
1425 |
||
16389 | 1426 |
canonicalize:aPathString |
1427 |
"convert the argument, aPathString to a good format. |
|
1428 |
This should eliminate useless directory components (i.e. '././') |
|
1429 |
and useless tree walks (i.e. '../foo/..')." |
|
1430 |
||
1431 |
^ self nameFromComponents:(self canonicalizedNameComponents:aPathString) |
|
1432 |
||
1433 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1434 |
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
|
1435 |
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
|
1436 |
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
|
1437 |
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
|
1438 |
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
|
1439 |
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
|
1440 |
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
|
1441 |
Filename canonicalize:'cg/../../..' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1442 |
Filename canonicalize:'./' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1443 |
Filename canonicalize:'/home/.' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1444 |
Filename canonicalize:'/home/../..' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1445 |
Filename canonicalize:'//foo' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1446 |
Filename canonicalize:'///foo' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1447 |
Filename canonicalize:'//foo//bar' |
16389 | 1448 |
" |
1449 |
! |
|
1450 |
||
1451 |
canonicalizedNameComponents: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 |
Answer a sequenceable collection of name components." |
|
1457 |
||
1458 |
|comps newComps rootName dotDot dot| |
|
1459 |
||
1460 |
dotDot := self parentDirectoryName. |
|
1461 |
dot := self currentDirectoryName. |
|
1462 |
rootName := self separatorString. |
|
1463 |
||
1464 |
comps := self components:aPathString. |
|
1465 |
newComps := OrderedCollection new:comps size. |
|
1466 |
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
|
1467 |
eachComponent ~= dot ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1468 |
eachComponent = dotDot ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1469 |
(newComps isEmpty |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1470 |
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
|
1471 |
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
|
1472 |
newComps add:eachComponent |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1473 |
] ifFalse:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1474 |
newComps removeLast |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1475 |
]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1476 |
] ifFalse:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1477 |
newComps add:eachComponent |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1478 |
]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1479 |
] |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1480 |
]. |
16389 | 1481 |
"/ add current Directory if empty |
1482 |
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
|
1483 |
newComps add:dot. |
16389 | 1484 |
]. |
1485 |
^ newComps |
|
1486 |
||
1487 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1488 |
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
|
1489 |
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
|
1490 |
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
|
1491 |
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
|
1492 |
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
|
1493 |
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
|
1494 |
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
|
1495 |
Filename canonicalizedNameComponents:'cg/../../..' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1496 |
Filename canonicalizedNameComponents:'/' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1497 |
Filename canonicalizedNameComponents:'./' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1498 |
Filename canonicalizedNameComponents:'/.' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1499 |
Filename canonicalizedNameComponents:'/home/.' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1500 |
Filename canonicalizedNameComponents:'/home' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1501 |
Filename canonicalizedNameComponents:'/home/../..' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1502 |
Filename canonicalizedNameComponents:'//foo' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1503 |
Filename canonicalizedNameComponents:'///foo' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1504 |
Filename canonicalizedNameComponents:'//foo//bar' |
16389 | 1505 |
" |
1506 |
! |
|
1507 |
||
1508 |
components:aString |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1509 |
"separate the pathName given by aString into |
16578 | 1510 |
a collection containing the directory components and the file's name as |
16389 | 1511 |
the final component. |
1512 |
If the argument names an absolute path, the first component will be the |
|
1513 |
name of the root directory (i.e. '/')." |
|
1514 |
||
1515 |
|sep f vol rest components| |
|
1516 |
||
1517 |
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
|
1518 |
^ ConcreteClass components:aString |
16389 | 1519 |
]. |
1520 |
||
1521 |
"/ the following works on Unix & MSDOS (but not on openVMS) |
|
1522 |
"/ However, MSDOS drive-letters and network drives are |
|
1523 |
"/ not correctly handled here. |
|
1524 |
||
1525 |
sep := self separator. |
|
1526 |
f := aString asFilename. |
|
1527 |
vol := f volume. |
|
1528 |
vol 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
|
1529 |
rest := f localPathName. |
16389 | 1530 |
] ifFalse:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1531 |
rest := aString |
16389 | 1532 |
]. |
1533 |
||
1534 |
components := rest asCollectionOfSubstringsSeparatedBy:sep. |
|
1535 |
(rest startsWith:sep) ifTrue:[ |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1536 |
"first was a separator - root directory - restore" |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1537 |
(rest size > 1 and:[rest second = sep and:[vol isEmptyOrNil]]) ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1538 |
"keep \\ for windows network paths" |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1539 |
components at:1 put:(String with:sep with:sep). |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1540 |
] ifFalse:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1541 |
components at:1 put:sep asString. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1542 |
]. |
16389 | 1543 |
]. |
1544 |
components := components select:[:each| each notEmpty]. |
|
1545 |
||
1546 |
"/ prepend volume to first component (the root directory) |
|
1547 |
vol 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
|
1548 |
components at:1 put:(vol , (components at:1)). |
16389 | 1549 |
]. |
1550 |
^ components |
|
1551 |
||
1552 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1553 |
Filename components:'/foo/bar/baz' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1554 |
Filename components:'/' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1555 |
Filename components:'//' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1556 |
Filename components:'foo/bar/baz' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1557 |
Filename components:'foo/bar' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1558 |
Filename components:'foo' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1559 |
Filename components:'/foo' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1560 |
Filename components:'//foo' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1561 |
Filename components:'' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1562 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1563 |
Filename components:'\' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1564 |
Filename components:'\foo' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1565 |
Filename components:'\foo\' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1566 |
Filename components:'\foo\bar' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1567 |
Filename components:'\foo\bar\' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1568 |
Filename components:'c:' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1569 |
Filename components:'c:\' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1570 |
Filename components:'c:\foo' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1571 |
Filename components:'c:\foo\' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1572 |
Filename components:'c:\foo\bar' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1573 |
Filename components:'c:\foo\bar\' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1574 |
Filename components:'\\idefix' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1575 |
Filename components:'\\idefix\home' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1576 |
Filename components:'\\idefix\home\bar' |
16389 | 1577 |
" |
1578 |
||
1579 |
"Modified: / 24.9.1998 / 19:10:52 / cg" |
|
1580 |
! |
|
1581 |
||
6802 | 1582 |
nameFromComponents:aCollectionOfDirectoryNames |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1583 |
"return a filenameString from components given in aCollectionOfDirectoryNames. |
6802 | 1584 |
If the first component is the name of the root directory (i.e. '/'), |
1585 |
an absolute path-string is returned." |
|
1586 |
||
1587 |
|sep s| |
|
1588 |
||
11781
6488fd6cc498
Make AutoDeletedFilename work like Filename
Stefan Vogel <sv@exept.de>
parents:
11763
diff
changeset
|
1589 |
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
|
1590 |
^ ConcreteClass nameFromComponents:aCollectionOfDirectoryNames |
6802 | 1591 |
]. |
1592 |
||
1593 |
"/ fallBack - works on Unix & MSDOS |
|
1594 |
||
8243 | 1595 |
sep := self separatorString. |
6802 | 1596 |
s := ''. |
1597 |
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
|
1598 |
index == 1 ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1599 |
s := component. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1600 |
] ifFalse:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1601 |
(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
|
1602 |
s := s , component |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1603 |
] ifFalse:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1604 |
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
|
1605 |
] |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1606 |
]. |
6802 | 1607 |
]. |
1608 |
^ s |
|
1609 |
||
1610 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1611 |
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
|
1612 |
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
|
1613 |
Filename nameFromComponents:#('/') |
7074 | 1614 |
|
1615 |
|comps| |
|
1616 |
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
|
1617 |
Filename nameFromComponents:comps |
7074 | 1618 |
|
1619 |
|comps| |
|
1620 |
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
|
1621 |
Filename nameFromComponents:comps |
7074 | 1622 |
|
1623 |
|comps| |
|
1624 |
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
|
1625 |
Filename nameFromComponents:comps |
7074 | 1626 |
|
1627 |
|comps| |
|
1628 |
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
|
1629 |
Filename nameFromComponents:comps |
7074 | 1630 |
|
1631 |
|comps| |
|
1632 |
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
|
1633 |
Filename nameFromComponents:comps |
7074 | 1634 |
|
1635 |
|comps| |
|
1636 |
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
|
1637 |
Filename nameFromComponents:comps |
7074 | 1638 |
|
1639 |
|comps| |
|
1640 |
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
|
1641 |
Filename nameFromComponents:comps |
6802 | 1642 |
" |
1643 |
||
1644 |
"Modified: 8.9.1997 / 00:23:16 / cg" |
|
1645 |
! |
|
1646 |
||
6383 | 1647 |
readingFile:aPathName do:aBlock |
1648 |
"create a read-stream on a file, evaluate aBlock, passing that stream, |
|
1649 |
and return the blocks value. |
|
1650 |
Ensures that the stream is closed." |
|
1651 |
||
6529 | 1652 |
^ aPathName asFilename readingFileDo:aBlock. |
1653 |
||
1654 |
" |
|
1655 |
read the first line from some file: |
|
1656 |
||
1657 |
|rslt| |
|
1658 |
||
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1659 |
rslt := |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1660 |
Filename |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1661 |
readingFile:'/etc/passwd' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1662 |
do:[:s | |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1663 |
s nextLine |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1664 |
]. |
6529 | 1665 |
Transcript showCR:rslt. |
1666 |
" |
|
1667 |
||
1668 |
" |
|
1669 |
find all used shells in /etc/passwd and count their usage: |
|
1670 |
||
6383 | 1671 |
|rslt| |
1672 |
||
6529 | 1673 |
rslt := |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1674 |
Filename |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1675 |
readingFile:'/etc/passwd' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1676 |
do: |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1677 |
[:s | |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1678 |
|shells| |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1679 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1680 |
shells := Bag new. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1681 |
s linesDo: |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1682 |
[:line | |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1683 |
|parts| |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1684 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1685 |
parts := line asCollectionOfSubstringsSeparatedBy:$:. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1686 |
shells add:(parts seventh). |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1687 |
]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1688 |
shells contents |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1689 |
]. |
6529 | 1690 |
Transcript showCR:rslt. |
1691 |
" |
|
6383 | 1692 |
! ! |
1693 |
||
7261 | 1694 |
!Filename methodsFor:'Compatibility-VW5.4'! |
6139 | 1695 |
|
1696 |
asLogicalFileSpecification |
|
1697 |
^ self |
|
1698 |
||
1699 |
"Created: / 30.10.2001 / 17:31:10 / cg" |
|
6447 | 1700 |
! |
1701 |
||
10583 | 1702 |
canBeWritten |
1703 |
"same as isWritable - for ST-80 compatibility" |
|
1704 |
||
1705 |
^ self isWritable |
|
1706 |
||
1707 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1708 |
'/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
|
1709 |
'/tmp' asFilename canBeWritten |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1710 |
'Makefile' asFilename canBeWritten |
10583 | 1711 |
" |
1712 |
! |
|
1713 |
||
7596 | 1714 |
definitelyExists |
1715 |
"for now - a kludge" |
|
1716 |
||
1717 |
^ self exists |
|
1718 |
! |
|
1719 |
||
6447 | 1720 |
extension |
6454 | 1721 |
"return the receiver's extension; |
1722 |
that is the characters from and including |
|
1723 |
the last period or nil, if there is none." |
|
1724 |
||
1725 |
|string idx| |
|
1726 |
||
1727 |
string := self asString. |
|
1728 |
idx := string lastIndexOf:$.. |
|
1729 |
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
|
1730 |
^ string copyFrom:idx |
6454 | 1731 |
]. |
1732 |
^ nil |
|
1733 |
||
1734 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1735 |
'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
|
1736 |
'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
|
1737 |
'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
|
1738 |
'foo.' asFilename extension |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1739 |
'foo' asFilename extension |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1740 |
'.login' asFilename extension |
6454 | 1741 |
" |
6139 | 1742 |
! ! |
1743 |
||
615 | 1744 |
!Filename methodsFor:'comparing'! |
1745 |
||
16255 | 1746 |
< aFilename |
1747 |
"compare file names - used for sorting" |
|
1748 |
||
1749 |
^ self asString < aFilename asString |
|
1750 |
! |
|
1751 |
||
615 | 1752 |
= aFilename |
1753 |
"return true, if the argument represents the same filename" |
|
1754 |
||
1755 |
|str| |
|
1756 |
||
1757 |
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
|
1758 |
str := aFilename asString. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1759 |
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
|
1760 |
^ nameString = str |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1761 |
]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1762 |
^ nameString sameAs:str |
615 | 1763 |
]. |
1764 |
^ false |
|
1765 |
! |
|
1766 |
||
5877 | 1767 |
contentsIsPrefixOf:aFilename |
5876
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1768 |
"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
|
1769 |
is the same as or a prefix of the contents of the file represented by the argument, aFilename. |
16578 | 1770 |
This compares the files' actual contents; not the filenames." |
3868 | 1771 |
|
8771 | 1772 |
|f2 s1 s2 bufferSize buffer1 buffer2 n| |
1773 |
||
1774 |
bufferSize := 8192 * 4. |
|
4979 | 1775 |
|
1776 |
f2 := aFilename asFilename. |
|
5876
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1777 |
self fileSize > f2 fileSize ifTrue:[^ false]. |
3868 | 1778 |
|
7088
cc3233554827
Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents:
7075
diff
changeset
|
1779 |
[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1780 |
s1 := self readStream. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1781 |
s2 := f2 readStream. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1782 |
s1 binary. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1783 |
s2 binary. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1784 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1785 |
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
|
1786 |
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
|
1787 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1788 |
[s1 atEnd] whileFalse:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1789 |
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
|
1790 |
n == 0 ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1791 |
"/ receiver shorter. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1792 |
^ true |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1793 |
]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1794 |
(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
|
1795 |
"/ aFilename shorter |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1796 |
^ false |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1797 |
]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1798 |
buffer1 ~= buffer2 ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1799 |
^ false |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1800 |
] |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1801 |
]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1802 |
"/ receiver shorter or same size. |
7088
cc3233554827
Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents:
7075
diff
changeset
|
1803 |
] ensure:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1804 |
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
|
1805 |
s2 notNil ifTrue:[s2 close]. |
3868 | 1806 |
]. |
5876
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1807 |
^ true |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1808 |
|
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1809 |
" |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1810 |
|s| |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1811 |
|
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1812 |
s := 'testFile1' asFilename writeStream. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1813 |
s nextPutAll:'11111'. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1814 |
s nextPutAll:'22222'. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1815 |
s nextPutAll:'33333'. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1816 |
s close. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1817 |
|
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1818 |
s := 'testFile2' asFilename writeStream. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1819 |
s nextPutAll:'11111'. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1820 |
s nextPutAll:'22222'. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1821 |
s nextPutAll:'33333'. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1822 |
s close. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1823 |
|
5877 | 1824 |
('testFile1' asFilename contentsIsPrefixOf:'testFile2' ) ifFalse:[self halt]. |
5876
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1825 |
|
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1826 |
s := 'testFile2' asFilename writeStream. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1827 |
s nextPutAll:'11111'. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1828 |
s nextPutAll:'22222'. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1829 |
s nextPutAll:'33333'. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1830 |
s nextPutAll:'44444'. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1831 |
s close. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1832 |
|
5877 | 1833 |
('testFile1' asFilename contentsIsPrefixOf:'testFile2' ) ifFalse:[self halt]. |
5876
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1834 |
|
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1835 |
s := 'testFile2' asFilename writeStream. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1836 |
s nextPutAll:'11111'. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1837 |
s nextPutAll:'22222'. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1838 |
s close. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1839 |
|
5877 | 1840 |
('testFile1' asFilename contentsIsPrefixOf:'testFile2' ) ifTrue:[self halt]. |
5876
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1841 |
|
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1842 |
s := 'testFile2' asFilename writeStream. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1843 |
s nextPutAll:'11111'. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1844 |
s nextPutAll:'22222'. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1845 |
s nextPutAll:'33334'. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1846 |
s close. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1847 |
|
5877 | 1848 |
('testFile1' asFilename contentsIsPrefixOf:'testFile2' ) ifTrue:[self halt]. |
1849 |
||
1850 |
" |
|
1851 |
! |
|
1852 |
||
1853 |
contentsStartsWithContentsOf:aFilename |
|
1854 |
"return true if the contents of the file represented by aFilename |
|
1855 |
is the same as or a prefix of the contents of the file represented by the receiver. |
|
16578 | 1856 |
This compares the files' actual contents; not the filenames." |
5877 | 1857 |
|
1858 |
^ aFilename asFilename contentsIsPrefixOf:self |
|
1859 |
||
1860 |
" |
|
1861 |
|s| |
|
1862 |
||
1863 |
s := 'testFile1' asFilename writeStream. |
|
1864 |
s nextPutAll:'11111'. |
|
1865 |
s nextPutAll:'22222'. |
|
1866 |
s nextPutAll:'33333'. |
|
1867 |
s close. |
|
1868 |
||
1869 |
s := 'testFile2' asFilename writeStream. |
|
1870 |
s nextPutAll:'11111'. |
|
1871 |
s nextPutAll:'22222'. |
|
1872 |
s nextPutAll:'33333'. |
|
1873 |
s close. |
|
1874 |
||
1875 |
('testFile2' asFilename contentsStartsWithContentsOf:'testFile1' ) ifFalse:[self halt]. |
|
1876 |
||
1877 |
s := 'testFile2' asFilename writeStream. |
|
1878 |
s nextPutAll:'11111'. |
|
1879 |
s nextPutAll:'22222'. |
|
1880 |
s nextPutAll:'33333'. |
|
1881 |
s nextPutAll:'44444'. |
|
1882 |
s close. |
|
1883 |
||
1884 |
('testFile2' asFilename contentsStartsWithContentsOf:'testFile1' ) ifFalse:[self halt]. |
|
1885 |
||
1886 |
s := 'testFile2' asFilename writeStream. |
|
1887 |
s nextPutAll:'11111'. |
|
1888 |
s nextPutAll:'22222'. |
|
1889 |
s close. |
|
1890 |
||
1891 |
('testFile2' asFilename contentsStartsWithContentsOf:'testFile1' ) ifTrue:[self halt]. |
|
1892 |
||
1893 |
s := 'testFile2' asFilename writeStream. |
|
1894 |
s nextPutAll:'11111'. |
|
1895 |
s nextPutAll:'22222'. |
|
1896 |
s nextPutAll:'33334'. |
|
1897 |
s close. |
|
1898 |
||
1899 |
('testFile2' asFilename contentsStartsWithContentsOf:'testFile1' ) ifTrue:[self halt]. |
|
5876
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1900 |
|
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1901 |
" |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1902 |
! |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1903 |
|
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1904 |
hash |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1905 |
"return an integer useful as a hash-key" |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1906 |
|
15811 | 1907 |
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
|
1908 |
"/ 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
|
1909 |
"/ 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
|
1910 |
"/ 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
|
1911 |
^ nameString asUppercase hash |
11424
c169cc34afe9
fixed hash for case-insensitive files
Claus Gittinger <cg@exept.de>
parents:
11406
diff
changeset
|
1912 |
]. |
5876
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1913 |
^ nameString hash |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1914 |
! |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1915 |
|
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1916 |
sameContentsAs:aFilename |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1917 |
"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
|
1918 |
same contents as the file represented by the argument, aFilename. |
16578 | 1919 |
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
|
1920 |
|
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1921 |
|f2| |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1922 |
|
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1923 |
f2 := aFilename asFilename. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1924 |
f2 fileSize = self fileSize ifFalse:[^ false]. |
5877 | 1925 |
^ self contentsIsPrefixOf:f2. |
3868 | 1926 |
|
1927 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
1928 |
'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
|
1929 |
'Make.proto' asFilename sameContentsAs:'Make.proto' |
3868 | 1930 |
" |
5876
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1931 |
|
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1932 |
" |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1933 |
|s| |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1934 |
|
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1935 |
s := 'testFile1' asFilename writeStream. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1936 |
s nextPutAll:'11111'. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1937 |
s nextPutAll:'22222'. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1938 |
s nextPutAll:'33333'. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1939 |
s close. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1940 |
|
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1941 |
s := 'testFile2' asFilename writeStream. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1942 |
s nextPutAll:'11111'. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1943 |
s nextPutAll:'22222'. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1944 |
s nextPutAll:'33333'. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1945 |
s close. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1946 |
|
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1947 |
('testFile1' asFilename sameContentsAs:'testFile2' ) ifFalse:[self halt]. |
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 |
s := 'testFile2' asFilename writeStream. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1950 |
s nextPutAll:'11111'. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1951 |
s nextPutAll:'22222'. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1952 |
s nextPutAll:'33333'. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1953 |
s nextPutAll:'44444'. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1954 |
s close. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1955 |
|
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1956 |
('testFile1' asFilename sameContentsAs:'testFile2' ) ifTrue:[self halt]. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1957 |
|
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1958 |
s := 'testFile2' asFilename writeStream. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1959 |
s nextPutAll:'11111'. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1960 |
s nextPutAll:'22222'. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1961 |
s close. |
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 |
('testFile1' asFilename sameContentsAs:'testFile2' ) ifTrue:[self halt]. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1964 |
|
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1965 |
s := 'testFile2' asFilename writeStream. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1966 |
s nextPutAll:'11111'. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1967 |
s nextPutAll:'22222'. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1968 |
s nextPutAll:'33334'. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1969 |
s close. |
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 |
('testFile1' asFilename sameContentsAs:'testFile2' ) ifTrue:[self halt]. |
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1972 |
|
e38638bad111
added #contentsIsPartOf (prefix contents check)
Claus Gittinger <cg@exept.de>
parents:
5866
diff
changeset
|
1973 |
" |
615 | 1974 |
! ! |
1975 |
||
1976 |
!Filename methodsFor:'converting'! |
|
1977 |
||
1978 |
asAbsoluteFilename |
|
1979 |
"return the receiver converted to a filename with |
|
1980 |
an absolute pathname." |
|
1981 |
||
15811 | 1982 |
^ self species named:self pathName |
7332 | 1983 |
|
1984 |
" |
|
1985 |
'.' asFilename |
|
1986 |
'.' asFilename asAbsoluteFilename |
|
9173 | 1987 |
'c:' asFilename asAbsoluteFilename |
7332 | 1988 |
" |
615 | 1989 |
! |
1990 |
||
10769 | 1991 |
asAutoDeletedFilename |
13653
6821135a2e1a
comment/format in: #asAutoDeletedFilename
Claus Gittinger <cg@exept.de>
parents:
13424
diff
changeset
|
1992 |
"will automatically delete myself, when no longer referenced" |
6821135a2e1a
comment/format in: #asAutoDeletedFilename
Claus Gittinger <cg@exept.de>
parents:
13424
diff
changeset
|
1993 |
|
11784 | 1994 |
^ AutoDeletedFilename basicNew setName:self name |
13653
6821135a2e1a
comment/format in: #asAutoDeletedFilename
Claus Gittinger <cg@exept.de>
parents:
13424
diff
changeset
|
1995 |
|
6821135a2e1a
comment/format in: #asAutoDeletedFilename
Claus Gittinger <cg@exept.de>
parents:
13424
diff
changeset
|
1996 |
"Modified (comment): / 07-09-2011 / 12:20:59 / cg" |
10769 | 1997 |
! |
1998 |
||
6802 | 1999 |
asCanonicalizedFilename |
2000 |
"return the receiver converted to a filename without intermediate ..'s and .'s |
|
2001 |
(similar to an absolute pathname, but symlinks are not resolved)." |
|
2002 |
||
15811 | 2003 |
^ self species named:(self species canonicalize:nameString) |
7074 | 2004 |
|
2005 |
" |
|
2006 |
'c:\test\work' asFilename asCanonicalizedFilename |
|
2007 |
'/test/work' asFilename asCanonicalizedFilename |
|
2008 |
" |
|
6802 | 2009 |
! |
2010 |
||
615 | 2011 |
asFilename |
1970 | 2012 |
"return the receiver converted to a filename; here, thats the receiver itself." |
615 | 2013 |
|
2014 |
"Thats pretty easy here :-)" |
|
2015 |
^ self |
|
1970 | 2016 |
|
2017 |
"Modified: 12.11.1996 / 12:40:03 / cg" |
|
615 | 2018 |
! |
2019 |
||
2020 |
asString |
|
2021 |
"return the receiver converted to a string" |
|
2022 |
||
2023 |
^ nameString |
|
2024 |
! |
|
2025 |
||
6256 | 2026 |
asURI |
15001 | 2027 |
"return the receiver converted to a file URI" |
6256 | 2028 |
|
2029 |
^ FileURI fromFilename:self. |
|
2030 |
! |
|
2031 |
||
15001 | 2032 |
asURL |
2033 |
"return an URL-object from myself" |
|
2034 |
||
2035 |
^ URL fromString:self pathName. |
|
2036 |
! |
|
2037 |
||
5890 | 2038 |
components |
2039 |
"return the receivers filename components - that is the name of each directory |
|
2040 |
along the pathName (that DOES include the root directory)" |
|
2041 |
||
15811 | 2042 |
^ self species components:self name |
5890 | 2043 |
|
2044 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2045 |
'.' asFilename asAbsoluteFilename components |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2046 |
'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
|
2047 |
" |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2048 |
! |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2049 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2050 |
makeLegalFilename |
1970 | 2051 |
"convert the receivers name to be a legal filename. |
2052 |
This removes/replaces invalid characters and/or compresses |
|
2053 |
the name as required by the OS. |
|
615 | 2054 |
The implementation may change in the future to be more |
2055 |
OS specific." |
|
2056 |
||
2057 |
" |
|
2058 |
actually, in Unix spaces are allowed - but it makes life |
|
2059 |
so hard; therefore, replace them by underscores ... |
|
2060 |
" |
|
16761 | 2061 |
nameString := nameString copyReplaceAll:(Character space) with:$_ ifNone:nameString. |
615 | 2062 |
" |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2063 |
need more - especially on SYS5.3 type systems, |
615 | 2064 |
we may want to contract the fileName to 14 characters. |
2065 |
" |
|
2066 |
^ self |
|
2067 |
||
2068 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2069 |
'hello world' asFilename makeLegalFilename |
615 | 2070 |
" |
1970 | 2071 |
|
3658 | 2072 |
"Modified: / 20.7.1998 / 13:16:51 / cg" |
2707
280456505357
added #findDefaultDirectory and #withEncoding:
Claus Gittinger <cg@exept.de>
parents:
2630
diff
changeset
|
2073 |
! |
280456505357
added #findDefaultDirectory and #withEncoding:
Claus Gittinger <cg@exept.de>
parents:
2630
diff
changeset
|
2074 |
|
280456505357
added #findDefaultDirectory and #withEncoding:
Claus Gittinger <cg@exept.de>
parents:
2630
diff
changeset
|
2075 |
withEncoding:encodingSymbol |
280456505357
added #findDefaultDirectory and #withEncoding:
Claus Gittinger <cg@exept.de>
parents:
2630
diff
changeset
|
2076 |
"dummy for now - for ST80 compatibility" |
280456505357
added #findDefaultDirectory and #withEncoding:
Claus Gittinger <cg@exept.de>
parents:
2630
diff
changeset
|
2077 |
|
280456505357
added #findDefaultDirectory and #withEncoding:
Claus Gittinger <cg@exept.de>
parents:
2630
diff
changeset
|
2078 |
^ self |
280456505357
added #findDefaultDirectory and #withEncoding:
Claus Gittinger <cg@exept.de>
parents:
2630
diff
changeset
|
2079 |
|
280456505357
added #findDefaultDirectory and #withEncoding:
Claus Gittinger <cg@exept.de>
parents:
2630
diff
changeset
|
2080 |
"Created: 20.6.1997 / 17:01:28 / cg" |
2 | 2081 |
! ! |
2082 |
||
18272 | 2083 |
|
5889
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2084 |
!Filename methodsFor:'enumerating-contents'! |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2085 |
|
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2086 |
allDirectoriesDo:aBlock |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2087 |
"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
|
2088 |
The block is invoked with a filename-arguments. |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2089 |
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
|
2090 |
filenames (but by creation time - on some systems). |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2091 |
This excludes entries for '.' or '..'. |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2092 |
NoOp for non-existing directories; however, this behavior |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2093 |
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
|
2094 |
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
|
2095 |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2096 |
self recursiveDirectoryContentsDo:[:eachFileOrDirectoryName | |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2097 |
|eachFileOrDirectory| |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2098 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2099 |
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
|
2100 |
eachFileOrDirectory isDirectory ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2101 |
aBlock value:eachFileOrDirectory |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2102 |
] |
5889
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2103 |
]. |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2104 |
|
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2105 |
" |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2106 |
'.' asFilename allDirectoriesDo:[:fn | Transcript showCR:fn name]. |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2107 |
'.' asFilename directoriesDo:[:fn | Transcript showCR:fn name]. |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2108 |
" |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2109 |
! |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2110 |
|
6773
26415b61ad09
isMountPoint & isParentDirectoryOf & allParentDirsDo:
penk
parents:
6771
diff
changeset
|
2111 |
allParentDirectoriesDo:aBlock |
26415b61ad09
isMountPoint & isParentDirectoryOf & allParentDirsDo:
penk
parents:
6771
diff
changeset
|
2112 |
"evaluate aBlock for all (recursive) directories along the parent directory path. |
26415b61ad09
isMountPoint & isParentDirectoryOf & allParentDirsDo:
penk
parents:
6771
diff
changeset
|
2113 |
The block is invoked with a filename-arguments." |
26415b61ad09
isMountPoint & isParentDirectoryOf & allParentDirsDo:
penk
parents:
6771
diff
changeset
|
2114 |
|
26415b61ad09
isMountPoint & isParentDirectoryOf & allParentDirsDo:
penk
parents:
6771
diff
changeset
|
2115 |
|parent here| |
26415b61ad09
isMountPoint & isParentDirectoryOf & allParentDirsDo:
penk
parents:
6771
diff
changeset
|
2116 |
|
26415b61ad09
isMountPoint & isParentDirectoryOf & allParentDirsDo:
penk
parents:
6771
diff
changeset
|
2117 |
here := self. |
26415b61ad09
isMountPoint & isParentDirectoryOf & allParentDirsDo:
penk
parents:
6771
diff
changeset
|
2118 |
parent := here directory. |
26415b61ad09
isMountPoint & isParentDirectoryOf & allParentDirsDo:
penk
parents:
6771
diff
changeset
|
2119 |
[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
|
2120 |
aBlock value:parent. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2121 |
here := parent. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2122 |
parent := here directory. |
6773
26415b61ad09
isMountPoint & isParentDirectoryOf & allParentDirsDo:
penk
parents:
6771
diff
changeset
|
2123 |
]. |
26415b61ad09
isMountPoint & isParentDirectoryOf & allParentDirsDo:
penk
parents:
6771
diff
changeset
|
2124 |
|
26415b61ad09
isMountPoint & isParentDirectoryOf & allParentDirsDo:
penk
parents:
6771
diff
changeset
|
2125 |
" |
26415b61ad09
isMountPoint & isParentDirectoryOf & allParentDirsDo:
penk
parents:
6771
diff
changeset
|
2126 |
'.' asFilename allParentDirectoriesDo:[:fn | Transcript showCR:fn pathName]. |
26415b61ad09
isMountPoint & isParentDirectoryOf & allParentDirsDo:
penk
parents:
6771
diff
changeset
|
2127 |
" |
26415b61ad09
isMountPoint & isParentDirectoryOf & allParentDirsDo:
penk
parents:
6771
diff
changeset
|
2128 |
! |
26415b61ad09
isMountPoint & isParentDirectoryOf & allParentDirsDo:
penk
parents:
6771
diff
changeset
|
2129 |
|
9362 | 2130 |
directories |
2131 |
"return a collection of directories contained in the directory represented by the receiver." |
|
2132 |
||
17310 | 2133 |
|collection| |
2134 |
||
2135 |
collection := OrderedCollection new. |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2136 |
self directoryContentsAsFilenamesDo:[:eachFileOrDirectory | |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2137 |
eachFileOrDirectory isDirectory ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2138 |
collection add:eachFileOrDirectory. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2139 |
]. |
17310 | 2140 |
]. |
2141 |
||
2142 |
^ collection |
|
9362 | 2143 |
|
2144 |
" |
|
2145 |
'.' asFilename directories. |
|
2146 |
" |
|
10557 | 2147 |
|
2148 |
"Modified: / 29-05-2007 / 12:02:56 / cg" |
|
9362 | 2149 |
! |
2150 |
||
5889
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2151 |
directoriesDo:aBlock |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2152 |
"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
|
2153 |
The block is invoked with a filename-arguments. |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2154 |
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
|
2155 |
filenames (but by creation time - on some systems). |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2156 |
This excludes entries for '.' or '..'. |
18686 | 2157 |
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
|
2158 |
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
|
2159 |
|
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2160 |
self directoryContentsAsFilenamesDo:[:eachFileOrDirectory | |
18686 | 2161 |
eachFileOrDirectory isDirectory ifTrue:[ |
2162 |
aBlock value:eachFileOrDirectory |
|
2163 |
] |
|
5889
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2164 |
]. |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2165 |
|
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2166 |
" |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2167 |
'.' asFilename directoriesDo:[:fn | Transcript showCR:fn baseName]. |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2168 |
" |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2169 |
! |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2170 |
|
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2171 |
directoryContentsAsFilenamesDo:aBlock |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2172 |
"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
|
2173 |
The block is invoked with a filename-argument. |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2174 |
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
|
2175 |
filenames (but by creation time - on some systems). |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2176 |
This excludes entries for '.' or '..'. |
17310 | 2177 |
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
|
2178 |
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
|
2179 |
Notice: this enumerates fileName objects; see also |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2180 |
#directoryContentsDo:, which enumerates strings." |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2181 |
|
6776
11df52e55905
better loop (dont preread all items in ..asFilenamesDo:)
penk
parents:
6773
diff
changeset
|
2182 |
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
|
2183 |
aBlock value:(self construct:entry). |
6776
11df52e55905
better loop (dont preread all items in ..asFilenamesDo:)
penk
parents:
6773
diff
changeset
|
2184 |
] |
5889
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2185 |
|
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2186 |
" |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2187 |
'.' asFilename directoryContentsAsFilenamesDo:[:fn | Transcript showCR:fn pathName]. |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2188 |
" |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2189 |
|
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2190 |
"Modified: / 18.9.1997 / 18:42:23 / stefan" |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2191 |
"Modified: / 23.12.1999 / 20:56:35 / cg" |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2192 |
! |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2193 |
|
7464 | 2194 |
directoryContentsDo:aBlock |
2195 |
"evaluate aBlock for each file in the directory represented by the receiver. |
|
2196 |
The block is invoked with a string as argument. |
|
2197 |
The enumerations order is undefined - i.e. usually NOT sorted by |
|
2198 |
filenames (but by creation time - on some systems). |
|
2199 |
This excludes entries for '.' or '..'. |
|
17310 | 2200 |
An OpenError exception is raised it the directory does not exist or is not readable. |
7464 | 2201 |
So users of this method better test for existing directory before. |
2202 |
Notice: this enumerates strings; see also |
|
2203 |
#directoryContentsAsFilenamesDo:, which enumerates fileName objects." |
|
2204 |
||
17310 | 2205 |
|s| |
2206 |
||
2207 |
s := DirectoryStream directoryNamed:self osNameForDirectoryContents. |
|
2208 |
"check for nil, in order to allow to proceed from an OpenError" |
|
2209 |
s notNil ifTrue:[ |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2210 |
[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2211 |
[s atEnd] whileFalse:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2212 |
|fn| |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2213 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2214 |
fn := s nextLine. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2215 |
(fn ~= '.' and:[fn ~= '..']) ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2216 |
aBlock value:fn |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2217 |
]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2218 |
]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2219 |
] ensure:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2220 |
s close. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2221 |
]. |
7464 | 2222 |
]. |
2223 |
||
2224 |
" |
|
2225 |
'.' asFilename directoryContentsDo:[:fn | Transcript showCR:fn]. |
|
7473 | 2226 |
'doeSnotExIST' asFilename directoryContentsDo:[:fn | Transcript showCR:fn]. |
17310 | 2227 |
[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2228 |
'doeSnotExIST' asFilename directoryContentsDo:[:fn | Transcript showCR:fn]. |
17310 | 2229 |
] on:OpenError do:[:ex| ex proceed] |
7464 | 2230 |
" |
2231 |
||
2232 |
"Modified: / 18.9.1997 / 18:42:23 / stefan" |
|
2233 |
"Modified: / 23.12.1999 / 20:56:35 / cg" |
|
2234 |
! |
|
2235 |
||
9382 | 2236 |
files |
18734 | 2237 |
"return a collection of regular files |
2238 |
contained in the directory represented by the receiver." |
|
9382 | 2239 |
|
17310 | 2240 |
|collection| |
2241 |
||
2242 |
collection := OrderedCollection new. |
|
18734 | 2243 |
self filesDo:[:eachFileName | collection add:eachFileName]. |
17310 | 2244 |
^ collection. |
9382 | 2245 |
|
2246 |
" |
|
2247 |
'.' asFilename files. |
|
2248 |
" |
|
10557 | 2249 |
|
2250 |
"Modified: / 29-05-2007 / 12:02:15 / cg" |
|
9382 | 2251 |
! |
2252 |
||
9806 | 2253 |
filesDo:aBlock |
18734 | 2254 |
"evaluate aBlock for all regular files (i.e. subdirs are ignored) |
2255 |
contained in the directory represented by the receiver." |
|
9806 | 2256 |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2257 |
^ self directoryContentsAsFilenamesDo:[:eachFileOrDirectory | |
18734 | 2258 |
eachFileOrDirectory isRegularFile ifTrue:[ |
2259 |
aBlock value: eachFileOrDirectory |
|
2260 |
]. |
|
17310 | 2261 |
]. |
9806 | 2262 |
|
2263 |
" |
|
2264 |
'.' asFilename filesDo:[:f | Transcript showCR:f]. |
|
2265 |
" |
|
2266 |
||
2267 |
"Created: / 29-08-2006 / 11:03:15 / cg" |
|
10557 | 2268 |
"Modified: / 29-05-2007 / 12:02:46 / cg" |
9806 | 2269 |
! |
2270 |
||
18734 | 2271 |
filesWithSuffix:suffix |
2272 |
"return a collection of regular files (i.e. not subdirectories) |
|
2273 |
with a given suffix which are contained in the directory |
|
2274 |
represented by the receiver." |
|
2275 |
||
2276 |
|collection| |
|
2277 |
||
2278 |
collection := OrderedCollection new. |
|
2279 |
self filesWithSuffix:suffix do:[:eachFileName | collection add:eachFileName]. |
|
2280 |
^ collection. |
|
2281 |
||
2282 |
" |
|
2283 |
'.' asFilename filesWithSuffix:'so'. |
|
2284 |
" |
|
2285 |
! |
|
2286 |
||
2287 |
filesWithSuffix:suffix do:aBlock |
|
2288 |
"evaluate aBlock for all regular files with a given suffix |
|
2289 |
contained in the directory represented by the receiver. |
|
2290 |
(i.e. subdirs are ignored)" |
|
2291 |
||
2292 |
^ self directoryContentsAsFilenamesDo:[:eachFileOrDirectory | |
|
2293 |
(eachFileOrDirectory hasSuffix:suffix) ifTrue:[ |
|
2294 |
eachFileOrDirectory isRegularFile ifTrue:[ |
|
2295 |
aBlock value: eachFileOrDirectory |
|
2296 |
]. |
|
2297 |
]. |
|
2298 |
]. |
|
2299 |
||
2300 |
" |
|
2301 |
'.' asFilename filesWithSuffix:'so' do:[:f | Transcript showCR:f]. |
|
2302 |
" |
|
2303 |
! |
|
2304 |
||
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2305 |
recursiveDirectoryContentsAsFilenamesDo:aBlock |
13191
10ffa6ac5505
added: #recursiveDirectoryContentsAsFilenamesDo:
Claus Gittinger <cg@exept.de>
parents:
13139
diff
changeset
|
2306 |
"evaluate aBlock for all files and directories found under the receiver. |
10ffa6ac5505
added: #recursiveDirectoryContentsAsFilenamesDo:
Claus Gittinger <cg@exept.de>
parents:
13139
diff
changeset
|
2307 |
The block is invoked with the filenames as argument. |
10ffa6ac5505
added: #recursiveDirectoryContentsAsFilenamesDo:
Claus Gittinger <cg@exept.de>
parents:
13139
diff
changeset
|
2308 |
The walk is bread-first. |
10ffa6ac5505
added: #recursiveDirectoryContentsAsFilenamesDo:
Claus Gittinger <cg@exept.de>
parents:
13139
diff
changeset
|
2309 |
This excludes any entries for '.' or '..'. |
10ffa6ac5505
added: #recursiveDirectoryContentsAsFilenamesDo:
Claus Gittinger <cg@exept.de>
parents:
13139
diff
changeset
|
2310 |
Subdirectory files are included with a relative pathname. |
10ffa6ac5505
added: #recursiveDirectoryContentsAsFilenamesDo:
Claus Gittinger <cg@exept.de>
parents:
13139
diff
changeset
|
2311 |
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
|
2312 |
|
10ffa6ac5505
added: #recursiveDirectoryContentsAsFilenamesDo:
Claus Gittinger <cg@exept.de>
parents:
13139
diff
changeset
|
2313 |
self recursiveDirectoryContentsDo:[:relFn | |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2314 |
aBlock value:(self construct:relFn) |
13191
10ffa6ac5505
added: #recursiveDirectoryContentsAsFilenamesDo:
Claus Gittinger <cg@exept.de>
parents:
13139
diff
changeset
|
2315 |
]. |
10ffa6ac5505
added: #recursiveDirectoryContentsAsFilenamesDo:
Claus Gittinger <cg@exept.de>
parents:
13139
diff
changeset
|
2316 |
|
10ffa6ac5505
added: #recursiveDirectoryContentsAsFilenamesDo:
Claus Gittinger <cg@exept.de>
parents:
13139
diff
changeset
|
2317 |
" |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2318 |
'.' asFilename recursiveDirectoryContentsAsFilenamesDo:[:f | Transcript showCR:f] |
13191
10ffa6ac5505
added: #recursiveDirectoryContentsAsFilenamesDo:
Claus Gittinger <cg@exept.de>
parents:
13139
diff
changeset
|
2319 |
" |
10ffa6ac5505
added: #recursiveDirectoryContentsAsFilenamesDo:
Claus Gittinger <cg@exept.de>
parents:
13139
diff
changeset
|
2320 |
|
10ffa6ac5505
added: #recursiveDirectoryContentsAsFilenamesDo:
Claus Gittinger <cg@exept.de>
parents:
13139
diff
changeset
|
2321 |
"Modified: / 12-09-2010 / 15:43:22 / cg" |
10ffa6ac5505
added: #recursiveDirectoryContentsAsFilenamesDo:
Claus Gittinger <cg@exept.de>
parents:
13139
diff
changeset
|
2322 |
! |
10ffa6ac5505
added: #recursiveDirectoryContentsAsFilenamesDo:
Claus Gittinger <cg@exept.de>
parents:
13139
diff
changeset
|
2323 |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2324 |
recursiveDirectoryContentsDo:aBlock |
5889
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2325 |
"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
|
2326 |
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
|
2327 |
The walk is bread-first. |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2328 |
This excludes any entries for '.' or '..'. |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2329 |
Subdirectory files are included with a relative pathname. |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2330 |
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
|
2331 |
|
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2332 |
self recursiveDirectoryContentsDo:aBlock directoryPrefix:'' |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2333 |
|
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2334 |
" |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2335 |
'.' asFilename recursiveDirectoryContentsDo:[:f | Transcript showCR:f] |
5889
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2336 |
" |
13057
4f7fa62156ac
comment/format in: #recursiveDirectoryContentsDo:
Claus Gittinger <cg@exept.de>
parents:
12975
diff
changeset
|
2337 |
|
4f7fa62156ac
comment/format in: #recursiveDirectoryContentsDo:
Claus Gittinger <cg@exept.de>
parents:
12975
diff
changeset
|
2338 |
"Modified: / 12-09-2010 / 15:43:22 / cg" |
5889
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2339 |
! |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2340 |
|
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2341 |
recursiveDirectoryContentsDo:aBlock directoryPrefix:aPrefix |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2342 |
"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
|
2343 |
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
|
2344 |
The walk is breadth-first. |
5889
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2345 |
This excludes any entries for '.' or '..'. |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2346 |
Subdirectory files are included with a relative pathname. |
19114 | 2347 |
A proceedable exception is raised forn non-accessible directories. |
5889
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2348 |
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
|
2349 |
|
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2350 |
|fileNames dirNames p| |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2351 |
|
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2352 |
fileNames := OrderedCollection new. |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2353 |
dirNames := OrderedCollection new. |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2354 |
self directoryContentsDo:[:f | |t| |
19114 | 2355 |
t := self construct:f. |
2356 |
t isDirectory ifTrue:[ |
|
2357 |
t isSymbolicLink ifFalse:[ |
|
2358 |
dirNames add:f |
|
2359 |
] |
|
2360 |
] ifFalse:[ |
|
2361 |
fileNames add:f |
|
2362 |
] |
|
5889
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2363 |
]. |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2364 |
|
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2365 |
aPrefix size > 0 ifTrue:[ |
19114 | 2366 |
p := aPrefix , self separator |
5889
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2367 |
] ifFalse:[ |
19114 | 2368 |
p := '' |
5889
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2369 |
]. |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2370 |
|
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2371 |
fileNames do:[:aFile | aBlock value:(p , aFile)]. |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2372 |
dirNames do:[:dN | |
19114 | 2373 |
aBlock value:(p , dN). |
2374 |
(self construct:dN) |
|
2375 |
recursiveDirectoryContentsDo:aBlock directoryPrefix:(p , dN) |
|
5889
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2376 |
]. |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2377 |
|
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2378 |
" |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2379 |
'.' 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
|
2380 |
'/etc' asFilename recursiveDirectoryContentsDo:[:f | Transcript showCR:f] |
5889
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2381 |
" |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2382 |
! |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2383 |
|
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2384 |
withAllDirectoriesDo:aBlock |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2385 |
"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
|
2386 |
The block is invoked with a filename-arguments. |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2387 |
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
|
2388 |
filenames (but by creation time - on some systems). |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2389 |
This excludes entries for '.' or '..'. |
17310 | 2390 |
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
|
2391 |
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
|
2392 |
|
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2393 |
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
|
2394 |
aBlock value:self. |
5889
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2395 |
]. |
17310 | 2396 |
self allDirectoriesDo:aBlock. |
5889
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2397 |
|
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2398 |
" |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2399 |
'.' asFilename withAllDirectoriesDo:[:fn | Transcript showCR:fn name]. |
17310 | 2400 |
'IdoNOTexist' asFilename withAllDirectoriesDo:[:fn | Transcript showCR:fn name]. |
2401 |
'/etc/hosts' asFilename withAllDirectoriesDo:[:fn | Transcript showCR:fn name]. |
|
5889
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2402 |
" |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2403 |
! ! |
171985b0ea2f
more & better enumeration protocol
Claus Gittinger <cg@exept.de>
parents:
5877
diff
changeset
|
2404 |
|
542 | 2405 |
!Filename methodsFor:'error handling'! |
2406 |
||
615 | 2407 |
accessDeniedError:filename |
1120
94c803be0210
compile errorMethods with +optSpace
Claus Gittinger <cg@exept.de>
parents:
1081
diff
changeset
|
2408 |
"{ Pragma: +optSpace }" |
94c803be0210
compile errorMethods with +optSpace
Claus Gittinger <cg@exept.de>
parents:
1081
diff
changeset
|
2409 |
|
94c803be0210
compile errorMethods with +optSpace
Claus Gittinger <cg@exept.de>
parents:
1081
diff
changeset
|
2410 |
"report an error that access to some file was denied" |
94c803be0210
compile errorMethods with +optSpace
Claus Gittinger <cg@exept.de>
parents:
1081
diff
changeset
|
2411 |
|
4820 | 2412 |
|errNo errString| |
2413 |
||
2414 |
errNo := OperatingSystem lastErrorNumber. |
|
2415 |
errString := OperatingSystem lastErrorString. |
|
2416 |
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
|
2417 |
errString := ''. |
4820 | 2418 |
] ifFalse:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2419 |
errString := ' (' , errString , ')' |
4820 | 2420 |
]. |
2421 |
||
615 | 2422 |
^ OperatingSystem accessDeniedErrorSignal |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2423 |
raiseRequestWith:filename ? self |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2424 |
errorString:(' : ' , (filename ? self) asString , errString) |
4820 | 2425 |
|
2426 |
"Modified: / 26.9.1999 / 16:11:44 / cg" |
|
615 | 2427 |
! |
2428 |
||
2429 |
fileCreationError:filename |
|
1120
94c803be0210
compile errorMethods with +optSpace
Claus Gittinger <cg@exept.de>
parents:
1081
diff
changeset
|
2430 |
"{ Pragma: +optSpace }" |
94c803be0210
compile errorMethods with +optSpace
Claus Gittinger <cg@exept.de>
parents:
1081
diff
changeset
|
2431 |
|
94c803be0210
compile errorMethods with +optSpace
Claus Gittinger <cg@exept.de>
parents:
1081
diff
changeset
|
2432 |
"report an error that some file could not be created" |
94c803be0210
compile errorMethods with +optSpace
Claus Gittinger <cg@exept.de>
parents:
1081
diff
changeset
|
2433 |
|
615 | 2434 |
^ OperatingSystem accessDeniedErrorSignal |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2435 |
raiseRequestWith:filename?self |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2436 |
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
|
2437 |
! |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2438 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2439 |
fileNotFoundError:filename |
1120
94c803be0210
compile errorMethods with +optSpace
Claus Gittinger <cg@exept.de>
parents:
1081
diff
changeset
|
2440 |
"{ Pragma: +optSpace }" |
94c803be0210
compile errorMethods with +optSpace
Claus Gittinger <cg@exept.de>
parents:
1081
diff
changeset
|
2441 |
|
94c803be0210
compile errorMethods with +optSpace
Claus Gittinger <cg@exept.de>
parents:
1081
diff
changeset
|
2442 |
"report an error that some file was not found" |
94c803be0210
compile errorMethods with +optSpace
Claus Gittinger <cg@exept.de>
parents:
1081
diff
changeset
|
2443 |
|
542 | 2444 |
^ OperatingSystem fileNotFoundErrorSignal |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2445 |
raiseRequestWith:filename?self |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2446 |
errorString:('file not found: ' , (filename ? self) asString) |
542 | 2447 |
! |
2448 |
||
2449 |
removeError:filename |
|
1120
94c803be0210
compile errorMethods with +optSpace
Claus Gittinger <cg@exept.de>
parents:
1081
diff
changeset
|
2450 |
"{ Pragma: +optSpace }" |
94c803be0210
compile errorMethods with +optSpace
Claus Gittinger <cg@exept.de>
parents:
1081
diff
changeset
|
2451 |
|
94c803be0210
compile errorMethods with +optSpace
Claus Gittinger <cg@exept.de>
parents:
1081
diff
changeset
|
2452 |
"report an error that some file could not be removed" |
94c803be0210
compile errorMethods with +optSpace
Claus Gittinger <cg@exept.de>
parents:
1081
diff
changeset
|
2453 |
|
542 | 2454 |
^ OperatingSystem accessDeniedErrorSignal |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2455 |
raiseRequestWith:filename?self |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2456 |
errorString:('cannot remove: ' , (filename?self) asString) |
615 | 2457 |
! |
2458 |
||
2459 |
reportError:string with:filename |
|
1120
94c803be0210
compile errorMethods with +optSpace
Claus Gittinger <cg@exept.de>
parents:
1081
diff
changeset
|
2460 |
"{ Pragma: +optSpace }" |
94c803be0210
compile errorMethods with +optSpace
Claus Gittinger <cg@exept.de>
parents:
1081
diff
changeset
|
2461 |
|
94c803be0210
compile errorMethods with +optSpace
Claus Gittinger <cg@exept.de>
parents:
1081
diff
changeset
|
2462 |
"report an error" |
94c803be0210
compile errorMethods with +optSpace
Claus Gittinger <cg@exept.de>
parents:
1081
diff
changeset
|
2463 |
|
15192 | 2464 |
^ OsError |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2465 |
raiseRequestWith:filename?self |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2466 |
errorString:string |
615 | 2467 |
! ! |
2468 |
||
2469 |
!Filename methodsFor:'file access'! |
|
2470 |
||
3015 | 2471 |
appendStream |
2472 |
"return a stream for appending to the file represented by the receiver. |
|
2473 |
If the file does not already exist, it is created. |
|
2474 |
Same as #appendingWriteStream for ST-80 compatibility." |
|
2475 |
||
2476 |
^ self appendingWriteStream |
|
2477 |
! |
|
2478 |
||
615 | 2479 |
appendingWriteStream |
2480 |
"return a stream for appending to the file represented by the receiver. |
|
5720 | 2481 |
If the file does not already exist, it is created; |
2482 |
if it does exist, writes are appended at the end." |
|
615 | 2483 |
|
2947 | 2484 |
^ FileStream appendingOldFileNamed:(self osNameForAccess) |
5720 | 2485 |
|
2486 |
" |
|
2487 |
|s| |
|
2488 |
||
2489 |
s := '/tmp/foo' asFilename writeStream. |
|
2490 |
s nextPutAll:'1234567890'. |
|
2491 |
s close. |
|
2492 |
||
2493 |
s := '/tmp/foo' asFilename appendingWriteStream. |
|
2494 |
s nextPutAll:'abcdef'. |
|
2495 |
s close. |
|
2496 |
||
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2497 |
'/tmp/foo' asFilename contents |
5720 | 2498 |
" |
615 | 2499 |
! |
2500 |
||
15490 | 2501 |
existingReadWriteStream |
2502 |
"return a stream for read/write the file represented by the receiver. |
|
2503 |
If the file does not already exist, an exception is raised." |
|
2504 |
||
2505 |
^ FileStream oldFileNamed:(self osNameForAccess) |
|
2506 |
||
2507 |
" |
|
2508 |
'/tmp/blaFaselQuall666666' asFilename remove. |
|
2509 |
'/tmp/blaFaselQuall666666' asFilename existingReadWriteStream. |
|
2510 |
" |
|
2511 |
" |
|
2512 |
|s| |
|
2513 |
s := '/tmp/foo' asFilename readWriteStream. |
|
2514 |
s nextPutAll:'1234567890'; close. |
|
2515 |
s := '/tmp/foo' asFilename existingReadWriteStream. |
|
2516 |
s nextPutAll:'abcdef'; close. |
|
2517 |
||
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2518 |
'/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
|
2519 |
'/tmp/foo' asFilename remove |
15490 | 2520 |
" |
2521 |
! |
|
2522 |
||
615 | 2523 |
newReadWriteStream |
2524 |
"return a stream for read/write the file represented by the receiver. |
|
5720 | 2525 |
If the file does not already exist, it is created; |
2526 |
if it does exist, it is truncated." |
|
615 | 2527 |
|
2947 | 2528 |
^ FileStream newFileNamed:(self osNameForAccess) |
5720 | 2529 |
|
2530 |
" |
|
2531 |
|s| |
|
2532 |
||
2533 |
s := '/tmp/foo' asFilename writeStream. |
|
2534 |
s nextPutAll:'1234567890'. |
|
2535 |
s close. |
|
2536 |
||
2537 |
s := '/tmp/foo' asFilename newReadWriteStream. |
|
2538 |
s nextPutAll:'12345'. |
|
2539 |
s close. |
|
2540 |
||
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2541 |
'/tmp/foo' asFilename contents |
5720 | 2542 |
" |
615 | 2543 |
! |
2544 |
||
15459 | 2545 |
openWithMode:anArrayOrString |
2546 |
"return a stream for read/write the file represented by the receiver. |
|
2547 |
If the file does not already exist, it is created; |
|
2548 |
if it does exist, it is truncated." |
|
2549 |
||
2550 |
^ FileStream open:self osNameForAccess withMode:anArrayOrString |
|
2551 |
||
2552 |
" |
|
2553 |
|s| |
|
2554 |
||
2555 |
s := '/tmp/foo' asFilename openWithMode:'r+'. |
|
2556 |
s nextPutAll:'1234567890'. |
|
2557 |
s close. |
|
2558 |
||
2559 |
||
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2560 |
'/tmp/foo' asFilename contents |
15459 | 2561 |
" |
2562 |
! |
|
2563 |
||
615 | 2564 |
readStream |
2565 |
"return a stream for reading from the file represented by the receiver. |
|
7828 | 2566 |
Raises an error if the file does not exist." |
615 | 2567 |
|
2947 | 2568 |
^ FileStream readonlyFileNamed:(self osNameForAccess) |
615 | 2569 |
|
2570 |
" |
|
17143 | 2571 |
'/tmp/foo' asFilename readStream. |
615 | 2572 |
" |
2573 |
! |
|
2574 |
||
2575 |
readWriteStream |
|
2576 |
"return a stream for read/write the file represented by the receiver. |
|
7828 | 2577 |
If the file does not already exist, it is created. |
2578 |
If the file does exist, it is NOT truncated, but rewritten at the beginning." |
|
615 | 2579 |
|
7088
cc3233554827
Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents:
7075
diff
changeset
|
2580 |
^ FileStream fileNamed:(self osNameForAccess) |
5720 | 2581 |
|
2582 |
" |
|
2583 |
|s| |
|
2584 |
||
2585 |
s := '/tmp/foo' asFilename writeStream. |
|
2586 |
s nextPutAll:'1234567890'. |
|
2587 |
s close. |
|
2588 |
||
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2589 |
s := '/tmp/foo' asFilename readWriteStream. |
5720 | 2590 |
s nextPutAll:'abcdef'. |
2591 |
s close. |
|
2592 |
||
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2593 |
'/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
|
2594 |
'/tmp/foo' asFilename remove |
5720 | 2595 |
" |
615 | 2596 |
! |
2597 |
||
2598 |
writeStream |
|
2599 |
"return a stream for writing to the file represented by the receiver. |
|
5720 | 2600 |
If the file does not already exist, it is created; |
2601 |
if it does exist, it is truncated." |
|
615 | 2602 |
|
2947 | 2603 |
^ FileStream newFileForWritingNamed:(self osNameForAccess) |
615 | 2604 |
|
2605 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2606 |
'/tmp/foo' asFilename writeStream |
615 | 2607 |
" |
5720 | 2608 |
|
2609 |
" |
|
2610 |
|s| |
|
2611 |
||
2612 |
s := '/tmp/foo' asFilename writeStream. |
|
2613 |
s nextPutAll:'1234567890'. |
|
2614 |
s close. |
|
2615 |
||
2616 |
s := '/tmp/foo' asFilename writeStream. |
|
2617 |
s nextPutAll:'12345'. |
|
2618 |
s close. |
|
2619 |
||
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2620 |
'/tmp/foo' asFilename contents |
5720 | 2621 |
" |
615 | 2622 |
! ! |
2623 |
||
8140
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2624 |
!Filename methodsFor:'file access - migration'! |
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2625 |
|
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2626 |
appendingWriteStreamOrNil |
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2627 |
"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
|
2628 |
If the file does not already exist, it is created; |
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2629 |
if it does exist, writes are appended at the end. |
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2630 |
|
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2631 |
Return nil, if the file cannot be opened. |
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2632 |
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
|
2633 |
instead of an exception when an error occurs." |
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2634 |
|
8280
0caa2f092e45
avoid expensive full-blocks (which return)
Claus Gittinger <cg@exept.de>
parents:
8243
diff
changeset
|
2635 |
^ [ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2636 |
FileStream appendingOldFileNamed:(self osNameForAccess) |
8280
0caa2f092e45
avoid expensive full-blocks (which return)
Claus Gittinger <cg@exept.de>
parents:
8243
diff
changeset
|
2637 |
] on:FileStream openErrorSignal do:[:ex| nil]. |
8140
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2638 |
! |
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2639 |
|
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2640 |
newReadWriteStreamOrNil |
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2641 |
"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
|
2642 |
If the file does not already exist, it is created; |
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2643 |
if it does exist, it is truncated. |
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2644 |
|
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2645 |
Return nil, if the file cannot be opened. |
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2646 |
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
|
2647 |
instead of an exception when an error occurs." |
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2648 |
|
8280
0caa2f092e45
avoid expensive full-blocks (which return)
Claus Gittinger <cg@exept.de>
parents:
8243
diff
changeset
|
2649 |
^ [ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2650 |
FileStream newFileNamed:(self osNameForAccess) |
8280
0caa2f092e45
avoid expensive full-blocks (which return)
Claus Gittinger <cg@exept.de>
parents:
8243
diff
changeset
|
2651 |
] on:FileStream openErrorSignal do:[:ex|nil]. |
8140
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2652 |
! |
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2653 |
|
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2654 |
readStreamOrNil |
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2655 |
"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
|
2656 |
If the file does not already exist, nil is returned. |
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2657 |
|
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2658 |
Return nil, if the file cannot be opened. |
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2659 |
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
|
2660 |
instead of an exception when an error occurs." |
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2661 |
|
8280
0caa2f092e45
avoid expensive full-blocks (which return)
Claus Gittinger <cg@exept.de>
parents:
8243
diff
changeset
|
2662 |
^ [ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2663 |
FileStream readonlyFileNamed:(self osNameForAccess) |
8280
0caa2f092e45
avoid expensive full-blocks (which return)
Claus Gittinger <cg@exept.de>
parents:
8243
diff
changeset
|
2664 |
] on:FileStream openErrorSignal do:[:ex|nil]. |
8140
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2665 |
|
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2666 |
" |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2667 |
'/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
|
2668 |
'/tmp/foo' asFilename readStream |
8140
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2669 |
" |
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2670 |
! |
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2671 |
|
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2672 |
readWriteStreamOrNil |
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2673 |
"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
|
2674 |
If the file does not already exist, it is created. |
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2675 |
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
|
2676 |
|
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2677 |
Return nil, if the file cannot be opened. |
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2678 |
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
|
2679 |
instead of an exception when an error occurs." |
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2680 |
|
8280
0caa2f092e45
avoid expensive full-blocks (which return)
Claus Gittinger <cg@exept.de>
parents:
8243
diff
changeset
|
2681 |
^ [ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2682 |
FileStream fileNamed:(self osNameForAccess) |
8280
0caa2f092e45
avoid expensive full-blocks (which return)
Claus Gittinger <cg@exept.de>
parents:
8243
diff
changeset
|
2683 |
] on:FileStream openErrorSignal do:[:ex|^ nil]. |
8140
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2684 |
! |
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2685 |
|
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2686 |
writeStreamOrNil |
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2687 |
"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
|
2688 |
If the file does not already exist, it is created; |
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2689 |
if it does exist, it is truncated. |
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2690 |
|
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2691 |
Return nil, if the file cannot be opened. |
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2692 |
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
|
2693 |
instead of an exception when an error occurs." |
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2694 |
|
8280
0caa2f092e45
avoid expensive full-blocks (which return)
Claus Gittinger <cg@exept.de>
parents:
8243
diff
changeset
|
2695 |
^ [ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2696 |
FileStream newFileForWritingNamed:(self osNameForAccess) |
8280
0caa2f092e45
avoid expensive full-blocks (which return)
Claus Gittinger <cg@exept.de>
parents:
8243
diff
changeset
|
2697 |
] on:FileStream openErrorSignal do:[:ex|^ nil]. |
8140
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2698 |
|
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2699 |
|
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2700 |
" |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2701 |
'/etc/foo' asFilename writeStreamOrNil |
8140
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2702 |
" |
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2703 |
! ! |
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8095
diff
changeset
|
2704 |
|
16310 | 2705 |
!Filename methodsFor:'file access rights'! |
615 | 2706 |
|
12529 | 2707 |
accessRights |
2708 |
"return the access rights of the file as opaque data |
|
2709 |
(SmallInteger in unix/linux)" |
|
2710 |
||
2711 |
^ OperatingSystem accessModeOf:self osNameForFile. |
|
2712 |
||
2713 |
" |
|
2714 |
'Make.proto' asFilename accessRights |
|
2715 |
" |
|
2716 |
! |
|
2717 |
||
2718 |
accessRights:opaqueData |
|
2719 |
"set the access rights of the file to opaqueData, |
|
2720 |
which is normally retrieved by Filename>>#accessRights." |
|
2721 |
||
2722 |
(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
|
2723 |
^ self accessDeniedError:self |
12529 | 2724 |
]. |
2725 |
||
2726 |
" |
|
2727 |
|rights| |
|
2728 |
||
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2729 |
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
|
2730 |
'Make.proto' asFilename accessRights:rights. |
12529 | 2731 |
" |
2732 |
||
2733 |
"Modified: / 5.5.1999 / 13:41:21 / cg" |
|
2734 |
! |
|
2735 |
||
615 | 2736 |
addAccessRights:aCollection |
2737 |
"add the access rights as specified in aCollection for the file represented |
|
2738 |
by the receiver. The argument must be a collection of symbols, |
|
2739 |
such as #readUser, #writeGroup etc." |
|
2740 |
||
2922 | 2741 |
|access osName| |
2742 |
||
2947 | 2743 |
osName := self osNameForFile. |
2922 | 2744 |
access := OperatingSystem accessModeOf:osName. |
615 | 2745 |
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
|
2746 |
access := access bitOr:(OperatingSystem accessMaskFor:accessSymbol). |
615 | 2747 |
]. |
2922 | 2748 |
(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
|
2749 |
^ self accessDeniedError:self |
615 | 2750 |
] |
2751 |
||
2752 |
" |
|
2753 |
'foo' asFilename writeStream close. |
|
2754 |
'foo' asFilename addAccessRights:#(readUser readGroup readOthers). |
|
2755 |
'foo' asFilename addAccessRights:#(writeUser writeGroup writeOthers). |
|
2756 |
'foo' asFilename addAccessRights:#(executeUser executeGroup executeOthers). |
|
2757 |
" |
|
2758 |
! |
|
2759 |
||
6223 | 2760 |
makeExecutable |
2761 |
"make the file executable - you must have permission to do so. |
|
2762 |
For directories, execution means: 'allow changing into it'" |
|
2763 |
||
2764 |
^ self addAccessRights:#(executeUser) |
|
2765 |
||
2766 |
"Created: 9.1.1996 / 15:32:47 / cg" |
|
2767 |
! |
|
2768 |
||
2769 |
makeExecutableForAll |
|
2770 |
"make the file executable for all - you must have permission to do so. |
|
2771 |
For directories, execution means: 'allow changing into it'" |
|
2772 |
||
2773 |
^ self addAccessRights:#(executeUser executeGroup executeOthers) |
|
2774 |
||
2775 |
"Created: 9.1.1996 / 15:32:28 / cg" |
|
2776 |
! |
|
2777 |
||
2778 |
makeExecutableForGroup |
|
2779 |
"make the file executable for the group - you must have permission to do so. |
|
2780 |
For directories, execution means: 'allow changing into it'" |
|
2781 |
||
2782 |
^ self addAccessRights:#(executeGroup) |
|
2783 |
||
2784 |
"Created: 9.1.1996 / 15:32:28 / cg" |
|
2785 |
! |
|
2786 |
||
2787 |
makeReadable |
|
2788 |
"make the file readable for the owner - you must have permission to do so." |
|
2789 |
||
2790 |
^ self addAccessRights:#(readUser) |
|
2791 |
! |
|
2792 |
||
2793 |
makeReadableForAll |
|
2794 |
"make the file readable for all - you must have permission to do so." |
|
2795 |
||
2796 |
^ self addAccessRights:#(readUser readGroup readOthers) |
|
2797 |
! |
|
2798 |
||
2799 |
makeReadableForGroup |
|
2800 |
"make the file readable for the group - you must have permission to do so." |
|
2801 |
||
2802 |
^ self addAccessRights:#(readGroup) |
|
2803 |
! |
|
2804 |
||
2805 |
makeUnwritable |
|
2806 |
"make the file unwritable for all - you must have permission to do so." |
|
2807 |
||
2808 |
^ self removeAccessRights:#(writeUser writeGroup writeOthers) |
|
2809 |
! |
|
2810 |
||
2811 |
makeWritable |
|
2812 |
"make the file writableable for all - you must have permission to do so." |
|
2813 |
||
2814 |
^ self addAccessRights:#(writeUser) |
|
2815 |
! |
|
2816 |
||
2817 |
makeWritableForAll |
|
2818 |
"make the file writable for all - you must have permission to do so." |
|
2819 |
||
2820 |
^ self addAccessRights:#(writeUser writeGroup writeOthers) |
|
2821 |
! |
|
2822 |
||
2823 |
makeWritableForGroup |
|
2824 |
"make the file writable for the group - you must have permission to do so." |
|
2825 |
||
2826 |
^ self addAccessRights:#(writeGroup) |
|
2827 |
! |
|
2828 |
||
2829 |
removeAccessRights:aCollection |
|
2830 |
"remove the access rights as specified in aCollection for the file represented |
|
2831 |
by the receiver. The argument must be a collection of symbols, |
|
2832 |
such as #readUser, #writeGroup etc. |
|
2833 |
Raises an exception if not successful." |
|
2834 |
||
2835 |
|access osName| |
|
2836 |
||
2837 |
osName := self osNameForFile. |
|
2838 |
access := OperatingSystem accessModeOf:osName. |
|
2839 |
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
|
2840 |
access := access bitAnd:(OperatingSystem accessMaskFor:accessSymbol) bitInvert. |
6223 | 2841 |
]. |
2842 |
(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
|
2843 |
^ self accessDeniedError:self |
6223 | 2844 |
]. |
2845 |
||
2846 |
" |
|
2847 |
'foo' asFilename writeStream close. |
|
2848 |
'foo' asFilename removeAccessRights:#(readUser readGroup readOthers). |
|
2849 |
'foo' asFilename removeAccessRights:#(writeUser writeGroup writeOthers). |
|
2850 |
'foo' asFilename removeAccessRights:#(executeUser executeGroup executeOthers). |
|
2851 |
" |
|
2852 |
||
2853 |
"Modified: / 5.5.1999 / 13:41:21 / cg" |
|
2854 |
! |
|
2855 |
||
2856 |
symbolicAccessRights |
|
2857 |
"return the access rights of the file as a aCollection of access symbols. |
|
2858 |
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
|
2859 |
#readUser, #writeGroup etc." |
6223 | 2860 |
|
2861 |
|access osName| |
|
2862 |
||
2863 |
osName := self osNameForFile. |
|
2864 |
access := OperatingSystem accessModeOf:osName. |
|
2865 |
||
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2866 |
^ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2867 |
#( readUser writeUser executeUser |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2868 |
readGroup writeGroup executeGroup |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2869 |
readOthers writeOthers executeOthers |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2870 |
) select:[:eachSymbolicAccessSymbol | |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2871 |
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
|
2872 |
]. |
6223 | 2873 |
|
2874 |
" |
|
2875 |
'Makefile' asFilename symbolicAccessRights |
|
2876 |
" |
|
2877 |
||
2878 |
"Modified: / 5.5.1999 / 13:41:21 / cg" |
|
2879 |
! |
|
2880 |
||
2881 |
symbolicAccessRights:aCollectionOfSymbols |
|
2882 |
"set the access rights of the file given a aCollection of access symbols. |
|
2883 |
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
|
2884 |
#readUser, #writeGroup etc." |
6223 | 2885 |
|
2886 |
|access osName| |
|
2887 |
||
2888 |
osName := self osNameForFile. |
|
2889 |
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
|
2890 |
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
|
2891 |
]. |
6223 | 2892 |
|
2893 |
(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
|
2894 |
^ self accessDeniedError:self |
6223 | 2895 |
]. |
2896 |
||
2897 |
" |
|
2898 |
|rights| |
|
2899 |
||
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2900 |
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
|
2901 |
'Makefile' asFilename symbolicAccessRights:(rights , #(executeOthers)). |
6223 | 2902 |
" |
2903 |
||
2904 |
"Modified: / 5.5.1999 / 13:41:21 / cg" |
|
2905 |
! ! |
|
2906 |
||
2907 |
!Filename methodsFor:'file operations'! |
|
2908 |
||
7329 | 2909 |
appendTo:newNameOrStream |
2910 |
"append the file - the argument must be convertable to a filename. |
|
2911 |
Raises an exception, if an error occurs." |
|
2912 |
||
2913 |
|inStream outStream outStreamToClose| |
|
2914 |
||
2915 |
inStream := self readStream. |
|
2916 |
[ |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2917 |
newNameOrStream isStream ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2918 |
outStream := newNameOrStream. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2919 |
] ifFalse:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2920 |
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
|
2921 |
]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2922 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2923 |
inStream binary. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2924 |
outStream binary. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2925 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2926 |
[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2927 |
inStream copyToEndInto:outStream. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2928 |
] 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
|
2929 |
^ self fileCreationError:newNameOrStream |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2930 |
] |
7329 | 2931 |
] ensure:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2932 |
inStream close. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2933 |
outStreamToClose notNil ifTrue:[outStreamToClose close]. |
7329 | 2934 |
]. |
2935 |
||
2936 |
" |
|
2937 |
'/etc/group' asFilename appendTo:'/tmp/Makefile.foo'. |
|
2938 |
'Makefile' asFilename appendTo:'/tmp/Makefile.foo' |
|
2939 |
'Makefile' asFilename copyTo:'/' |
|
2940 |
'smalltalk' asFilename copyTo:'/dev/null' |
|
2941 |
" |
|
2942 |
||
2943 |
"Modified: / 23.12.1999 / 21:52:36 / cg" |
|
2944 |
! |
|
2945 |
||
2982 | 2946 |
basicMakeDirectory |
2947 |
"create a directory with the receivers name. |
|
2948 |
Return true if successful, false if not." |
|
2949 |
||
2950 |
^ OperatingSystem createDirectory:(self osNameForDirectory) |
|
2951 |
! |
|
2952 |
||
10020 | 2953 |
copyTo:newNameArg |
16578 | 2954 |
"Copy the file's contents into another file. |
9235 | 2955 |
The argument must be convertable to a filename. |
4148
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
2956 |
Raises an exception, if an error occurs." |
615 | 2957 |
|
12529 | 2958 |
|newName inStream outStream newNameAlreadyExists| |
10020 | 2959 |
|
2960 |
newName := newNameArg asFilename. |
|
6804
caf6a4521d4c
added utility: ExternalStream >> copyToEndInto:
Claus Gittinger <cg@exept.de>
parents:
6803
diff
changeset
|
2961 |
|
8535 | 2962 |
"Contents is not copied if newName represent same file as me." |
10020 | 2963 |
newName asAbsoluteFilename = self asAbsoluteFilename ifTrue: [ ^ self ]. |
8535 | 2964 |
|
615 | 2965 |
inStream := self readStream. |
17143 | 2966 |
inStream isNil ifTrue:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2967 |
"open failed, but somenone did a proceed for the OpenError. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2968 |
Ignore this file but continue in order to copy the rest when |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2969 |
doing a recursive copy" |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2970 |
^ self. |
17143 | 2971 |
]. |
2972 |
||
6804
caf6a4521d4c
added utility: ExternalStream >> copyToEndInto:
Claus Gittinger <cg@exept.de>
parents:
6803
diff
changeset
|
2973 |
[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2974 |
newNameAlreadyExists := newName exists. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2975 |
outStream := newName writeStream. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2976 |
newNameAlreadyExists ifFalse:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2977 |
[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2978 |
"would be nice to keep the access rights of the original test suite" |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2979 |
newName accessRights:self accessRights. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2980 |
] on:OperatingSystem accessDeniedErrorSignal do:[:ex| |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2981 |
"ignore the error - may occure when copying to a network drive" |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2982 |
]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2983 |
]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2984 |
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
|
2985 |
outStream binary; buffered:false. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2986 |
inStream copyToEndInto:outStream. |
6804
caf6a4521d4c
added utility: ExternalStream >> copyToEndInto:
Claus Gittinger <cg@exept.de>
parents:
6803
diff
changeset
|
2987 |
] ensure:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2988 |
inStream close. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
2989 |
outStream notNil ifTrue:[outStream close]. |
615 | 2990 |
]. |
2991 |
||
2992 |
" |
|
12529 | 2993 |
'Make.proto' asFilename copyTo:'/tmp/Makefile.foo' |
2994 |
'Make.proto' asFilename copyTo:'/' |
|
615 | 2995 |
'smalltalk' asFilename copyTo:'/dev/null' |
2996 |
" |
|
4148
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
2997 |
|
10020 | 2998 |
"Modified: / 10-09-2004 / 09:49:28 / janfrog" |
2999 |
"Modified: / 29-09-2006 / 16:26:32 / cg" |
|
615 | 3000 |
! |
3001 |
||
15465 | 3002 |
copyToStream:outStream |
16578 | 3003 |
"Copy the file's contents into another file. |
15465 | 3004 |
The argument must be convertable to a filename. |
3005 |
Raises an exception, if an error occurs." |
|
3006 |
||
15858 | 3007 |
|inStream resetBinary| |
15465 | 3008 |
|
3009 |
"Contents is not copied if newName represent same file as me." |
|
3010 |
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
|
3011 |
outStream fileName asAbsoluteFilename = self asAbsoluteFilename ifTrue: [ ^ self ]. |
15465 | 3012 |
]. |
3013 |
||
3014 |
inStream := self readStream. |
|
3015 |
[ |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3016 |
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
|
3017 |
resetBinary := false. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3018 |
outStream isBinary ifFalse:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3019 |
outStream binary. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3020 |
resetBinary := true. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3021 |
]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3022 |
inStream copyToEndInto:outStream. |
15465 | 3023 |
] ensure:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3024 |
inStream close. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3025 |
resetBinary ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3026 |
outStream text. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3027 |
]. |
15465 | 3028 |
]. |
3029 |
||
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3030 |
" |
15465 | 3031 |
|out| |
3032 |
out := FileStream newTemporary. |
|
3033 |
'Make.proto' asFilename copyToStream:out. |
|
3034 |
out reset; contents |
|
3035 |
" |
|
3036 |
! |
|
3037 |
||
6983 | 3038 |
createAsEmptyFile |
3039 |
"create an empty file with the receivers name. |
|
3040 |
Raises an exception if not successful |
|
3041 |
(either already existing or creation not possible)" |
|
3042 |
||
3043 |
|writeStream| |
|
3044 |
||
3045 |
self exists ifTrue:[ |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3046 |
OperatingSystem accessDeniedErrorSignal |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3047 |
raiseRequestWith:self |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3048 |
errorString:(' - file exists: ' , self asString). |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3049 |
^ self |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3050 |
]. |
6983 | 3051 |
|
3052 |
FileStream 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
|
3053 |
self fileCreationError:self. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3054 |
^ self |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3055 |
] do:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3056 |
writeStream := self newReadWriteStream. |
6983 | 3057 |
]. |
3058 |
writeStream close. |
|
3059 |
! |
|
3060 |
||
17143 | 3061 |
createAsSymbolicLinkTo:linkFilenameString |
3062 |
"create a directory with the receivers name. |
|
3063 |
Raises an exception if not successful" |
|
3064 |
||
3065 |
OperatingSystem createSymbolicLinkFrom:linkFilenameString to:self pathName. |
|
3066 |
||
3067 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3068 |
'/tmp/link' asFilename makeSymbolicLinkTo:'bla' |
17143 | 3069 |
" |
3070 |
! |
|
3071 |
||
615 | 3072 |
delete |
3073 |
"remove the file - same as remove, for ST-80 compatibility" |
|
3074 |
||
3075 |
self remove |
|
3076 |
! |
|
3077 |
||
3078 |
makeDirectory |
|
3079 |
"create a directory with the receivers name. |
|
4148
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3080 |
Raises an exception if not successful" |
615 | 3081 |
|
2982 | 3082 |
(self basicMakeDirectory) ifFalse:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3083 |
"/ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3084 |
"/ could have existed before ... |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3085 |
"/ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3086 |
(self exists and:[self isDirectory]) ifFalse:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3087 |
self fileCreationError:self. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3088 |
^ false |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3089 |
] |
2982 | 3090 |
]. |
3091 |
^ true |
|
1970 | 3092 |
|
4148
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3093 |
"Modified: / 5.5.1999 / 13:36:33 / cg" |
615 | 3094 |
! |
3095 |
||
6996
720a54a2a358
move now also supports recursive directory moves
Claus Gittinger <cg@exept.de>
parents:
6995
diff
changeset
|
3096 |
moveFileTo:newName |
720a54a2a358
move now also supports recursive directory moves
Claus Gittinger <cg@exept.de>
parents:
6995
diff
changeset
|
3097 |
"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
|
3098 |
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
|
3099 |
Raise an exception if not successful. |
720a54a2a358
move now also supports recursive directory moves
Claus Gittinger <cg@exept.de>
parents:
6995
diff
changeset
|
3100 |
(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
|
3101 |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3102 |
[self renameTo:newName] |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3103 |
on:OsError |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3104 |
do:[:ex | |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3105 |
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
|
3106 |
ex reject |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3107 |
]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3108 |
self safeCopyTo:newName. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3109 |
self remove |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3110 |
]. |
6996
720a54a2a358
move now also supports recursive directory moves
Claus Gittinger <cg@exept.de>
parents:
6995
diff
changeset
|
3111 |
|
720a54a2a358
move now also supports recursive directory moves
Claus Gittinger <cg@exept.de>
parents:
6995
diff
changeset
|
3112 |
" |
720a54a2a358
move now also supports recursive directory moves
Claus Gittinger <cg@exept.de>
parents:
6995
diff
changeset
|
3113 |
|f s| |
720a54a2a358
move now also supports recursive directory moves
Claus Gittinger <cg@exept.de>
parents:
6995
diff
changeset
|
3114 |
|
720a54a2a358
move now also supports recursive directory moves
Claus Gittinger <cg@exept.de>
parents:
6995
diff
changeset
|
3115 |
f := '/tmp/foo' asFilename. |
720a54a2a358
move now also supports recursive directory moves
Claus Gittinger <cg@exept.de>
parents:
6995
diff
changeset
|
3116 |
s := f writeStream. |
720a54a2a358
move now also supports recursive directory moves
Claus Gittinger <cg@exept.de>
parents:
6995
diff
changeset
|
3117 |
s nextPutLine:'hello'. |
720a54a2a358
move now also supports recursive directory moves
Claus Gittinger <cg@exept.de>
parents:
6995
diff
changeset
|
3118 |
s close. |
720a54a2a358
move now also supports recursive directory moves
Claus Gittinger <cg@exept.de>
parents:
6995
diff
changeset
|
3119 |
f renameTo:'./foo' |
720a54a2a358
move now also supports recursive directory moves
Claus Gittinger <cg@exept.de>
parents:
6995
diff
changeset
|
3120 |
" |
720a54a2a358
move now also supports recursive directory moves
Claus Gittinger <cg@exept.de>
parents:
6995
diff
changeset
|
3121 |
|
720a54a2a358
move now also supports recursive directory moves
Claus Gittinger <cg@exept.de>
parents:
6995
diff
changeset
|
3122 |
" |
720a54a2a358
move now also supports recursive directory moves
Claus Gittinger <cg@exept.de>
parents:
6995
diff
changeset
|
3123 |
|f s| |
720a54a2a358
move now also supports recursive directory moves
Claus Gittinger <cg@exept.de>
parents:
6995
diff
changeset
|
3124 |
|
720a54a2a358
move now also supports recursive directory moves
Claus Gittinger <cg@exept.de>
parents:
6995
diff
changeset
|
3125 |
f := '/tmp/foo' asFilename. |
720a54a2a358
move now also supports recursive directory moves
Claus Gittinger <cg@exept.de>
parents:
6995
diff
changeset
|
3126 |
s := f writeStream. |
720a54a2a358
move now also supports recursive directory moves
Claus Gittinger <cg@exept.de>
parents:
6995
diff
changeset
|
3127 |
s nextPutLine:'hello'. |
720a54a2a358
move now also supports recursive directory moves
Claus Gittinger <cg@exept.de>
parents:
6995
diff
changeset
|
3128 |
s close. |
720a54a2a358
move now also supports recursive directory moves
Claus Gittinger <cg@exept.de>
parents:
6995
diff
changeset
|
3129 |
f moveTo:'./foo' |
720a54a2a358
move now also supports recursive directory moves
Claus Gittinger <cg@exept.de>
parents:
6995
diff
changeset
|
3130 |
" |
720a54a2a358
move now also supports recursive directory moves
Claus Gittinger <cg@exept.de>
parents:
6995
diff
changeset
|
3131 |
! |
720a54a2a358
move now also supports recursive directory moves
Claus Gittinger <cg@exept.de>
parents:
6995
diff
changeset
|
3132 |
|
16490 | 3133 |
moveTo:newNameArg |
615 | 3134 |
"copy the file represented by the receiver, then delete it. |
3135 |
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
|
3136 |
Raise an exception if not successful. |
3d801043be3f
dont read the whole directory in #directoryContentsDo:
Claus Gittinger <cg@exept.de>
parents:
5577
diff
changeset
|
3137 |
(Notice, that a rename is tried first, in case of non-cross device move)" |
615 | 3138 |
|
16490 | 3139 |
|newName| |
3140 |
||
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3141 |
newName := newNameArg asFilename. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3142 |
[self renameTo:newName] |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3143 |
on:(OSErrorHolder inappropriateReferentSignal) |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3144 |
do:[:ex | |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3145 |
"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
|
3146 |
self isDirectory ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3147 |
self recursiveMoveDirectoryTo:newName. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3148 |
] ifFalse:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3149 |
self safeCopyTo:newName. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3150 |
self remove. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3151 |
]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3152 |
]. |
5507
e8c61b1741c6
in #moveTo: - try a link first, then do a copy-remove.
Claus Gittinger <cg@exept.de>
parents:
5303
diff
changeset
|
3153 |
|
e8c61b1741c6
in #moveTo: - try a link first, then do a copy-remove.
Claus Gittinger <cg@exept.de>
parents:
5303
diff
changeset
|
3154 |
" |
e8c61b1741c6
in #moveTo: - try a link first, then do a copy-remove.
Claus Gittinger <cg@exept.de>
parents:
5303
diff
changeset
|
3155 |
|f s| |
e8c61b1741c6
in #moveTo: - try a link first, then do a copy-remove.
Claus Gittinger <cg@exept.de>
parents:
5303
diff
changeset
|
3156 |
|
e8c61b1741c6
in #moveTo: - try a link first, then do a copy-remove.
Claus Gittinger <cg@exept.de>
parents:
5303
diff
changeset
|
3157 |
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
|
3158 |
s := f writeStream. |
e8c61b1741c6
in #moveTo: - try a link first, then do a copy-remove.
Claus Gittinger <cg@exept.de>
parents:
5303
diff
changeset
|
3159 |
s nextPutLine:'hello'. |
e8c61b1741c6
in #moveTo: - try a link first, then do a copy-remove.
Claus Gittinger <cg@exept.de>
parents:
5303
diff
changeset
|
3160 |
s close. |
e8c61b1741c6
in #moveTo: - try a link first, then do a copy-remove.
Claus Gittinger <cg@exept.de>
parents:
5303
diff
changeset
|
3161 |
f renameTo:'./foo' |
e8c61b1741c6
in #moveTo: - try a link first, then do a copy-remove.
Claus Gittinger <cg@exept.de>
parents:
5303
diff
changeset
|
3162 |
" |
e8c61b1741c6
in #moveTo: - try a link first, then do a copy-remove.
Claus Gittinger <cg@exept.de>
parents:
5303
diff
changeset
|
3163 |
|
e8c61b1741c6
in #moveTo: - try a link first, then do a copy-remove.
Claus Gittinger <cg@exept.de>
parents:
5303
diff
changeset
|
3164 |
" |
e8c61b1741c6
in #moveTo: - try a link first, then do a copy-remove.
Claus Gittinger <cg@exept.de>
parents:
5303
diff
changeset
|
3165 |
|f s| |
e8c61b1741c6
in #moveTo: - try a link first, then do a copy-remove.
Claus Gittinger <cg@exept.de>
parents:
5303
diff
changeset
|
3166 |
|
e8c61b1741c6
in #moveTo: - try a link first, then do a copy-remove.
Claus Gittinger <cg@exept.de>
parents:
5303
diff
changeset
|
3167 |
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
|
3168 |
s := f writeStream. |
e8c61b1741c6
in #moveTo: - try a link first, then do a copy-remove.
Claus Gittinger <cg@exept.de>
parents:
5303
diff
changeset
|
3169 |
s nextPutLine:'hello'. |
e8c61b1741c6
in #moveTo: - try a link first, then do a copy-remove.
Claus Gittinger <cg@exept.de>
parents:
5303
diff
changeset
|
3170 |
s close. |
e8c61b1741c6
in #moveTo: - try a link first, then do a copy-remove.
Claus Gittinger <cg@exept.de>
parents:
5303
diff
changeset
|
3171 |
f moveTo:'./foo' |
e8c61b1741c6
in #moveTo: - try a link first, then do a copy-remove.
Claus Gittinger <cg@exept.de>
parents:
5303
diff
changeset
|
3172 |
" |
4148
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3173 |
! |
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3174 |
|
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3175 |
recursiveCopyTo:destination |
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3176 |
"if I represent a regular file, copy it. |
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3177 |
Otherwise, copy the directory and recursively |
12975 | 3178 |
all of its subfiles/subdirectories. |
17143 | 3179 |
|
3180 |
Raises an exception if not successful. |
|
3181 |
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
|
3182 |
If a whole directory is to be copied and the destination directory |
17143 | 3183 |
does not exist, it will be created." |
3184 |
||
3185 |
|ok destinationFilename| |
|
3186 |
||
3187 |
destinationFilename := destination asFilename. |
|
4148
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3188 |
self isDirectory ifFalse:[ |
18952 | 3189 |
destinationFilename isDirectory ifTrue:[ |
3190 |
destinationFilename := destinationFilename construct:self baseName. |
|
3191 |
]. |
|
3192 |
self copyTo:destinationFilename. |
|
3193 |
^ self. |
|
4148
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3194 |
]. |
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3195 |
|
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3196 |
"/ typically, an 'cp -r' is faster; |
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3197 |
"/ 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
|
3198 |
"/ fallBack doing a manual directory walk. |
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3199 |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3200 |
ok := OperatingSystem |
18952 | 3201 |
recursiveCopyDirectory:(self osNameForDirectory) |
3202 |
to:(destinationFilename osNameForDirectory). |
|
4148
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3203 |
|
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3204 |
ok ifFalse:[ |
18952 | 3205 |
self recursiveCopyWithoutOSCommandTo:destinationFilename |
3206 |
]. |
|
3207 |
||
3208 |
" |
|
3209 |
'.' asFilename recursiveCopyTo:'/temp/xxx'. |
|
17143 | 3210 |
" |
3211 |
||
12975 | 3212 |
"Created: / 05-05-1999 / 13:35:01 / cg" |
3213 |
"Modified: / 31-05-1999 / 13:11:34 / cg" |
|
3214 |
"Modified: / 29-07-2010 / 12:41:06 / sr" |
|
4148
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3215 |
! |
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3216 |
|
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3217 |
recursiveCopyWithoutOSCommandTo:destination |
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3218 |
"if I represent a regular file, copy it. |
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3219 |
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
|
3220 |
This one walks down the directory hierarchy, not using any OS command to do the copy. |
17143 | 3221 |
Raises an exception if not successful. |
3222 |
||
3223 |
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
|
3224 |
If a whole directory is to be copied and the destination directory |
17143 | 3225 |
does not exist, it will be created." |
4148
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3226 |
|
12529 | 3227 |
|destinationFilename| |
3228 |
||
3229 |
destinationFilename := destination asFilename. |
|
4148
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3230 |
|
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3231 |
self isDirectory ifTrue:[ |
18952 | 3232 |
destinationFilename exists ifFalse:[ |
3233 |
destinationFilename makeDirectory. |
|
3234 |
destinationFilename accessRights:self accessRights. |
|
3235 |
]. |
|
3236 |
||
3237 |
self directoryContentsDo:[:aFilenameString | |
|
3238 |
|src srcInfo dst info| |
|
3239 |
||
3240 |
src := self construct:aFilenameString. |
|
3241 |
dst := destinationFilename construct:aFilenameString. |
|
3242 |
||
3243 |
srcInfo := src linkInfo. |
|
3244 |
srcInfo isDirectory ifTrue:[ |
|
3245 |
src recursiveCopyWithoutOSCommandTo:dst |
|
3246 |
] ifFalse:[srcInfo isSymbolicLink ifTrue:[ |
|
3247 |
dst |
|
3248 |
remove; |
|
3249 |
createAsSymbolicLinkTo:src linkInfo path. |
|
3250 |
] ifFalse:[ |
|
3251 |
src copyTo:dst. |
|
3252 |
]]. |
|
3253 |
]. |
|
4148
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3254 |
] ifFalse:[ |
18952 | 3255 |
destinationFilename isDirectory ifTrue:[ |
3256 |
destinationFilename := destinationFilename construct:self baseName. |
|
3257 |
]. |
|
3258 |
self copyTo:destinationFilename. |
|
4148
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3259 |
] |
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3260 |
|
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3261 |
" |
18952 | 3262 |
'.' asFilename recursiveCopyWithoutOSCommandTo:'/temp/xxx'. |
4148
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3263 |
'smalltalk.rc' asFilename recursiveCopyWithoutOSCommandTo:'/tmp/xxx'. |
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3264 |
" |
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3265 |
|
4246 | 3266 |
"Modified: / 31.5.1999 / 18:12:31 / cg" |
615 | 3267 |
! |
3268 |
||
659 | 3269 |
recursiveMakeDirectory |
18490 | 3270 |
"create a directory with the receiver's name and all required intermediate |
659 | 3271 |
directories. |
4148
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3272 |
Raises an exception if not successful." |
659 | 3273 |
|
2922 | 3274 |
(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
|
3275 |
^ self fileCreationError:self |
659 | 3276 |
] |
3277 |
||
4148
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3278 |
"Created: / 27.11.1995 / 23:36:40 / cg" |
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3279 |
"Modified: / 5.5.1999 / 13:38:42 / cg" |
659 | 3280 |
! |
3281 |
||
6997 | 3282 |
recursiveMoveDirectoryTo:newName |
3283 |
"recursively copy the directory represented by the receiver, then delete it. |
|
3284 |
This is different to renaming in case of cross device moves. |
|
3285 |
Raise an exception if not successful. |
|
3286 |
(Notice, that a rename is tried first, in case of non-cross device move)" |
|
3287 |
||
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3288 |
[self renameTo:newName] |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3289 |
on:OsError |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3290 |
do:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3291 |
self recursiveCopyTo:newName. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3292 |
self recursiveRemove |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3293 |
]. |
6997 | 3294 |
! |
3295 |
||
615 | 3296 |
recursiveRemove |
3299
5abe74e42d94
recursiveRemove is now done without OS support.
Claus Gittinger <cg@exept.de>
parents:
3171
diff
changeset
|
3297 |
"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
|
3298 |
Otherwise, remove the directory and all of its subfiles/subdirectories. |
4148
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3299 |
Raise an exception if not successful." |
615 | 3300 |
|
3301 |
|ok| |
|
3302 |
||
3302 | 3303 |
"/ 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
|
3304 |
"/ 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
|
3305 |
"/ fallBack doing a manual directory walk. |
3302 | 3306 |
|
3307 |
ok := OperatingSystem recursiveRemoveDirectory:(self osNameForDirectory). |
|
3308 |
ok ifFalse:[ |
|
18952 | 3309 |
self recursiveRemoveWithoutOSCommand |
3310 |
]. |
|
3311 |
||
3312 |
" |
|
3313 |
'foo/bar' asFilename recursiveMakeDirectory. |
|
3314 |
'foo' asFilename remove. |
|
3315 |
self assert:('foo' asFilename exists not). |
|
3316 |
||
3317 |
||
3318 |
'foo' asFilename recursiveRemove. |
|
3319 |
'foo/bar' asFilename recursiveMakeDirectory. |
|
3320 |
'foo' asFilename recursiveRemove. |
|
3321 |
self assert:('foo' asFilename exists not). |
|
3302 | 3322 |
" |
3323 |
||
3324 |
"Created: / 14.11.1995 / 11:19:29 / cg" |
|
4148
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3325 |
"Modified: / 5.5.1999 / 13:43:35 / cg" |
3302 | 3326 |
! |
3327 |
||
13246 | 3328 |
recursiveRemoveAll |
13247
9e47a0e73ba4
comment/format in: #recursiveRemoveAll
Claus Gittinger <cg@exept.de>
parents:
13246
diff
changeset
|
3329 |
"Remove all of my subfiles/subdirectories. |
3302 | 3330 |
Raise an error if not successful. |
3331 |
This one walks down the directory hierarchy, not using any OS |
|
3332 |
command to do the remove." |
|
3299
5abe74e42d94
recursiveRemove is now done without OS support.
Claus Gittinger <cg@exept.de>
parents:
3171
diff
changeset
|
3333 |
|
18952 | 3334 |
|removeFailedError| |
4939 | 3335 |
|
3299
5abe74e42d94
recursiveRemove is now done without OS support.
Claus Gittinger <cg@exept.de>
parents:
3171
diff
changeset
|
3336 |
self isDirectory ifTrue:[ |
18952 | 3337 |
removeFailedError := OperatingSystem accessDeniedErrorSignal. |
3338 |
self directoryContentsAsFilenamesDo:[:eachFilename | |
|
3339 |
removeFailedError handle:[:ex | |
|
3340 |
eachFilename isDirectory ifFalse:[ ex reject ]. |
|
3341 |
eachFilename |
|
3342 |
recursiveRemoveAll; |
|
3343 |
removeDirectory. |
|
3344 |
] do:[ |
|
3345 |
eachFilename remove |
|
3346 |
]. |
|
3347 |
||
3348 |
"/ eachFilename isDirectory ifTrue:[ |
|
3349 |
"/ eachFilename recursiveRemoveWithoutOSCommand |
|
3350 |
"/ ] ifFalse:[ |
|
3351 |
"/ eachFilename remove |
|
3352 |
"/ ]. |
|
3353 |
] |
|
615 | 3354 |
]. |
13246 | 3355 |
|
3356 |
" |
|
3357 |
'foo' asFilename makeDirectory. |
|
3358 |
'foo/bar' asFilename writeStream close. |
|
3359 |
'foo' asFilename remove |
|
3360 |
" |
|
3361 |
" |
|
3362 |
'foo' asFilename makeDirectory. |
|
3363 |
'foo/bar' asFilename writeStream close. |
|
18952 | 3364 |
'foo' asFilename recursiveRemove. |
3365 |
self assert:('foo' asFilename exists not). |
|
13246 | 3366 |
" |
3367 |
||
3368 |
"Created: / 25-01-2011 / 16:42:15 / cg" |
|
3369 |
! |
|
3370 |
||
3371 |
recursiveRemoveWithoutOSCommand |
|
3372 |
"if I represent a regular file, remove it. |
|
3373 |
Otherwise, remove the directory and all of its subfiles/subdirectories. |
|
3374 |
Raise an error if not successful. |
|
3375 |
This one walks down the directory hierarchy, not using any OS |
|
3376 |
command to do the remove." |
|
3377 |
||
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3378 |
self |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3379 |
recursiveRemoveAll; |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3380 |
remove. |
615 | 3381 |
|
3382 |
" |
|
3383 |
'foo' asFilename makeDirectory. |
|
3384 |
'foo/bar' asFilename writeStream close. |
|
4940 | 3385 |
'foo' asFilename remove |
615 | 3386 |
" |
3387 |
" |
|
3388 |
'foo' asFilename makeDirectory. |
|
3389 |
'foo/bar' asFilename writeStream close. |
|
4940 | 3390 |
'foo' asFilename recursiveRemove |
615 | 3391 |
" |
3392 |
||
13246 | 3393 |
"Created: / 25-02-1998 / 19:50:40 / cg" |
13949 | 3394 |
"Modified: / 19-01-2012 / 17:18:28 / cg" |
615 | 3395 |
! |
3396 |
||
3397 |
remove |
|
845 | 3398 |
"remove the file/directory. |
4148
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3399 |
Raises an exception if not successful. |
845 | 3400 |
Use #recursiveRemove in order to (recursively) remove non empty directories." |
615 | 3401 |
|
8741 | 3402 |
|linkInfo osName ok| |
3403 |
||
18952 | 3404 |
osName := self osNameForAccess. |
3405 |
ok := OperatingSystem removeFile:osName. |
|
3406 |
ok ifFalse:[ |
|
3407 |
linkInfo := self linkInfo. |
|
3408 |
linkInfo isNil ifTrue:[ |
|
3409 |
"file does not exist - no error" |
|
3410 |
^ self. |
|
3411 |
] ifFalse:[linkInfo isDirectory ifTrue:[ |
|
3412 |
ok := OperatingSystem removeDirectory:osName |
|
3413 |
]]. |
|
3414 |
ok ifFalse:[ |
|
3415 |
self exists ifTrue:[ |
|
3416 |
self removeError:self pathName |
|
3417 |
] |
|
3418 |
] |
|
615 | 3419 |
]. |
3420 |
||
3421 |
" |
|
3422 |
(FileStream newFileNamed:'foo') close. |
|
3423 |
'foo' asFilename remove |
|
3424 |
" |
|
3425 |
||
3426 |
" |
|
3427 |
'foo' asFilename makeDirectory. |
|
3428 |
'foo/bar' asFilename writeStream close. |
|
8738 | 3429 |
'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
|
3430 |
'foo' asFilename recursiveRemove. |
615 | 3431 |
" |
3432 |
||
13793
3f1c660956ce
added: #new_recursiveRemoveAll
Claus Gittinger <cg@exept.de>
parents:
13781
diff
changeset
|
3433 |
"Modified: / 20-11-1997 / 17:40:22 / stefan" |
3f1c660956ce
added: #new_recursiveRemoveAll
Claus Gittinger <cg@exept.de>
parents:
13781
diff
changeset
|
3434 |
"Modified: / 11-10-2011 / 10:20:01 / cg" |
615 | 3435 |
! |
3436 |
||
5595
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3437 |
removeDirectory |
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3438 |
"remove the directory. |
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3439 |
Raises an exception if not successful (or if its not a directory). |
5596 | 3440 |
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
|
3441 |
Use #recursiveRemove in order to (recursively) remove non empty directories." |
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3442 |
|
18952 | 3443 |
(OperatingSystem removeDirectory:(self osNameForAccess)) ifFalse:[ |
3444 |
self exists ifFalse:[ ^ self]. |
|
3445 |
self removeError:self |
|
5595
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3446 |
]. |
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3447 |
|
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3448 |
" |
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3449 |
(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
|
3450 |
'foo' asFilename removeDirectory |
5595
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3451 |
" |
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3452 |
|
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3453 |
" |
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3454 |
'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
|
3455 |
'foo' asFilename removeDirectory |
5595
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3456 |
" |
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3457 |
|
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3458 |
" |
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3459 |
'foo' asFilename makeDirectory. |
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3460 |
'foo/bar' asFilename writeStream close. |
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3461 |
('foo' asFilename remove) ifFalse:[ |
18952 | 3462 |
Transcript showCR:'could not remove foo' |
5595
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3463 |
] |
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3464 |
" |
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3465 |
|
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3466 |
"Modified: / 20.11.1997 / 17:40:22 / stefan" |
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3467 |
"Modified: / 5.5.1999 / 13:41:12 / cg" |
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3468 |
! |
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3469 |
|
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3470 |
removeFile |
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3471 |
"remove the file. |
5596 | 3472 |
Raises an exception if not successful (or if its not a file). |
3473 |
Use #remove if it is not known if the receiver is a directory or file. |
|
3474 |
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
|
3475 |
|
18952 | 3476 |
(OperatingSystem removeFile:self osNameForAccess) ifFalse:[ |
3477 |
self exists ifTrue:[ |
|
3478 |
self removeError:self |
|
3479 |
]. |
|
5595
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3480 |
]. |
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3481 |
|
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3482 |
" |
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3483 |
(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
|
3484 |
'foo' asFilename removeFile |
5595
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3485 |
" |
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3486 |
|
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3487 |
" |
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3488 |
'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
|
3489 |
'foo' asFilename removeFile |
5595
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3490 |
" |
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3491 |
! |
b80d12c4983b
added #removeFile and #removeDirectory,
Claus Gittinger <cg@exept.de>
parents:
5594
diff
changeset
|
3492 |
|
16490 | 3493 |
renameTo:newNameArg |
671 | 3494 |
"rename the file - the argument must be convertable to a String. |
15823 | 3495 |
Raises an exception if not successful. |
3496 |
If newName already exists, it will be replaced by myself." |
|
615 | 3497 |
|
16490 | 3498 |
|errno newName| |
3499 |
||
3500 |
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
|
3501 |
(OperatingSystem |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3502 |
renameFile:(self osNameForFile) |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3503 |
to:(newName osNameForFile) |
2922 | 3504 |
) ifFalse:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3505 |
errno := OperatingSystem lastErrorNumber. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3506 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3507 |
self exists ifFalse:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3508 |
^ self fileNotFoundError:self |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3509 |
]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3510 |
(OperatingSystem errorHolderForNumber:errno) |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3511 |
parameter:newName; |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3512 |
reportError. |
615 | 3513 |
]. |
3514 |
||
3515 |
" |
|
3516 |
'/tmp/foo' asFilename renameTo:'/tmp/bar' |
|
3517 |
" |
|
4148
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3518 |
|
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3519 |
"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
|
3520 |
! |
f57ec42ceb44
added interface to truncate & ftruncate (req. by Mr. Olberding)
Claus Gittinger <cg@exept.de>
parents:
883
diff
changeset
|
3521 |
|
15819 | 3522 |
safeCopyTo:newNameArg |
16578 | 3523 |
"Copy the file's contents into another file. |
15819 | 3524 |
Do it safe in an atomic operation shich makes sure that no partially written file appears. |
3525 |
The argument must be convertable to a filename. |
|
3526 |
Raises an exception, if an error occurs." |
|
3527 |
||
15823 | 3528 |
|newName inStream accessRights tempStream| |
15819 | 3529 |
|
3530 |
newName := newNameArg asFilename. |
|
3531 |
||
3532 |
"Contents is not copied if newName represent same file as me." |
|
3533 |
newName asAbsoluteFilename = self asAbsoluteFilename ifTrue: [ ^ self ]. |
|
3534 |
||
3535 |
inStream := self readStream. |
|
15823 | 3536 |
newName exists ifTrue:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3537 |
accessRights := newName accessRights. |
15819 | 3538 |
] ifFalse:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3539 |
accessRights := self accessRights. |
15819 | 3540 |
]. |
3541 |
||
3542 |
[ |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3543 |
"let the temp filename start with a ~ to make it invisible" |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3544 |
tempStream := FileStream newTemporaryIn:newName directory osNameForFile nameTemplate:'~%1_%2'. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3545 |
[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3546 |
"would be nice to keep the access rights of the original file" |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3547 |
tempStream fileName accessRights:accessRights. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3548 |
] on:OperatingSystem accessDeniedErrorSignal do:[:ex| |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3549 |
"ignore the error - may occure when copying to a network drive" |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3550 |
]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3551 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3552 |
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
|
3553 |
tempStream binary; buffered:false. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3554 |
[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3555 |
inStream copyToEndInto:tempStream. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3556 |
] ifCurtailed:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3557 |
tempStream close. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3558 |
tempStream fileName remove. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3559 |
tempStream := nil. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3560 |
]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3561 |
tempStream syncData. |
15819 | 3562 |
] ensure:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3563 |
inStream close. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3564 |
tempStream notNil ifTrue:[tempStream close]. |
15819 | 3565 |
]. |
3566 |
tempStream fileName renameTo:newName. |
|
3567 |
||
3568 |
" |
|
3569 |
'Make.proto' asFilename safeCopyTo:'/tmp/Makefile.foo' |
|
3570 |
'Make.proto' asFilename safeCopyTo:'/' |
|
3571 |
'smalltalk' asFilename safeCopyTo:'/xxxxxxxxxxxxxxxx/bla' |
|
3572 |
" |
|
3573 |
||
3574 |
"Modified: / 10-09-2004 / 09:49:28 / janfrog" |
|
3575 |
"Modified: / 29-09-2006 / 16:26:32 / cg" |
|
3576 |
! |
|
3577 |
||
932
f57ec42ceb44
added interface to truncate & ftruncate (req. by Mr. Olberding)
Claus Gittinger <cg@exept.de>
parents:
883
diff
changeset
|
3578 |
truncateTo:newSize |
16578 | 3579 |
"change the file's size. |
4148
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3580 |
This may not be supported on all operating systems |
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3581 |
(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
|
3582 |
|
7888
e76fa60251dc
Remove obsolete nil-checks after opening streams
Stefan Vogel <sv@exept.de>
parents:
7846
diff
changeset
|
3583 |
(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
|
3584 |
^ 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
|
3585 |
] |
f57ec42ceb44
added interface to truncate & ftruncate (req. by Mr. Olberding)
Claus Gittinger <cg@exept.de>
parents:
883
diff
changeset
|
3586 |
|
f57ec42ceb44
added interface to truncate & ftruncate (req. by Mr. Olberding)
Claus Gittinger <cg@exept.de>
parents:
883
diff
changeset
|
3587 |
" |
f57ec42ceb44
added interface to truncate & ftruncate (req. by Mr. Olberding)
Claus Gittinger <cg@exept.de>
parents:
883
diff
changeset
|
3588 |
|s| |
f57ec42ceb44
added interface to truncate & ftruncate (req. by Mr. Olberding)
Claus Gittinger <cg@exept.de>
parents:
883
diff
changeset
|
3589 |
|
f57ec42ceb44
added interface to truncate & ftruncate (req. by Mr. Olberding)
Claus Gittinger <cg@exept.de>
parents:
883
diff
changeset
|
3590 |
s := 'test' asFilename writeStream. |
f57ec42ceb44
added interface to truncate & ftruncate (req. by Mr. Olberding)
Claus Gittinger <cg@exept.de>
parents:
883
diff
changeset
|
3591 |
s next:1000 put:$1. |
f57ec42ceb44
added interface to truncate & ftruncate (req. by Mr. Olberding)
Claus Gittinger <cg@exept.de>
parents:
883
diff
changeset
|
3592 |
s close. |
7888
e76fa60251dc
Remove obsolete nil-checks after opening streams
Stefan Vogel <sv@exept.de>
parents:
7846
diff
changeset
|
3593 |
('test' asFilename fileSize) printCR. |
932
f57ec42ceb44
added interface to truncate & ftruncate (req. by Mr. Olberding)
Claus Gittinger <cg@exept.de>
parents:
883
diff
changeset
|
3594 |
'test' asFilename truncateTo:100. |
7888
e76fa60251dc
Remove obsolete nil-checks after opening streams
Stefan Vogel <sv@exept.de>
parents:
7846
diff
changeset
|
3595 |
('test' asFilename fileSize) printCR. |
932
f57ec42ceb44
added interface to truncate & ftruncate (req. by Mr. Olberding)
Claus Gittinger <cg@exept.de>
parents:
883
diff
changeset
|
3596 |
" |
4148
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3597 |
|
70c391aa0e3e
added recursiveCopy support.
Claus Gittinger <cg@exept.de>
parents:
4131
diff
changeset
|
3598 |
"Modified: / 5.5.1999 / 13:41:59 / cg" |
615 | 3599 |
! ! |
3600 |
||
3601 |
!Filename methodsFor:'file queries'! |
|
3602 |
||
1532
6b4c38b9090c
added #modificationTime & #accessTime (easier to use than #dates)
Claus Gittinger <cg@exept.de>
parents:
1523
diff
changeset
|
3603 |
accessTime |
16578 | 3604 |
"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
|
3605 |
|
3768
4801b87c1cd7
care for non-existing info in #accessTime, #modTime and #fileSize
Claus Gittinger <cg@exept.de>
parents:
3763
diff
changeset
|
3606 |
| i | |
4801b87c1cd7
care for non-existing info in #accessTime, #modTime and #fileSize
Claus Gittinger <cg@exept.de>
parents:
3763
diff
changeset
|
3607 |
|
4801b87c1cd7
care for non-existing info in #accessTime, #modTime and #fileSize
Claus Gittinger <cg@exept.de>
parents:
3763
diff
changeset
|
3608 |
(i := self info) isNil ifTrue:[^ nil]. |
6793
0d3e3fd18a70
modified -> modificationTime
Claus Gittinger <cg@exept.de>
parents:
6776
diff
changeset
|
3609 |
^ i accessTime |
1532
6b4c38b9090c
added #modificationTime & #accessTime (easier to use than #dates)
Claus Gittinger <cg@exept.de>
parents:
1523
diff
changeset
|
3610 |
|
6b4c38b9090c
added #modificationTime & #accessTime (easier to use than #dates)
Claus Gittinger <cg@exept.de>
parents:
1523
diff
changeset
|
3611 |
" |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3612 |
Filename currentDirectory accessTime |
1532
6b4c38b9090c
added #modificationTime & #accessTime (easier to use than #dates)
Claus Gittinger <cg@exept.de>
parents:
1523
diff
changeset
|
3613 |
" |
6b4c38b9090c
added #modificationTime & #accessTime (easier to use than #dates)
Claus Gittinger <cg@exept.de>
parents:
1523
diff
changeset
|
3614 |
|
3768
4801b87c1cd7
care for non-existing info in #accessTime, #modTime and #fileSize
Claus Gittinger <cg@exept.de>
parents:
3763
diff
changeset
|
3615 |
"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
|
3616 |
"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
|
3617 |
"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
|
3618 |
! |
6b4c38b9090c
added #modificationTime & #accessTime (easier to use than #dates)
Claus Gittinger <cg@exept.de>
parents:
1523
diff
changeset
|
3619 |
|
6977 | 3620 |
creationTime |
16578 | 3621 |
"return a timeStamp containing the file's creation time. |
6977 | 3622 |
NOTICE: only windoof distinguishes creation from modification; |
6978 | 3623 |
under unix, nil is returned (callers should fall back and use mod-time then" |
6977 | 3624 |
|
3625 |
|i| |
|
3626 |
||
3627 |
(i := self info) isNil ifTrue:[^ nil]. "/ non-existing |
|
6978 | 3628 |
^ i creationTime |
3629 |
||
3630 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3631 |
Filename currentDirectory creationTime |
6977 | 3632 |
" |
3633 |
||
3634 |
"Created: / 9.7.1996 / 10:18:59 / cg" |
|
3635 |
"Modified: / 26.9.1997 / 13:05:39 / stefan" |
|
3636 |
"Modified: / 14.8.1998 / 17:42:50 / cg" |
|
3637 |
! |
|
3638 |
||
615 | 3639 |
dates |
16578 | 3640 |
"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
|
3641 |
that responds to the at: message with arguments |
615 | 3642 |
#modified, #accessed or #statusChanged." |
3643 |
||
2922 | 3644 |
|info dates osName| |
3645 |
||
2947 | 3646 |
osName := self osNameForAccess. |
2922 | 3647 |
info := OperatingSystem infoOf:osName. |
615 | 3648 |
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
|
3649 |
"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
|
3650 |
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
|
3651 |
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
|
3652 |
info isNil ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3653 |
^ nil |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3654 |
] |
615 | 3655 |
]. |
3656 |
dates := IdentityDictionary new. |
|
6978 | 3657 |
dates at:#created put:(info creationTime). |
6793
0d3e3fd18a70
modified -> modificationTime
Claus Gittinger <cg@exept.de>
parents:
6776
diff
changeset
|
3658 |
dates at:#modified put:(info modificationTime). |
0d3e3fd18a70
modified -> modificationTime
Claus Gittinger <cg@exept.de>
parents:
6776
diff
changeset
|
3659 |
dates at:#accessed put:(info accessTime). |
0d3e3fd18a70
modified -> modificationTime
Claus Gittinger <cg@exept.de>
parents:
6776
diff
changeset
|
3660 |
dates at:#statusChanged put:(info statusChangeTime). |
615 | 3661 |
^ dates |
3662 |
||
3663 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3664 |
Filename currentDirectory dates |
615 | 3665 |
'../regression' asFilename dates |
3666 |
" |
|
1859
7f6040320daf
changes for new return from OS>>infoOf:
Claus Gittinger <cg@exept.de>
parents:
1614
diff
changeset
|
3667 |
|
7f6040320daf
changes for new return from OS>>infoOf:
Claus Gittinger <cg@exept.de>
parents:
1614
diff
changeset
|
3668 |
"Modified: 1.11.1996 / 20:19:24 / cg" |
615 | 3669 |
! |
3670 |
||
3671 |
fileSize |
|
3672 |
"return the size of the file in bytes" |
|
3673 |
||
3768
4801b87c1cd7
care for non-existing info in #accessTime, #modTime and #fileSize
Claus Gittinger <cg@exept.de>
parents:
3763
diff
changeset
|
3674 |
|i| |
4801b87c1cd7
care for non-existing info in #accessTime, #modTime and #fileSize
Claus Gittinger <cg@exept.de>
parents:
3763
diff
changeset
|
3675 |
|
4801b87c1cd7
care for non-existing info in #accessTime, #modTime and #fileSize
Claus Gittinger <cg@exept.de>
parents:
3763
diff
changeset
|
3676 |
(i := self info) isNil ifTrue:[^ nil]. |
6794
498d85323172
use #fileSize instead of #size
Claus Gittinger <cg@exept.de>
parents:
6793
diff
changeset
|
3677 |
^ i fileSize |
3768
4801b87c1cd7
care for non-existing info in #accessTime, #modTime and #fileSize
Claus Gittinger <cg@exept.de>
parents:
3763
diff
changeset
|
3678 |
|
4801b87c1cd7
care for non-existing info in #accessTime, #modTime and #fileSize
Claus Gittinger <cg@exept.de>
parents:
3763
diff
changeset
|
3679 |
"Modified: / 17.8.1998 / 10:23:46 / cg" |
615 | 3680 |
! |
3681 |
||
3682 |
fileType |
|
3683 |
"this returns a string describing the type of contents of |
|
3684 |
the file. This is done using the unix 'file' command, |
|
3685 |
(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
|
3686 |
On non-unix systems, this may simply return 'file', |
2922 | 3687 |
not knowning about the contents. |
3688 |
Warning: |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3689 |
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
|
3690 |
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
|
3691 |
NOT as a tag to be used by a program." |
3665 | 3692 |
|
16755 | 3693 |
|suffix baseNm info mime| |
3665 | 3694 |
|
3695 |
"/ 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
|
3696 |
"/ do the most obvious ones here. |
3665 | 3697 |
"/ (also useful since the 'file' command takes some time, and the code |
3698 |
"/ 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
|
3699 |
|
8477
c962d56c1973
#linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents:
8280
diff
changeset
|
3700 |
info := self linkInfo. |
9060 | 3701 |
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
|
3702 |
^ 'removed' "/ could happen, when coming from a snapshot image |
9060 | 3703 |
]. |
3704 |
||
8477
c962d56c1973
#linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents:
8280
diff
changeset
|
3705 |
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
|
3706 |
^ 'symbolic link to ' , info path |
1601
1d57e1047323
avoid calling 'file' for symbolic links & directories
Claus Gittinger <cg@exept.de>
parents:
1540
diff
changeset
|
3707 |
]. |
8477
c962d56c1973
#linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents:
8280
diff
changeset
|
3708 |
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
|
3709 |
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
|
3710 |
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
|
3711 |
^ 'directory' |
2573 | 3712 |
]. |
8477
c962d56c1973
#linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents:
8280
diff
changeset
|
3713 |
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
|
3714 |
^ 'character device special file' |
3665 | 3715 |
]. |
8477
c962d56c1973
#linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents:
8280
diff
changeset
|
3716 |
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
|
3717 |
^ 'block device special file' |
3665 | 3718 |
]. |
8477
c962d56c1973
#linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents:
8280
diff
changeset
|
3719 |
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
|
3720 |
^ 'socket' |
3665 | 3721 |
]. |
8477
c962d56c1973
#linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents:
8280
diff
changeset
|
3722 |
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
|
3723 |
^ '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
|
3724 |
]. |
3665 | 3725 |
|
1602 | 3726 |
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
|
3727 |
info fileSize == 0 ifTrue:[^ 'empty']. |
1602 | 3728 |
|
17112 | 3729 |
"/ suffix := self suffix asLowercase. |
3730 |
"/ baseNm := self withoutSuffix baseName asLowercase. |
|
2922 | 3731 |
|
16755 | 3732 |
mime := self mimeTypeOfContents. |
3733 |
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
|
3734 |
"/ 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
|
3735 |
(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
|
3736 |
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
|
3737 |
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
|
3738 |
]. |
1602 | 3739 |
]. |
2906 | 3740 |
^ 'file' |
615 | 3741 |
|
3742 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3743 |
'Makefile' asFilename fileType |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3744 |
'.' asFilename fileType |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3745 |
'/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
|
3746 |
'/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
|
3747 |
'/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
|
3748 |
'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
|
3749 |
'bitmaps/SBrowser.xbm' asFilename fileType |
615 | 3750 |
" |
1601
1d57e1047323
avoid calling 'file' for symbolic links & directories
Claus Gittinger <cg@exept.de>
parents:
1540
diff
changeset
|
3751 |
|
3665 | 3752 |
"Modified: / 21.7.1998 / 11:25:56 / cg" |
615 | 3753 |
! |
3754 |
||
2836 | 3755 |
id |
16578 | 3756 |
"return the file's/directory's file-id (inode number)" |
2836 | 3757 |
|
2947 | 3758 |
^ OperatingSystem idOf:(self osNameForAccess) |
2836 | 3759 |
|
3760 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3761 |
Filename currentDirectory id |
2836 | 3762 |
" |
3763 |
||
3764 |
"Modified: 9.7.1996 / 10:19:27 / cg" |
|
3765 |
"Created: 5.8.1997 / 19:26:01 / cg" |
|
3766 |
! |
|
3767 |
||
615 | 3768 |
info |
16578 | 3769 |
"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
|
3770 |
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
|
3771 |
the returned object) is: |
7f6040320daf
changes for new return from OS>>infoOf:
Claus Gittinger <cg@exept.de>
parents:
1614
diff
changeset
|
3772 |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3773 |
type - a symbol giving the files fileType |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3774 |
mode - numeric access mode |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3775 |
uid - owners user id |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3776 |
gid - owners group id |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3777 |
size - files size |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3778 |
id - files number (i.e. inode number) |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3779 |
accessed - last access time (as osTime-stamp) |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3780 |
modified - last modification time (as osTime-stamp) |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3781 |
statusChangeTime - last staus change (as osTime-stamp) |
615 | 3782 |
|
1859
7f6040320daf
changes for new return from OS>>infoOf:
Claus Gittinger <cg@exept.de>
parents:
1614
diff
changeset
|
3783 |
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
|
3784 |
all of the information. |
7f6040320daf
changes for new return from OS>>infoOf:
Claus Gittinger <cg@exept.de>
parents:
1614
diff
changeset
|
3785 |
The minimum returned info (i.e. on all OS's) will consist of at least: |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3786 |
modified |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3787 |
size |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3788 |
type |
615 | 3789 |
|
1859
7f6040320daf
changes for new return from OS>>infoOf:
Claus Gittinger <cg@exept.de>
parents:
1614
diff
changeset
|
3790 |
Dont expect things like uid/gid/mode to be non-nil; write your application |
7f6040320daf
changes for new return from OS>>infoOf:
Claus Gittinger <cg@exept.de>
parents:
1614
diff
changeset
|
3791 |
to either handle nil values, |
615 | 3792 |
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
|
3793 |
(i.e. instead of: |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3794 |
someFilename type == #directory |
1859
7f6040320daf
changes for new return from OS>>infoOf:
Claus Gittinger <cg@exept.de>
parents:
1614
diff
changeset
|
3795 |
use |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3796 |
someFilename isDirectory |
615 | 3797 |
" |
3798 |
||
2947 | 3799 |
^ OperatingSystem infoOf:(self osNameForAccess) |
615 | 3800 |
|
3801 |
" |
|
3802 |
Filename currentDirectory info |
|
3768
4801b87c1cd7
care for non-existing info in #accessTime, #modTime and #fileSize
Claus Gittinger <cg@exept.de>
parents:
3763
diff
changeset
|
3803 |
'/dev/null' asFilename info |
615 | 3804 |
'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
|
3805 |
'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
|
3806 |
'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
|
3807 |
'../../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
|
3808 |
'.' asFilename info |
4801b87c1cd7
care for non-existing info in #accessTime, #modTime and #fileSize
Claus Gittinger <cg@exept.de>
parents:
3763
diff
changeset
|
3809 |
'..' asFilename info |
4801b87c1cd7
care for non-existing info in #accessTime, #modTime and #fileSize
Claus Gittinger <cg@exept.de>
parents:
3763
diff
changeset
|
3810 |
'..\..' asFilename info |
4801b87c1cd7
care for non-existing info in #accessTime, #modTime and #fileSize
Claus Gittinger <cg@exept.de>
parents:
3763
diff
changeset
|
3811 |
'..\..\..' asFilename info |
4801b87c1cd7
care for non-existing info in #accessTime, #modTime and #fileSize
Claus Gittinger <cg@exept.de>
parents:
3763
diff
changeset
|
3812 |
'..\..\..\..' asFilename info |
4801b87c1cd7
care for non-existing info in #accessTime, #modTime and #fileSize
Claus Gittinger <cg@exept.de>
parents:
3763
diff
changeset
|
3813 |
'c:\' asFilename info |
615 | 3814 |
" |
1859
7f6040320daf
changes for new return from OS>>infoOf:
Claus Gittinger <cg@exept.de>
parents:
1614
diff
changeset
|
3815 |
|
16272 | 3816 |
"Modified: / 17-08-1998 / 10:24:10 / cg" |
3817 |
"Modified (comment): / 21-03-2014 / 00:35:30 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
615 | 3818 |
! |
3819 |
||
3820 |
linkInfo |
|
16578 | 3821 |
"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
|
3822 |
instead of the link's target. |
615 | 3823 |
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
|
3824 |
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
|
3825 |
is returned |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3826 |
(while in this case, #info returns the info of the target file, |
615 | 3827 |
which is accessed via the symbolic link). |
3828 |
||
3829 |
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
|
3830 |
path -> the target files pathname |
615 | 3831 |
|
3832 |
See the comment in #info for more details." |
|
3833 |
||
2947 | 3834 |
^ OperatingSystem linkInfoOf:(self osNameForAccess) |
615 | 3835 |
|
3836 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3837 |
Filename currentDirectory linkInfo |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3838 |
'/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
|
3839 |
'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
|
3840 |
'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
|
3841 |
'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
|
3842 |
'../../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
|
3843 |
'/usr/tmp' asFilename linkInfo |
615 | 3844 |
" |
1862
e8f44f10f1ab
changes for new #infoOf: / #linkInfoOf: return
Claus Gittinger <cg@exept.de>
parents:
1859
diff
changeset
|
3845 |
|
e8f44f10f1ab
changes for new #infoOf: / #linkInfoOf: return
Claus Gittinger <cg@exept.de>
parents:
1859
diff
changeset
|
3846 |
"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
|
3847 |
! |
6b4c38b9090c
added #modificationTime & #accessTime (easier to use than #dates)
Claus Gittinger <cg@exept.de>
parents:
1523
diff
changeset
|
3848 |
|
6b4c38b9090c
added #modificationTime & #accessTime (easier to use than #dates)
Claus Gittinger <cg@exept.de>
parents:
1523
diff
changeset
|
3849 |
modificationTime |
16578 | 3850 |
"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
|
3851 |
|
3763
31d58d04ac15
care for nil-info in #modificationTime
Claus Gittinger <cg@exept.de>
parents:
3753
diff
changeset
|
3852 |
|i| |
31d58d04ac15
care for nil-info in #modificationTime
Claus Gittinger <cg@exept.de>
parents:
3753
diff
changeset
|
3853 |
|
31d58d04ac15
care for nil-info in #modificationTime
Claus Gittinger <cg@exept.de>
parents:
3753
diff
changeset
|
3854 |
(i := self info) isNil ifTrue:[^ nil]. "/ non-existing |
6793
0d3e3fd18a70
modified -> modificationTime
Claus Gittinger <cg@exept.de>
parents:
6776
diff
changeset
|
3855 |
^ i modificationTime |
1532
6b4c38b9090c
added #modificationTime & #accessTime (easier to use than #dates)
Claus Gittinger <cg@exept.de>
parents:
1523
diff
changeset
|
3856 |
|
6b4c38b9090c
added #modificationTime & #accessTime (easier to use than #dates)
Claus Gittinger <cg@exept.de>
parents:
1523
diff
changeset
|
3857 |
" |
6b4c38b9090c
added #modificationTime & #accessTime (easier to use than #dates)
Claus Gittinger <cg@exept.de>
parents:
1523
diff
changeset
|
3858 |
Filename currentDirectory modificationTime |
6b4c38b9090c
added #modificationTime & #accessTime (easier to use than #dates)
Claus Gittinger <cg@exept.de>
parents:
1523
diff
changeset
|
3859 |
" |
6b4c38b9090c
added #modificationTime & #accessTime (easier to use than #dates)
Claus Gittinger <cg@exept.de>
parents:
1523
diff
changeset
|
3860 |
|
3763
31d58d04ac15
care for nil-info in #modificationTime
Claus Gittinger <cg@exept.de>
parents:
3753
diff
changeset
|
3861 |
"Created: / 9.7.1996 / 10:18:59 / cg" |
31d58d04ac15
care for nil-info in #modificationTime
Claus Gittinger <cg@exept.de>
parents:
3753
diff
changeset
|
3862 |
"Modified: / 26.9.1997 / 13:05:39 / stefan" |
31d58d04ac15
care for nil-info in #modificationTime
Claus Gittinger <cg@exept.de>
parents:
3753
diff
changeset
|
3863 |
"Modified: / 14.8.1998 / 17:42:50 / cg" |
2836 | 3864 |
! |
3865 |
||
3866 |
type |
|
3867 |
"return the symbolic type of the file" |
|
3868 |
||
2947 | 3869 |
^ OperatingSystem typeOf:(self osNameForAccess) |
2836 | 3870 |
|
3871 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3872 |
Filename currentDirectory type |
2836 | 3873 |
" |
3874 |
||
3875 |
"Modified: 9.7.1996 / 10:19:27 / cg" |
|
3876 |
"Created: 5.8.1997 / 19:31:26 / cg" |
|
615 | 3877 |
! ! |
3878 |
||
3879 |
!Filename methodsFor:'file utilities'! |
|
3880 |
||
3881 |
edit |
|
3882 |
"start an editView on the file represented by the receiver" |
|
3883 |
||
3884 |
EditTextView openOn:self asString |
|
3885 |
||
3886 |
" |
|
3887 |
'smalltalk.rc' asFilename edit |
|
3888 |
" |
|
3889 |
! |
|
3890 |
||
3891 |
fileIn |
|
13424 | 3892 |
"load source code from the file" |
3893 |
||
3894 |
^ (ProgrammingLanguage forFile: self) fileIn: self |
|
3895 |
||
3896 |
"Modified: / 16-08-2009 / 13:27:36 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
542 | 3897 |
! ! |
3898 |
||
2 | 3899 |
!Filename methodsFor:'instance creation'! |
3900 |
||
10969
046b204c6ea2
New method: #/ as synonym of #construct:. Thanks to Jan Vrany, see Bug 823.
Stefan Vogel <sv@exept.de>
parents:
10902
diff
changeset
|
3901 |
/ subname |
046b204c6ea2
New method: #/ as synonym of #construct:. Thanks to Jan Vrany, see Bug 823.
Stefan Vogel <sv@exept.de>
parents:
10902
diff
changeset
|
3902 |
"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
|
3903 |
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
|
3904 |
(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
|
3905 |
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
|
3906 |
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
|
3907 |
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
|
3908 |
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
|
3909 |
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
|
3910 |
|
046b204c6ea2
New method: #/ as synonym of #construct:. Thanks to Jan Vrany, see Bug 823.
Stefan Vogel <sv@exept.de>
parents:
10902
diff
changeset
|
3911 |
^ 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
|
3912 |
|
046b204c6ea2
New method: #/ as synonym of #construct:. Thanks to Jan Vrany, see Bug 823.
Stefan Vogel <sv@exept.de>
parents:
10902
diff
changeset
|
3913 |
" |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3914 |
'/tmp' asFilename / 'foo' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3915 |
'/' 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
|
3916 |
'/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
|
3917 |
|
046b204c6ea2
New method: #/ as synonym of #construct:. Thanks to Jan Vrany, see Bug 823.
Stefan Vogel <sv@exept.de>
parents:
10902
diff
changeset
|
3918 |
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
|
3919 |
'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
|
3920 |
" |
046b204c6ea2
New method: #/ as synonym of #construct:. Thanks to Jan Vrany, see Bug 823.
Stefan Vogel <sv@exept.de>
parents:
10902
diff
changeset
|
3921 |
! |
046b204c6ea2
New method: #/ as synonym of #construct:. Thanks to Jan Vrany, see Bug 823.
Stefan Vogel <sv@exept.de>
parents:
10902
diff
changeset
|
3922 |
|
615 | 3923 |
construct:subname |
3924 |
"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
|
3925 |
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
|
3926 |
(i.e. for a file or a subdirectory in that directory). |
2922 | 3927 |
The argument may not specify an absolute path name. |
3928 |
Please do not use this to create filenames with suffixes, |
|
3929 |
since some systems require special naming conventions. |
|
3930 |
See also: #withSuffix: (which is different, but often needed)." |
|
615 | 3931 |
|
11784 | 3932 |
|constructedName| |
3933 |
||
3934 |
constructedName := self constructString:subname. |
|
15811 | 3935 |
^ self species named:constructedName. |
615 | 3936 |
|
3937 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3938 |
'/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
|
3939 |
'/' asFilename construct:'foo' |
615 | 3940 |
'/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
|
3941 |
'/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
|
3942 |
'/foo/bar' asFilename construct:'baz' asFilename |
2922 | 3943 |
|
3944 |
Bad example; works on UNIX, but may not on others: |
|
11784 | 3945 |
'foo/bar.baz' asFilename construct:'.suff' |
615 | 3946 |
" |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3947 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
3948 |
"Modified: 29.2.1996 / 20:55:06 / cg" |
2911 | 3949 |
! |
3950 |
||
2922 | 3951 |
constructDirectory:subname |
3952 |
"same as #construct: on most systems. |
|
3953 |
(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
|
3954 |
|
15811 | 3955 |
^ self species named:(self constructDirectoryString:subname) |
2922 | 3956 |
! |
3957 |
||
3958 |
constructDirectoryString:subName |
|
3959 |
"same as #constructString: on most systems. |
|
3960 |
(may allow different/relaxed name syntax of the argument on some systems)" |
|
3961 |
||
3962 |
^ self constructString:subName |
|
3963 |
! |
|
3964 |
||
3965 |
constructString:subName |
|
2911 | 3966 |
"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
|
3967 |
filename-string for an entry within this directory |
2922 | 3968 |
(i.e. for a file or a subdirectory in that directory). |
2960 | 3969 |
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
|
3970 |
The code below works for UNIX & MSDOS; |
2960 | 3971 |
other filename classes (i.e. VMS) may want to redefine this method." |
3972 |
||
3973 |
|sepString sub| |
|
3974 |
||
3975 |
sub := subName asString. |
|
15811 | 3976 |
sepString := self species separatorString. |
8243 | 3977 |
nameString size == 0 ifTrue:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3978 |
^ sub |
2911 | 3979 |
]. |
3677
51542c86ba2a
md's changes for msdos compatibility.
Claus Gittinger <cg@exept.de>
parents:
3666
diff
changeset
|
3980 |
(nameString endsWith:sepString) ifTrue:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3981 |
^ nameString , sub |
6247 | 3982 |
]. |
2960 | 3983 |
^ nameString , sepString , sub |
2911 | 3984 |
|
3985 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
3986 |
'/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
|
3987 |
'/' asFilename constructString:'foo' |
2911 | 3988 |
'/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
|
3989 |
'/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
|
3990 |
'' asFilename constructString:'baz' |
2911 | 3991 |
" |
3992 |
||
3677
51542c86ba2a
md's changes for msdos compatibility.
Claus Gittinger <cg@exept.de>
parents:
3666
diff
changeset
|
3993 |
"Modified: / 7.9.1995 / 10:15:22 / claus" |
51542c86ba2a
md's changes for msdos compatibility.
Claus Gittinger <cg@exept.de>
parents:
3666
diff
changeset
|
3994 |
"Created: / 9.9.1997 / 08:57:08 / cg" |
51542c86ba2a
md's changes for msdos compatibility.
Claus Gittinger <cg@exept.de>
parents:
3666
diff
changeset
|
3995 |
"Modified: / 20.1.1998 / 15:58:23 / md" |
51542c86ba2a
md's changes for msdos compatibility.
Claus Gittinger <cg@exept.de>
parents:
3666
diff
changeset
|
3996 |
"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
|
3997 |
! |
e1f1111afa12
Add #isImplicit to check for builtin dir names such as '.' and '..'.
Stefan Vogel <sv@exept.de>
parents:
2939
diff
changeset
|
3998 |
|
e1f1111afa12
Add #isImplicit to check for builtin dir names such as '.' and '..'.
Stefan Vogel <sv@exept.de>
parents:
2939
diff
changeset
|
3999 |
filenameFor:fileName |
6973 | 4000 |
"return a filename representing the argument, fileName |
4001 |
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
|
4002 |
|
e1f1111afa12
Add #isImplicit to check for builtin dir names such as '.' and '..'.
Stefan Vogel <sv@exept.de>
parents:
2939
diff
changeset
|
4003 |
|f| |
e1f1111afa12
Add #isImplicit to check for builtin dir names such as '.' and '..'.
Stefan Vogel <sv@exept.de>
parents:
2939
diff
changeset
|
4004 |
|
e1f1111afa12
Add #isImplicit to check for builtin dir names such as '.' and '..'.
Stefan Vogel <sv@exept.de>
parents:
2939
diff
changeset
|
4005 |
f := fileName asFilename. |
e1f1111afa12
Add #isImplicit to check for builtin dir names such as '.' and '..'.
Stefan Vogel <sv@exept.de>
parents:
2939
diff
changeset
|
4006 |
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
|
4007 |
^ (self construct:fileName) |
e1f1111afa12
Add #isImplicit to check for builtin dir names such as '.' and '..'.
Stefan Vogel <sv@exept.de>
parents:
2939
diff
changeset
|
4008 |
|
e1f1111afa12
Add #isImplicit to check for builtin dir names such as '.' and '..'.
Stefan Vogel <sv@exept.de>
parents:
2939
diff
changeset
|
4009 |
" |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4010 |
'/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
|
4011 |
'/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
|
4012 |
" |
e1f1111afa12
Add #isImplicit to check for builtin dir names such as '.' and '..'.
Stefan Vogel <sv@exept.de>
parents:
2939
diff
changeset
|
4013 |
|
e1f1111afa12
Add #isImplicit to check for builtin dir names such as '.' and '..'.
Stefan Vogel <sv@exept.de>
parents:
2939
diff
changeset
|
4014 |
"Created: 18.9.1997 / 14:34:14 / stefan" |
9263 | 4015 |
! |
4016 |
||
4017 |
secureConstruct:subname |
|
4018 |
"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
|
4019 |
filename for an entry within this directory |
9263 | 4020 |
(i.e. for a file or a subdirectory in that directory). |
4021 |
The argument may not specify an absolute path name. |
|
4022 |
Please do not use this to create filenames with suffixes, |
|
4023 |
since some systems require special naming conventions. |
|
4024 |
See also: #withSuffix: (which is different, but often needed). |
|
4025 |
||
4026 |
This method differs from #construct:, by not permitting subName |
|
4027 |
to navigate above (via ..) the current filename." |
|
4028 |
||
15811 | 4029 |
^ self species named:(self secureConstructString:subname) |
9263 | 4030 |
|
4031 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4032 |
'/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
|
4033 |
'/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
|
4034 |
'/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
|
4035 |
'/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
|
4036 |
'/' asFilename secureConstruct:'foo' |
9263 | 4037 |
'/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
|
4038 |
'/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
|
4039 |
'/foo/bar' asFilename secureConstruct:'baz' asFilename |
9263 | 4040 |
|
4041 |
Bad example; works on UNIX, but may not on others: |
|
4042 |
'foo/bar.baz' secureConstruct:'.suff' |
|
4043 |
" |
|
4044 |
||
4045 |
"Modified: 29.2.1996 / 20:55:06 / cg" |
|
4046 |
! |
|
4047 |
||
4048 |
secureConstructString:subName |
|
4049 |
"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
|
4050 |
filename-string for an entry within this directory |
9263 | 4051 |
(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
|
4052 |
|
9263 | 4053 |
This method differs from #constructString, by not permitting subName |
4054 |
to navigate above (via ..) the current filename. |
|
4055 |
||
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4056 |
The code below works for UNIX & MSDOS; |
9263 | 4057 |
other filename classes (i.e. VMS) may want to redefine this method." |
4058 |
||
4059 |
|sepString sub normalizedPath pathStream| |
|
4060 |
||
15811 | 4061 |
sepString := self species separatorString. |
9263 | 4062 |
sub := subName asString. |
4063 |
||
4064 |
sub := sub asCollectionOfSubstringsSeparatedByAll:sepString. |
|
4065 |
normalizedPath := OrderedCollection new:sub size. |
|
4066 |
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
|
4067 |
eachPathComponent = '..' ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4068 |
normalizedPath isEmpty ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4069 |
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
|
4070 |
]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4071 |
normalizedPath removeLast. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4072 |
] 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
|
4073 |
normalizedPath add:eachPathComponent. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4074 |
]] |
9263 | 4075 |
]. |
18272 | 4076 |
pathStream := CharacterWriteStream with:nameString. |
9263 | 4077 |
(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
|
4078 |
pathStream nextPutAll:sepString. |
9263 | 4079 |
]. |
4080 |
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
|
4081 |
pathStream nextPutAll:eachPathComponent. |
9263 | 4082 |
] separatedBy:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4083 |
pathStream nextPutAll:sepString. |
9263 | 4084 |
]. |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4085 |
|
9263 | 4086 |
^ pathStream contents. |
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 |
'/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
|
4090 |
'/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
|
4091 |
'/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
|
4092 |
'/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
|
4093 |
'/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
|
4094 |
'/' asFilename secureConstructString:'foo' |
9263 | 4095 |
'/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
|
4096 |
'/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
|
4097 |
'' asFilename secureConstructString:'baz' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4098 |
'' asFilename secureConstructString:'/baz' |
9263 | 4099 |
" |
2 | 4100 |
! ! |
4101 |
||
195 | 4102 |
!Filename methodsFor:'misc'! |
4103 |
||
4104 |
, aString |
|
4105 |
"this allows filenames to understand how names are concatenated. |
|
14072 | 4106 |
Returns a string consisting of the receiver's name, concatenated |
195 | 4107 |
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
|
4108 |
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
|
4109 |
See also: #withSuffix: which is new and better." |
195 | 4110 |
|
5866 | 4111 |
<resource:#obsolete> |
4112 |
||
2906 | 4113 |
self obsoleteMethodWarning:'use #construct:'. |
308 | 4114 |
^ (nameString , aString asString) |
195 | 4115 |
|
4116 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4117 |
'Makefile' asFilename , '.bak' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4118 |
('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
|
4119 |
'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
|
4120 |
'Makefile' asFilename construct:'.bak' |
195 | 4121 |
" |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4122 |
|
14072 | 4123 |
"Modified: / 07-09-1997 / 23:45:36 / cg" |
4124 |
"Modified (comment): / 01-04-2012 / 13:18:21 / cg" |
|
9263 | 4125 |
! |
4126 |
||
4127 |
canonicalize |
|
4128 |
"normalize a filename by removing all empty path components or dots, |
|
4129 |
and by resolving parent directory '..' references. |
|
4130 |
||
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4131 |
The code below works for UNIX & MSDOS; |
9263 | 4132 |
other filename classes (i.e. VMS) may want to redefine this method." |
4133 |
||
15811 | 4134 |
nameString := self species canonicalize:nameString. |
9263 | 4135 |
|
4136 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4137 |
'/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
|
4138 |
'/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
|
4139 |
'/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
|
4140 |
'..' asFilename canonicalize. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4141 |
'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
|
4142 |
'//bla/../fasel' asFilename canonicalize. |
9263 | 4143 |
" |
195 | 4144 |
! ! |
4145 |
||
14232 | 4146 |
!Filename methodsFor:'os shell'! |
4147 |
||
4148 |
openExplorer |
|
4149 |
"open a file-explorer on the directory represented by the receiver. |
|
4150 |
On non-windows systems, an error is raised" |
|
4151 |
||
4152 |
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
|
4153 |
self warn:'sorry - this operation is only available under windows'. |
14232 | 4154 |
]. |
4155 |
||
4156 |
OperatingSystem |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4157 |
openApplicationForDocument:self pathName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4158 |
operation:#explore. |
14232 | 4159 |
|
4160 |
"Created: / 21-07-2012 / 12:28:18 / cg" |
|
14804 | 4161 |
! |
4162 |
||
4163 |
openFinder |
|
4164 |
"open a finder on the directory represented by the receiver. |
|
4165 |
On non-osx systems, an error is raised" |
|
4166 |
||
4167 |
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
|
4168 |
self warn:'sorry - this operation is only available under osx'. |
14804 | 4169 |
]. |
4170 |
||
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4171 |
OperatingSystem executeCommand:'open "',self pathName,'"' |
14804 | 4172 |
! |
4173 |
||
4174 |
openTerminal |
|
16545 | 4175 |
"open a terminal window on the directory represented by the receiver; |
4176 |
on osx, a terminal app is opened, |
|
4177 |
on windows a cmd.exe window, |
|
4178 |
on unix, an xterm is opened." |
|
4179 |
||
4180 |
OperatingSystem isOSXlike ifTrue:[ |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4181 |
"/ I dont know yet how to tell the terminal to |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4182 |
"/ go to a particular directory. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4183 |
"/ therefore, use the built in terminal |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4184 |
VT100TerminalView openShellIn:self pathName. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4185 |
^ self. |
16545 | 4186 |
]. |
14804 | 4187 |
|
14941 | 4188 |
[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4189 |
|cmd| |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4190 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4191 |
OperatingSystem isOSXlike ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4192 |
cmd := '/Applications/Utilities/Terminal.app/Contents/MacOS/Terminal ' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4193 |
] ifFalse:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4194 |
OperatingSystem isMSWINDOWSlike ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4195 |
cmd := 'c:\windows\System32\cmd.exe' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4196 |
] ifFalse:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4197 |
"/ VT100TerminalView openShellIn:self pathName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4198 |
cmd := 'xterm' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4199 |
] |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4200 |
]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4201 |
OperatingSystem |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4202 |
executeCommand:cmd |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4203 |
inDirectory:self pathName. |
14941 | 4204 |
] fork |
14232 | 4205 |
! ! |
4206 |
||
615 | 4207 |
!Filename methodsFor:'printing & storing'! |
174 | 4208 |
|
615 | 4209 |
printOn:aStream |
4392 | 4210 |
"append a user printed representation of the receiver to aStream. |
4211 |
The format is suitable for a human - not meant to be read back." |
|
174 | 4212 |
|
2906 | 4213 |
aStream nextPutAll:(self class name). |
4214 |
aStream nextPutAll:'('''. |
|
615 | 4215 |
nameString printOn:aStream. |
4216 |
aStream nextPutAll:''')' |
|
2906 | 4217 |
|
4218 |
"Modified: 7.9.1997 / 23:46:20 / cg" |
|
1 | 4219 |
! |
4220 |
||
615 | 4221 |
storeOn:aStream |
4222 |
"append a printed representation of the receiver to aStream, |
|
4223 |
which allows reconstructing it via readFrom:" |
|
328 | 4224 |
|
615 | 4225 |
aStream nextPut:$(. |
4226 |
nameString storeOn:aStream. |
|
4227 |
aStream nextPutAll:' asFilename)' |
|
1 | 4228 |
! ! |
4229 |
||
7258 | 4230 |
!Filename methodsFor:'private-accessing'! |
1 | 4231 |
|
6227 | 4232 |
getName |
4233 |
"get the raw filename" |
|
4234 |
||
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4235 |
^ nameString |
6227 | 4236 |
! |
4237 |
||
68 | 4238 |
setName:aString |
38 | 4239 |
"set the filename" |
4240 |
||
14220
2a3457b016be
Fix the '~/dir/name' resolution fow windows
Stefan Vogel <sv@exept.de>
parents:
14218
diff
changeset
|
4241 |
nameString := aString. |
3666 | 4242 |
|
4243 |
"Modified: / 21.7.1998 / 10:44:18 / cg" |
|
1 | 4244 |
! ! |
4245 |
||
2 | 4246 |
!Filename methodsFor:'queries'! |
4247 |
||
68 | 4248 |
exists |
92 | 4249 |
"return true, if such a file exists." |
68 | 4250 |
|
2947 | 4251 |
^ OperatingSystem isValidPath:(self osNameForAccess) |
68 | 4252 |
|
85 | 4253 |
" |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4254 |
'/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
|
4255 |
'/tmp' asFilename exists |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4256 |
'Makefile' asFilename exists |
85 | 4257 |
" |
77 | 4258 |
! |
4259 |
||
5928 | 4260 |
filenamesMatching:aPattern |
4261 |
"VW compatibility" |
|
4262 |
||
15811 | 4263 |
^ (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
|
4264 |
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
|
4265 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4266 |
" |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4267 |
'/etc' asFilename filenamesMatching:'a*;c*' |
5928 | 4268 |
" |
4269 |
||
4270 |
"Created: / 15.4.1997 / 15:40:02 / cg" |
|
4271 |
"Modified: / 3.8.1998 / 21:22:15 / cg" |
|
4272 |
! |
|
4273 |
||
2548
b6182b559ea2
made filesMatching ST-80 compatible.
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4274 |
filesMatching:aPattern |
2550 | 4275 |
"given the receiver, representing a directory; |
4276 |
return a collection of files matching a pattern. |
|
4277 |
The pattern may be a simple matchPattern, or a set of |
|
4278 |
multiple patterns separated by semicolons." |
|
4279 |
||
15737 | 4280 |
|matchers caseSensitive| |
2550 | 4281 |
|
4282 |
matchers := aPattern asCollectionOfSubstringsSeparatedBy:$;. |
|
15811 | 4283 |
caseSensitive := self species isCaseSensitive. |
2550 | 4284 |
^ self directoryContents |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4285 |
select:[:name | |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4286 |
(matchers detect:[:p | p match:name caseSensitive:caseSensitive] ifNone:0) ~~ 0 |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4287 |
] |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4288 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4289 |
" |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4290 |
'/etc' asFilename filesMatching:'a*;c*' |
2548
b6182b559ea2
made filesMatching ST-80 compatible.
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4291 |
" |
b6182b559ea2
made filesMatching ST-80 compatible.
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4292 |
|
3719
ce88c6f64d37
ignore case for PC-filenames when searching for matches.
Claus Gittinger <cg@exept.de>
parents:
3713
diff
changeset
|
4293 |
"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
|
4294 |
"Modified: / 3.8.1998 / 21:22:15 / cg" |
2550 | 4295 |
! |
4296 |
||
4297 |
filesMatchingWithoutDotDirs:aPattern |
|
4298 |
"given the receiver, representing a directory; |
|
4299 |
return a collection of files matching a pattern. |
|
4300 |
Exclude '.' and '..' from the returned list. |
|
4301 |
The pattern may be a simple matchPattern, or a set of |
|
4302 |
multiple patterns separated by semicolons." |
|
4303 |
||
15737 | 4304 |
|matchers caseSensitive| |
2550 | 4305 |
|
4306 |
matchers := aPattern asCollectionOfSubstringsSeparatedBy:$;. |
|
15811 | 4307 |
caseSensitive := self species isCaseSensitive. |
3719
ce88c6f64d37
ignore case for PC-filenames when searching for matches.
Claus Gittinger <cg@exept.de>
parents:
3713
diff
changeset
|
4308 |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4309 |
^ self directoryContents |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4310 |
select:[:name | |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4311 |
name ~= '.' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4312 |
and:[name ~= '..' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4313 |
and:[(matchers detect:[:p | p match:name caseSensitive:caseSensitive] ifNone:0) ~~ 0]] |
2550 | 4314 |
] |
4315 |
||
4316 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4317 |
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
|
4318 |
'/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
|
4319 |
'../../libbasic' asFilename filesMatching:'[A-D]*.st' |
2550 | 4320 |
" |
4321 |
||
3719
ce88c6f64d37
ignore case for PC-filenames when searching for matches.
Claus Gittinger <cg@exept.de>
parents:
3713
diff
changeset
|
4322 |
"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
|
4323 |
"Modified: / 3.8.1998 / 21:22:30 / cg" |
2548
b6182b559ea2
made filesMatching ST-80 compatible.
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4324 |
! |
b6182b559ea2
made filesMatching ST-80 compatible.
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4325 |
|
9206 | 4326 |
fullAlternativePathName |
4327 |
^ nameString |
|
4328 |
! |
|
4329 |
||
615 | 4330 |
isExecutable |
4331 |
"return true, if such a file exists and is executable (by Unix's definition). |
|
4332 |
For directories, true is returned if the directory can be entered. |
|
4333 |
See isExecutableProgram for a related check." |
|
4334 |
||
2947 | 4335 |
^ OperatingSystem isExecutable:(self osNameForAccess) |
615 | 4336 |
|
4337 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4338 |
'/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
|
4339 |
'/tmp' asFilename isExecutable |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4340 |
'Makefile' asFilename isExecutable |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4341 |
'/bin/ls' asFilename isExecutable |
356 | 4342 |
" |
4343 |
! |
|
4344 |
||
615 | 4345 |
isExecutableProgram |
4346 |
"return true, if such a file exists and is an executable program. |
|
4347 |
(i.e. for directories, false is returned.)" |
|
356 | 4348 |
|
2922 | 4349 |
|osName| |
4350 |
||
2947 | 4351 |
osName := self osNameForAccess. |
2922 | 4352 |
^ (OperatingSystem isExecutable:osName) |
4353 |
and:[(OperatingSystem isDirectory:osName) not] |
|
356 | 4354 |
|
4355 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4356 |
'/tmp' asFilename isExecutable |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4357 |
'/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
|
4358 |
'/tmp' asFilename isExecutableProgram |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4359 |
'/bin/ls' asFilename isExecutableProgram |
615 | 4360 |
" |
4361 |
! |
|
4362 |
||
2922 | 4363 |
isHidden |
4364 |
"return true, if the receiver represents a hidden file. |
|
4365 |
The definitions of hidden files depends on the OS used; |
|
4366 |
on UNIX, a name starting with a period is considered hidden; |
|
16578 | 4367 |
on MSDOS, the file's hidden attribute is also used. |
2922 | 4368 |
VMS has no concept of hidden files." |
4369 |
||
4370 |
^ false |
|
4371 |
! |
|
4372 |
||
6773
26415b61ad09
isMountPoint & isParentDirectoryOf & allParentDirsDo:
penk
parents:
6771
diff
changeset
|
4373 |
isMountPoint:aPathName |
26415b61ad09
isMountPoint & isParentDirectoryOf & allParentDirsDo:
penk
parents:
6771
diff
changeset
|
4374 |
"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
|
4375 |
Warning: |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4376 |
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
|
4377 |
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
|
4378 |
Aka: do not ask: '../../' asFilename isMountPoint; |
6773
26415b61ad09
isMountPoint & isParentDirectoryOf & allParentDirsDo:
penk
parents:
6771
diff
changeset
|
4379 |
" |
26415b61ad09
isMountPoint & isParentDirectoryOf & allParentDirsDo:
penk
parents:
6771
diff
changeset
|
4380 |
|
26415b61ad09
isMountPoint & isParentDirectoryOf & allParentDirsDo:
penk
parents:
6771
diff
changeset
|
4381 |
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
|
4382 |
self error:'this query must be done on an absolute pathname'. |
6773
26415b61ad09
isMountPoint & isParentDirectoryOf & allParentDirsDo:
penk
parents:
6771
diff
changeset
|
4383 |
]. |
26415b61ad09
isMountPoint & isParentDirectoryOf & allParentDirsDo:
penk
parents:
6771
diff
changeset
|
4384 |
^ OperatingSystem isMountPoint:(self name) |
26415b61ad09
isMountPoint & isParentDirectoryOf & allParentDirsDo:
penk
parents:
6771
diff
changeset
|
4385 |
! |
26415b61ad09
isMountPoint & isParentDirectoryOf & allParentDirsDo:
penk
parents:
6771
diff
changeset
|
4386 |
|
615 | 4387 |
isReadable |
4388 |
"return true, if such a file exists and is readable." |
|
4389 |
||
2947 | 4390 |
^ OperatingSystem isReadable:(self osNameForFile) |
615 | 4391 |
|
4392 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4393 |
'/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
|
4394 |
'/tmp' asFilename isReadable |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4395 |
'Makefile' asFilename isReadable |
328 | 4396 |
" |
4397 |
! |
|
4398 |
||
11529 | 4399 |
isSharedLibrary |
4400 |
"return true, if such a file exists and is a shared library." |
|
4401 |
||
4402 |
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
|
4403 |
"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
|
4404 |
^ false. |
11529 | 4405 |
]. |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4406 |
^ (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
|
4407 |
and:[self isRegularFile]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4408 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4409 |
" |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4410 |
'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
|
4411 |
'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
|
4412 |
'/tmp' asFilename isSharedLibrary |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4413 |
'/tmp.dll' asFilename isSharedLibrary |
11529 | 4414 |
" |
4415 |
! |
|
4416 |
||
615 | 4417 |
isWritable |
4418 |
"return true, if such a file exists and is writable." |
|
4419 |
||
2947 | 4420 |
^ OperatingSystem isWritable:(self osNameForFile) |
615 | 4421 |
|
4422 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4423 |
'/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
|
4424 |
'/tmp' asFilename isWritable |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4425 |
'Makefile' asFilename isWritable |
328 | 4426 |
" |
174 | 4427 |
! |
4428 |
||
15574 | 4429 |
isWritableDirectory |
4430 |
"return true, if such a directory exists and is writable. |
|
4431 |
Don't believe #isWritable, since on an NFS mounted filesystem |
|
4432 |
with UID mapping and attribute cache enabled, there may be false negatives." |
|
4433 |
||
4434 |
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
|
4435 |
^ false. |
15574 | 4436 |
]. |
4437 |
||
4438 |
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
|
4439 |
"/ 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
|
4440 |
"/ attribute cache enabled, |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4441 |
"/ 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
|
4442 |
"/ check again... |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4443 |
[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4444 |
|tempFile| |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4445 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4446 |
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
|
4447 |
tempFile close. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4448 |
tempFile fileName remove. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4449 |
] 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
|
4450 |
^ false. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4451 |
]. |
15574 | 4452 |
]. |
4453 |
^ true. |
|
4454 |
||
4455 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4456 |
'/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
|
4457 |
'/tmp' asFilename isWritableDirectory |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4458 |
'/etc' asFilename isWritableDirectory |
15574 | 4459 |
'Makefile' asFilename isWritableDirectory |
4460 |
'/net/exeptn/home2/office' asFilename isWritable |
|
4461 |
'/net/exeptn/home2/office' asFilename isWritableDirectory |
|
4462 |
" |
|
4463 |
! |
|
4464 |
||
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4465 |
separator |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4466 |
"return the directory-separator character" |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4467 |
|
15811 | 4468 |
^ self species separator |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4469 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4470 |
"Modified: 29.2.1996 / 20:52:01 / cg" |
8947 | 4471 |
! |
4472 |
||
11781
6488fd6cc498
Make AutoDeletedFilename work like Filename
Stefan Vogel <sv@exept.de>
parents:
11763
diff
changeset
|
4473 |
species |
15811 | 4474 |
"create only new instances of the concrete OS specific class. |
4475 |
Redefined in AutoDeletedFilename, to not create AutoDeleted instances |
|
4476 |
per default (from directories etc.)" |
|
4477 |
||
4478 |
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
|
4479 |
^ ConcreteClass. |
15811 | 4480 |
] 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 class. |
15811 | 4482 |
]. |
11781
6488fd6cc498
Make AutoDeletedFilename work like Filename
Stefan Vogel <sv@exept.de>
parents:
11763
diff
changeset
|
4483 |
! |
6488fd6cc498
Make AutoDeletedFilename work like Filename
Stefan Vogel <sv@exept.de>
parents:
11763
diff
changeset
|
4484 |
|
8947 | 4485 |
withSpecialExpansions |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4486 |
"return a new filename, expanding any OS specific macros. |
15811 | 4487 |
Here, a ~/ prefix is expanded to the users home dir (as in bash)" |
8947 | 4488 |
|
4489 |
|newName| |
|
4490 |
||
15811 | 4491 |
newName := self species nameWithSpecialExpansions:nameString. |
4492 |
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
|
4493 |
^ self. |
8947 | 4494 |
]. |
15811 | 4495 |
^ self species named:newName. |
8947 | 4496 |
|
4497 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4498 |
'~' asFilename withSpecialExpansions |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4499 |
'~/Desktop' asFilename withSpecialExpansions |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4500 |
'~stefan' asFilename withSpecialExpansions |
15811 | 4501 |
'~stefan/Desktop' asFilename withSpecialExpansions |
8947 | 4502 |
" |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4503 |
! ! |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4504 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4505 |
!Filename methodsFor:'queries-contents'! |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4506 |
|
7291 | 4507 |
mimeTypeFromName |
16578 | 4508 |
"return the mimeType as guessed from the file's name/and or extension. |
7291 | 4509 |
This could be less accurate than mimeTypeOfContents, but avoids |
4510 |
reading the file (is therefore much faster). |
|
4511 |
Also it works with non-existing files. |
|
4512 |
Returns nil for directories and other non-regular files." |
|
4513 |
||
17112 | 4514 |
|mimeTypes| |
4515 |
||
16755 | 4516 |
"/ kludge to avoid making libview a prereq. of libbasic |
17112 | 4517 |
(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
|
4518 |
^ mimeTypes mimeTypeForFilename:(self name) |
16755 | 4519 |
]. |
4520 |
^ nil |
|
7291 | 4521 |
|
4522 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4523 |
'Makefile' asFilename mimeTypeFromName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4524 |
'.' asFilename mimeTypeFromName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4525 |
'/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
|
4526 |
'/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
|
4527 |
'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
|
4528 |
'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
|
4529 |
'../../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
|
4530 |
'/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
|
4531 |
'/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
|
4532 |
'/x.gz' asFilename mimeTypeFromName |
7291 | 4533 |
" |
4534 |
! |
|
4535 |
||
5011 | 4536 |
mimeTypeOfContents |
4537 |
"this tries to guess the mime type of contents of |
|
4538 |
the file. Returns nil, if the file is unreadable, not a plain file |
|
4539 |
or the contents is unknown. |
|
4540 |
This is done using some heuristics, and may need some improvement" |
|
4541 |
||
17111 | 4542 |
|type buffer s size mimeTypes| |
5011 | 4543 |
|
7088
cc3233554827
Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents:
7075
diff
changeset
|
4544 |
type := self type. |
11406
af2c2118e164
refactored - mimetypeofdata now where it belongs to
Claus Gittinger <cg@exept.de>
parents:
11397
diff
changeset
|
4545 |
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
|
4546 |
type == #directory ifTrue:[ ^ nil ]. |
11406
af2c2118e164
refactored - mimetypeofdata now where it belongs to
Claus Gittinger <cg@exept.de>
parents:
11397
diff
changeset
|
4547 |
type == #characterSpecial ifTrue:[ ^ nil ]. |
af2c2118e164
refactored - mimetypeofdata now where it belongs to
Claus Gittinger <cg@exept.de>
parents:
11397
diff
changeset
|
4548 |
type == #blockSpecial ifTrue:[ ^ nil ]. |
af2c2118e164
refactored - mimetypeofdata now where it belongs to
Claus Gittinger <cg@exept.de>
parents:
11397
diff
changeset
|
4549 |
type == #socket ifTrue:[ ^ nil ]. |
5011 | 4550 |
self fileSize == 0 ifTrue:[^ nil]. |
4551 |
||
7088
cc3233554827
Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents:
7075
diff
changeset
|
4552 |
s := self readStreamOrNil. |
cc3233554827
Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents:
7075
diff
changeset
|
4553 |
s isNil ifTrue:[^ nil]. |
cc3233554827
Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents:
7075
diff
changeset
|
4554 |
|
5011 | 4555 |
"/ read some data from the file ... |
7685
535a69a7cd69
String new -> uninitializedNew: / basicNew:
Claus Gittinger <cg@exept.de>
parents:
7680
diff
changeset
|
4556 |
buffer := String new:2048. |
5011 | 4557 |
|
6943
910f4b17c342
care for unreadable contents in mimeTypeOfContents
Claus Gittinger <cg@exept.de>
parents:
6908
diff
changeset
|
4558 |
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
|
4559 |
size := 0. |
6943
910f4b17c342
care for unreadable contents in mimeTypeOfContents
Claus Gittinger <cg@exept.de>
parents:
6908
diff
changeset
|
4560 |
] do:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4561 |
size := s nextBytes:buffer size into:buffer. |
6943
910f4b17c342
care for unreadable contents in mimeTypeOfContents
Claus Gittinger <cg@exept.de>
parents:
6908
diff
changeset
|
4562 |
]. |
5011 | 4563 |
s close. |
11406
af2c2118e164
refactored - mimetypeofdata now where it belongs to
Claus Gittinger <cg@exept.de>
parents:
11397
diff
changeset
|
4564 |
|
16755 | 4565 |
"/ kludge to avoid making libview a prereq. of libbasic |
17111 | 4566 |
(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
|
4567 |
^ mimeTypes mimeTypeOfData:buffer suffix:self suffix. |
16755 | 4568 |
]. |
4569 |
^ nil |
|
5011 | 4570 |
|
4571 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4572 |
'Makefile' asFilename mimeTypeOfContents |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4573 |
'.' asFilename mimeTypeOfContents |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4574 |
'/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
|
4575 |
'/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
|
4576 |
'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
|
4577 |
'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
|
4578 |
'../../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
|
4579 |
'/bläh' asFilename mimeTypeOfContents |
10153 | 4580 |
'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
|
4581 |
'G:\A\A01.TOP' asFilename mimeTypeOfContents |
10153 | 4582 |
" |
4583 |
||
4584 |
"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
|
4585 |
! ! |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4586 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4587 |
!Filename methodsFor:'queries-path & name'! |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4588 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4589 |
baseName |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4590 |
"return my baseName as a string. |
2012 | 4591 |
- thats the file/directory name without leading parent-dirs. |
2922 | 4592 |
(i.e. '/usr/lib/st/file' asFilename baseName -> 'file' |
4593 |
and '/usr/lib' asFilename baseName -> lib). |
|
7075 | 4594 |
This method does not check if the path is valid. |
4595 |
The code here should work for Unix and MSDOS, but needs to be redefined |
|
4596 |
for VMS (and maybe others as well). |
|
2911 | 4597 |
See also: #pathName, #directoryName and #directoryPathName. |
4598 |
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
|
4599 |
|
2922 | 4600 |
|len index sep endIdx| |
4601 |
||
4602 |
sep := self separator. |
|
4603 |
len := nameString size. |
|
4604 |
((len == 1) and:[(nameString at:1) == sep]) ifTrue:[ |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4605 |
^ nameString |
2922 | 4606 |
]. |
4607 |
||
4608 |
endIdx := len. |
|
4609 |
len > 1 ifTrue:[ |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4610 |
(nameString at:len) == sep ifTrue:[endIdx := endIdx - 1]. |
2922 | 4611 |
]. |
4612 |
index := nameString lastIndexOf:sep startingAt:len-1. |
|
4613 |
^ 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
|
4614 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4615 |
" |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4616 |
'/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
|
4617 |
'/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
|
4618 |
'.' asFilename baseName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4619 |
'..' asFilename baseName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4620 |
'../..' asFilename baseName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4621 |
'../../libbasic' asFilename baseName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4622 |
'../../libpr' asFilename baseName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4623 |
'../../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
|
4624 |
'/' asFilename baseName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4625 |
'\' asFilename baseName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4626 |
'c:\' asFilename baseName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4627 |
'\\idefix' asFilename baseName |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4628 |
" |
2012 | 4629 |
|
3851 | 4630 |
"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
|
4631 |
! |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4632 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4633 |
directory |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4634 |
"return the directory name part of the file/directory as a new filename. |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4635 |
- thats a filename for the directory where the file/dir represented by |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4636 |
the receiver is contained in. |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4637 |
(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
|
4638 |
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
|
4639 |
|
15811 | 4640 |
^ self species named:(self directoryName) |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4641 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4642 |
" |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4643 |
'/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
|
4644 |
'/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
|
4645 |
'/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
|
4646 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4647 |
'.' asFilename directory |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4648 |
'..' asFilename directory |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4649 |
'../..' asFilename directory |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4650 |
" |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4651 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4652 |
"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
|
4653 |
! |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4654 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4655 |
directoryName |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4656 |
"return the directory name part of the file/directory as a string. |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4657 |
- thats the name of the directory where the file/dir represented by |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4658 |
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
|
4659 |
This method does not check if the path is valid. |
2922 | 4660 |
|
4661 |
(i.e. '/usr/lib/st/file' asFilename directoryName -> '/usr/lib/st' |
|
4662 |
and '/usr/lib' asFilename directoryName -> /usr'). |
|
4663 |
||
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4664 |
(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
|
4665 |
a string instead of a Filename instance). |
2922 | 4666 |
|
2012 | 4667 |
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
|
4668 |
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
|
4669 |
|
16389 | 4670 |
|index sep sepString p rest parentDirectoryString| |
2922 | 4671 |
|
4672 |
sep := self separator. |
|
4673 |
sepString := sep asString. |
|
4674 |
(nameString = sepString) ifTrue:[ |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4675 |
"/ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4676 |
"/ the trivial '/' case |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4677 |
"/ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4678 |
^ sepString |
2922 | 4679 |
]. |
4680 |
||
4681 |
"/ |
|
3893 | 4682 |
"/ strip off multiple trailing slashes |
2922 | 4683 |
"/ |
4684 |
p := nameString. |
|
16389 | 4685 |
[p endsWith:sep] whileTrue:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4686 |
(p = sepString) ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4687 |
^ sepString |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4688 |
]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4689 |
p := p copyButLast:1 |
2922 | 4690 |
]. |
4691 |
||
16389 | 4692 |
parentDirectoryString := self class parentDirectoryName. |
4693 |
||
3886
e6efeb877eda
fixed #directory & #directoryName for
Claus Gittinger <cg@exept.de>
parents:
3876
diff
changeset
|
4694 |
"/ strip off trailing components |
3888
a528db31e5c0
had to change #directoryName again - it did not work.
Claus Gittinger <cg@exept.de>
parents:
3886
diff
changeset
|
4695 |
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
|
4696 |
index == 0 ifTrue:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4697 |
"/ no separator found |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4698 |
p = '.' ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4699 |
^ parentDirectoryString |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4700 |
]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4701 |
p = '..' ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4702 |
^ parentDirectoryString, sepString, parentDirectoryString |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4703 |
]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4704 |
^ '.' |
2922 | 4705 |
]. |
3888
a528db31e5c0
had to change #directoryName again - it did not work.
Claus Gittinger <cg@exept.de>
parents:
3886
diff
changeset
|
4706 |
rest := p copyFrom:(index+1). |
7342
4e9ff418113f
fixed for directory name ending with '/..'
Claus Gittinger <cg@exept.de>
parents:
7332
diff
changeset
|
4707 |
(rest = '.') ifTrue:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4708 |
^ p copyTo:index-1. |
7342
4e9ff418113f
fixed for directory name ending with '/..'
Claus Gittinger <cg@exept.de>
parents:
7332
diff
changeset
|
4709 |
]. |
16389 | 4710 |
(rest = parentDirectoryString) ifTrue:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4711 |
^ (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
|
4712 |
]. |
3893 | 4713 |
index == 1 ifTrue:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4714 |
^ sepString |
3893 | 4715 |
]. |
3888
a528db31e5c0
had to change #directoryName again - it did not work.
Claus Gittinger <cg@exept.de>
parents:
3886
diff
changeset
|
4716 |
^ p copyTo:(index - 1) |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4717 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4718 |
" |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4719 |
'/home' asFilename directoryName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4720 |
'/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
|
4721 |
'/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
|
4722 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4723 |
'/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
|
4724 |
'bitmaps' asFilename directoryName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4725 |
'bitmaps' asFilename directoryPathName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4726 |
'.' asFilename directoryName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4727 |
'.' asFilename directoryPathName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4728 |
'..' asFilename directoryName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4729 |
'..' asFilename directoryPathName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4730 |
'../..' asFilename directoryName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4731 |
'../..' asFilename directoryPathName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4732 |
'/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
|
4733 |
'/foo/bar/baz/.' asFilename directoryName |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4734 |
" |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4735 |
|
3886
e6efeb877eda
fixed #directory & #directoryName for
Claus Gittinger <cg@exept.de>
parents:
3876
diff
changeset
|
4736 |
"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
|
4737 |
"Modified: / 21.10.1998 / 22:52:25 / cg" |
3893 | 4738 |
"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
|
4739 |
! |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4740 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4741 |
directoryPathName |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4742 |
"return the full directory pathname part of the file/directory as a string. |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4743 |
- thats the full pathname of the directory where the file/dir represented by |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4744 |
the receiver is contained in. |
2012 | 4745 |
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
|
4746 |
|
15811 | 4747 |
^ (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
|
4748 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4749 |
" |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4750 |
'/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
|
4751 |
'/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
|
4752 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4753 |
'.' asFilename directoryPathName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4754 |
'.' asFilename directoryName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4755 |
'.' asFilename directory |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4756 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4757 |
'..' asFilename directoryPathName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4758 |
'..' asFilename directoryName |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4759 |
'..' asFilename directory |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4760 |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4761 |
'../..' asFilename directoryPathName |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4762 |
" |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4763 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4764 |
"Modified: 7.9.1995 / 10:42:13 / claus" |
2012 | 4765 |
"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
|
4766 |
! |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4767 |
|
14567 | 4768 |
encodedNameString |
4769 |
"answer the name as passed to OS system calls" |
|
4770 |
||
4771 |
^ OperatingSystem encodePath:nameString |
|
4772 |
! |
|
4773 |
||
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4774 |
filenameCompletion |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4775 |
"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
|
4776 |
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
|
4777 |
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
|
4778 |
it returns a collection of matching filename objects, |
6556
367bc84f51fc
filename completion better if an empty basename is shown
Claus Gittinger <cg@exept.de>
parents:
6529
diff
changeset
|
4779 |
and changes the receivers 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
|
4780 |
match. |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4781 |
If none matches, the returned collection is empty and the recevier is unchanged. |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4782 |
If there is only one match, the size of the returned collection is exactly 1, |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4783 |
containing the fully expanded filename and the receivers name is changed to it." |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4784 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4785 |
^ self filenameCompletionIn:nil |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4786 |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4787 |
" |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4788 |
'mak' asFilename filenameCompletion |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4789 |
'Make' asFilename filenameCompletion |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4790 |
'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
|
4791 |
'/u' asFilename filenameCompletion |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4792 |
'../../libpr' asFilename inspect filenameCompletion |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4793 |
" |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4794 |
|
1517 | 4795 |
"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
|
4796 |
! |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4797 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4798 |
filenameCompletionIn:aDirectory |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4799 |
"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
|
4800 |
|
6556
367bc84f51fc
filename completion better if an empty basename is shown
Claus Gittinger <cg@exept.de>
parents:
6529
diff
changeset
|
4801 |
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
|
4802 |
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
|
4803 |
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
|
4804 |
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
|
4805 |
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
|
4806 |
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
|
4807 |
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
|
4808 |
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
|
4809 |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4810 |
|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
|
4811 |
sepString parentString prefix nMatch nm caseless lcBaseName| |
3666 | 4812 |
|
15811 | 4813 |
mySpecies := self species. |
4814 |
||
4815 |
caseless := mySpecies isCaseSensitive not. |
|
6556
367bc84f51fc
filename completion better if an empty basename is shown
Claus Gittinger <cg@exept.de>
parents:
6529
diff
changeset
|
4816 |
matching := OrderedCollection new. |
367bc84f51fc
filename completion better if an empty basename is shown
Claus Gittinger <cg@exept.de>
parents:
6529
diff
changeset
|
4817 |
|
15811 | 4818 |
nm := mySpecies nameWithSpecialExpansions:nameString. |
4819 |
nm := mySpecies canonicalize:nm. |
|
4820 |
||
4821 |
sepString := mySpecies separatorString. |
|
3666 | 4822 |
(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
|
4823 |
"/ two exceptions here: |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4824 |
"/ 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
|
4825 |
"/ 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
|
4826 |
self isDirectory ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4827 |
|first longest| |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4828 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4829 |
first := nil. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4830 |
OpenError catch:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4831 |
self directoryContentsDo:[:fileName | |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4832 |
((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
|
4833 |
matching add:fileName. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4834 |
first isNil ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4835 |
first := longest := fileName. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4836 |
] ifFalse:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4837 |
"/ 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
|
4838 |
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
|
4839 |
longest isEmpty ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4840 |
^ #() |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4841 |
]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4842 |
] |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4843 |
] |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4844 |
]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4845 |
]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4846 |
longest notNil ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4847 |
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
|
4848 |
^ matching |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4849 |
]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4850 |
]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4851 |
^ #() |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4852 |
]. |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4853 |
|
15811 | 4854 |
parentString := mySpecies parentDirectoryName. |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4855 |
baseName := self baseName. |
3666 | 4856 |
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
|
4857 |
prefix := self directoryName. |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4858 |
]. |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4859 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4860 |
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
|
4861 |
dir := self directory |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4862 |
] ifFalse:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4863 |
aDirectory isNil ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4864 |
dir := self directory |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4865 |
] ifFalse:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4866 |
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
|
4867 |
] |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4868 |
]. |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4869 |
|
3774
e2a75c79c625
ignore case in fileNameCompletion, on systems where case is ignored
Claus Gittinger <cg@exept.de>
parents:
3768
diff
changeset
|
4870 |
caseless ifTrue:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4871 |
lcBaseName := baseName asLowercase |
3774
e2a75c79c625
ignore case in fileNameCompletion, on systems where case is ignored
Claus Gittinger <cg@exept.de>
parents:
3768
diff
changeset
|
4872 |
]. |
e2a75c79c625
ignore case in fileNameCompletion, on systems where case is ignored
Claus Gittinger <cg@exept.de>
parents:
3768
diff
changeset
|
4873 |
|
2978
e466e478fa43
Handle errors in #filenameCompletion:
Stefan Vogel <sv@exept.de>
parents:
2977
diff
changeset
|
4874 |
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
|
4875 |
^ #(). |
2978
e466e478fa43
Handle errors in #filenameCompletion:
Stefan Vogel <sv@exept.de>
parents:
2977
diff
changeset
|
4876 |
] do:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4877 |
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
|
4878 |
((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
|
4879 |
((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
|
4880 |
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
|
4881 |
matching add:fileName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4882 |
] |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4883 |
] |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4884 |
]. |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4885 |
]. |
6556
367bc84f51fc
filename completion better if an empty basename is shown
Claus Gittinger <cg@exept.de>
parents:
6529
diff
changeset
|
4886 |
|
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4887 |
(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
|
4888 |
" |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4889 |
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
|
4890 |
" |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4891 |
matchLen := baseName size. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4892 |
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
|
4893 |
try := baseName. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4894 |
allMatching := false |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4895 |
] ifFalse:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4896 |
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
|
4897 |
allMatching := true. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4898 |
]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4899 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4900 |
[allMatching] whileTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4901 |
matching do:[:aName | |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4902 |
((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
|
4903 |
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
|
4904 |
allMatching := false |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4905 |
] |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4906 |
]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4907 |
allMatching ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4908 |
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
|
4909 |
matchLen := matchLen + 1. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4910 |
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
|
4911 |
] ifFalse:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4912 |
allMatching := false |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4913 |
] |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4914 |
] ifFalse:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4915 |
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
|
4916 |
] |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4917 |
]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4918 |
" |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4919 |
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
|
4920 |
" |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4921 |
nameString := nm := try |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4922 |
]. |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4923 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4924 |
" |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4925 |
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
|
4926 |
" |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4927 |
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
|
4928 |
(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
|
4929 |
"/ 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
|
4930 |
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
|
4931 |
]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4932 |
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
|
4933 |
nMatch == 1 ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4934 |
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
|
4935 |
] ifFalse:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4936 |
nMatch > 1 ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4937 |
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
|
4938 |
] |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4939 |
] |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4940 |
] ifFalse:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4941 |
nMatch == 1 ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4942 |
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
|
4943 |
] |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4944 |
]. |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4945 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4946 |
" |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4947 |
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
|
4948 |
(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
|
4949 |
" |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4950 |
^ matching |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4951 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4952 |
" trivial cases: |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4953 |
|
11341
22494c109161
fixed filename completion for root directories (added another sep-char)
Claus Gittinger <cg@exept.de>
parents:
11192
diff
changeset
|
4954 |
'../' asFilename filenameCompletion -> empty |
22494c109161
fixed filename completion for root directories (added another sep-char)
Claus Gittinger <cg@exept.de>
parents:
11192
diff
changeset
|
4955 |
'/' asFilename filenameCompletion -> empty |
22494c109161
fixed filename completion for root directories (added another sep-char)
Claus Gittinger <cg@exept.de>
parents:
11192
diff
changeset
|
4956 |
'/usr/' asFilename filenameCompletion -> empty |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4957 |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4958 |
'mak' asFilename filenameCompletion |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4959 |
'Make' asFilename filenameCompletion |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4960 |
'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
|
4961 |
'/u' asFilename filenameCompletion |
7088
cc3233554827
Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents:
7075
diff
changeset
|
4962 |
'../../libpr' asFilename filenameCompletion |
cc3233554827
Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents:
7075
diff
changeset
|
4963 |
'/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
|
4964 |
|
22494c109161
fixed filename completion for root directories (added another sep-char)
Claus Gittinger <cg@exept.de>
parents:
11192
diff
changeset
|
4965 |
'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
|
4966 |
'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
|
4967 |
'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
|
4968 |
'c:\' asFilename filenameCompletion -> empty |
22494c109161
fixed filename completion for root directories (added another sep-char)
Claus Gittinger <cg@exept.de>
parents:
11192
diff
changeset
|
4969 |
'c:' asFilename filenameCompletion -> empty |
22494c109161
fixed filename completion for root directories (added another sep-char)
Claus Gittinger <cg@exept.de>
parents:
11192
diff
changeset
|
4970 |
'\' asFilename filenameCompletion -> empty |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4971 |
" |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4972 |
|
10793
0475c364e80a
care for bad (non-filename) arg in fileNameCompletion:
Claus Gittinger <cg@exept.de>
parents:
10780
diff
changeset
|
4973 |
"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
|
4974 |
"Modified: / 17-11-2007 / 14:31:08 / cg" |
2903 | 4975 |
! |
4976 |
||
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4977 |
head |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4978 |
"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
|
4979 |
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
|
4980 |
(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
|
4981 |
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
|
4982 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4983 |
^ self directoryName |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4984 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4985 |
" |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4986 |
Filename currentDirectory head |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4987 |
'Makefile' asFilename head |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
4988 |
'/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
|
4989 |
" |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4990 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4991 |
"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
|
4992 |
! |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
4993 |
|
7120 | 4994 |
isAbsolute |
4995 |
"return true, if the receiver represents an absolute pathname |
|
4996 |
(in contrast to one relative to the current directory)." |
|
4997 |
||
15811 | 4998 |
((nameString startsWith:self species separator) or:[nameString startsWith:'~']) ifTrue:[^ true]. |
7120 | 4999 |
^ self isVolumeAbsolute |
5000 |
||
5001 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5002 |
'/foo/bar' asFilename isAbsolute |
14220
2a3457b016be
Fix the '~/dir/name' resolution fow windows
Stefan Vogel <sv@exept.de>
parents:
14218
diff
changeset
|
5003 |
'~/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
|
5004 |
'..' asFilename isAbsolute |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5005 |
'..' asAbsoluteFilename isAbsolute |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5006 |
'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
|
5007 |
'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
|
5008 |
'SBrowser.st' asFilename isRelative |
7120 | 5009 |
" |
5010 |
! |
|
5011 |
||
5012 |
isExplicitRelative |
|
5013 |
"return true, if this name is an explicit relative name |
|
5014 |
(i.e. starts with './' or '../', to avoid path-prepending)" |
|
5015 |
||
5016 |
^ false |
|
5017 |
! |
|
5018 |
||
5019 |
isImplicit |
|
5020 |
"return true, if the receiver represents a builtin file. |
|
5021 |
The definitions of builtin files depends on the OS used; |
|
5022 |
on UNIX, '.' and '..' are builtin names." |
|
5023 |
||
5024 |
^ false |
|
5025 |
||
5026 |
"Created: 18.9.1997 / 18:04:51 / stefan" |
|
5027 |
! |
|
5028 |
||
6773
26415b61ad09
isMountPoint & isParentDirectoryOf & allParentDirsDo:
penk
parents:
6771
diff
changeset
|
5029 |
isParentDirectoryOf:aFilenameOrString |
16389 | 5030 |
"Answer true, if myself is a parent directory of aFilenameOrString. |
5031 |
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
|
5032 |
not exist and relative and absolute path names are mixed |
18686 | 5033 |
('/' asFilename isParentDirectoryOf:'../noExistent' -> false) |
16389 | 5034 |
|
5035 |
Warning: maybe symbolic links must be resolved which could lead to automounting" |
|
5036 |
||
5037 |
|filenameArg otherNames myNames myName| |
|
6773
26415b61ad09
isMountPoint & isParentDirectoryOf & allParentDirsDo:
penk
parents:
6771
diff
changeset
|
5038 |
|
7236
2b8b8680f5b9
isParentDirectoryOf - fix for directories
Claus Gittinger <cg@exept.de>
parents:
7134
diff
changeset
|
5039 |
filenameArg := aFilenameOrString asFilename. |
16389 | 5040 |
|
5041 |
"first do a simple comparison" |
|
5042 |
otherNames := self class canonicalizedNameComponents:filenameArg name. |
|
5043 |
myNames := self class canonicalizedNameComponents:self name. |
|
5044 |
((otherNames startsWith:myNames) and:[myNames first ~= self class parentDirectoryName]) ifTrue:[ |
|
18686 | 5045 |
^ otherNames ~= myNames |
7236
2b8b8680f5b9
isParentDirectoryOf - fix for directories
Claus Gittinger <cg@exept.de>
parents:
7134
diff
changeset
|
5046 |
]. |
6773
26415b61ad09
isMountPoint & isParentDirectoryOf & allParentDirsDo:
penk
parents:
6771
diff
changeset
|
5047 |
|
16389 | 5048 |
"fall back - try it again with ~ substitution and symbolic links resolved" |
5049 |
otherNames := self class canonicalizedNameComponents:filenameArg pathName. |
|
5050 |
myNames := self class canonicalizedNameComponents:self pathName. |
|
5051 |
(otherNames startsWith:myNames) ifTrue:[ |
|
18686 | 5052 |
^ otherNames ~= myNames |
6773
26415b61ad09
isMountPoint & isParentDirectoryOf & allParentDirsDo:
penk
parents:
6771
diff
changeset
|
5053 |
]. |
26415b61ad09
isMountPoint & isParentDirectoryOf & allParentDirsDo:
penk
parents:
6771
diff
changeset
|
5054 |
|
16389 | 5055 |
myName := self class nameFromComponents:myNames. |
6773
26415b61ad09
isMountPoint & isParentDirectoryOf & allParentDirsDo:
penk
parents:
6771
diff
changeset
|
5056 |
filenameArg allParentDirectoriesDo:[:parent | |
18686 | 5057 |
parent pathName = myName ifTrue:[^ true]. |
6773
26415b61ad09
isMountPoint & isParentDirectoryOf & allParentDirsDo:
penk
parents:
6771
diff
changeset
|
5058 |
]. |
26415b61ad09
isMountPoint & isParentDirectoryOf & allParentDirsDo:
penk
parents:
6771
diff
changeset
|
5059 |
^ false. |
26415b61ad09
isMountPoint & isParentDirectoryOf & allParentDirsDo:
penk
parents:
6771
diff
changeset
|
5060 |
|
26415b61ad09
isMountPoint & isParentDirectoryOf & allParentDirsDo:
penk
parents:
6771
diff
changeset
|
5061 |
" |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5062 |
'/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
|
5063 |
'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
|
5064 |
'/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
|
5065 |
'/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
|
5066 |
'/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
|
5067 |
'/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
|
5068 |
'~' 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
|
5069 |
'~' asFilename isParentDirectoryOf:'.' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5070 |
'~' asFilename isParentDirectoryOf:'..' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5071 |
'~' asFilename isParentDirectoryOf:'../smalltalk' |
18686 | 5072 |
'../..' asFilename isParentDirectoryOf:'../nonExistent' |
5073 |
'..' asFilename isParentDirectoryOf:'../../nonExistent' |
|
5074 |
'/' 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
|
5075 |
'/' 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
|
5076 |
" |
6773
26415b61ad09
isMountPoint & isParentDirectoryOf & allParentDirsDo:
penk
parents:
6771
diff
changeset
|
5077 |
! |
26415b61ad09
isMountPoint & isParentDirectoryOf & allParentDirsDo:
penk
parents:
6771
diff
changeset
|
5078 |
|
7120 | 5079 |
isRelative |
5080 |
"return true, if this name is interpreted relative to some |
|
5081 |
directory (opposite of absolute)" |
|
5082 |
||
5083 |
^ self isAbsolute not |
|
5084 |
||
5085 |
" |
|
5086 |
'./foo/bar' asFilename isRelative |
|
5087 |
'../../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
|
5088 |
'/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
|
5089 |
'bar' asFilename isRelative |
7120 | 5090 |
" |
5091 |
||
5092 |
"Modified: 16.1.1997 / 01:19:14 / cg" |
|
5093 |
! |
|
5094 |
||
5095 |
isRootDirectory |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5096 |
"return true, if I represent the root directory |
7120 | 5097 |
(i.e. I have no parentDir)" |
5098 |
||
5099 |
"/ mhmh - should we use: |
|
5100 |
"/ |
|
5101 |
"/ parentDir := self construct:'..'. |
|
5102 |
"/ (parentDir exists |
|
5103 |
"/ and:[parentDir isDirectory |
|
5104 |
"/ and:[parentDir id ~= self id]]) ifTrue:[ |
|
5105 |
"/ ^ false |
|
5106 |
"/ ]. |
|
5107 |
"/ ^ true |
|
5108 |
"/ |
|
5109 |
||
5110 |
^ self pathName = Filename rootDirectory pathName |
|
5111 |
||
5112 |
"Modified: 23.10.1997 / 00:38:35 / cg" |
|
5113 |
! |
|
5114 |
||
5115 |
isVolumeAbsolute |
|
5116 |
"return true, if the receiver represents an absolute pathname |
|
5117 |
on some disk volume (MSDOS only)" |
|
5118 |
||
5119 |
^ false |
|
5120 |
||
5121 |
"Modified: 7.9.1997 / 23:54:33 / cg" |
|
5122 |
! |
|
5123 |
||
2987
87a7ad1f4519
Simplify #accessTime and #modificationTime
Stefan Vogel <sv@exept.de>
parents:
2982
diff
changeset
|
5124 |
localPathName |
87a7ad1f4519
Simplify #accessTime and #modificationTime
Stefan Vogel <sv@exept.de>
parents:
2982
diff
changeset
|
5125 |
"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
|
5126 |
but without any volume information. |
87a7ad1f4519
Simplify #accessTime and #modificationTime
Stefan Vogel <sv@exept.de>
parents:
2982
diff
changeset
|
5127 |
Only makes a difference on MSDOS & VMS systems." |
87a7ad1f4519
Simplify #accessTime and #modificationTime
Stefan Vogel <sv@exept.de>
parents:
2982
diff
changeset
|
5128 |
|
87a7ad1f4519
Simplify #accessTime and #modificationTime
Stefan Vogel <sv@exept.de>
parents:
2982
diff
changeset
|
5129 |
^ self pathName |
87a7ad1f4519
Simplify #accessTime and #modificationTime
Stefan Vogel <sv@exept.de>
parents:
2982
diff
changeset
|
5130 |
! |
87a7ad1f4519
Simplify #accessTime and #modificationTime
Stefan Vogel <sv@exept.de>
parents:
2982
diff
changeset
|
5131 |
|
615 | 5132 |
name |
5133 |
"return the name of the file represented by the receiver as a string. |
|
883 | 5134 |
This may or may not be a relative name (i.e. include ..'s). |
615 | 5135 |
See also: pathName" |
174 | 5136 |
|
6773
26415b61ad09
isMountPoint & isParentDirectoryOf & allParentDirsDo:
penk
parents:
6771
diff
changeset
|
5137 |
"/ self isAbsolute ifTrue:[^ self pathName]. |
615 | 5138 |
^ nameString |
174 | 5139 |
|
5140 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5141 |
'/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
|
5142 |
'/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
|
5143 |
'.' asFilename name |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5144 |
'.' asFilename pathName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5145 |
'../..' asFilename name |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5146 |
'../..' asFilename pathName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5147 |
'bitmaps' asFilename name |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5148 |
'bitmaps' asFilename pathName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5149 |
'/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
|
5150 |
'/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
|
5151 |
'source/..' asFilename name |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5152 |
'source/..' asFilename pathName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5153 |
'/tmp/..' asFilename name |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5154 |
'/tmp/..' asFilename pathName |
92 | 5155 |
" |
538
b9337c6c55bb
added recursiveRemove; remove now also removes directories
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
5156 |
|
883 | 5157 |
"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
|
5158 |
! |
b9337c6c55bb
added recursiveRemove; remove now also removes directories
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
5159 |
|
7308 | 5160 |
nameString |
5161 |
"raw access to nameString - req'd for xml-store/reload" |
|
5162 |
||
5163 |
^ nameString |
|
5164 |
! |
|
5165 |
||
5166 |
nameString:aString |
|
5167 |
"raw access to nameString - req'd for xml-store/reload" |
|
5168 |
||
5169 |
nameString := aString |
|
5170 |
! |
|
5171 |
||
615 | 5172 |
pathName |
5173 |
"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
|
5174 |
as a string. This will not include ..'s. |
1317 | 5175 |
If the path represented by the receiver does NOT represent a valid path, |
5176 |
no compression will be done (for now; this may change). |
|
5177 |
See also: name" |
|
538
b9337c6c55bb
added recursiveRemove; remove now also removes directories
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
5178 |
|
b9337c6c55bb
added recursiveRemove; remove now also removes directories
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
5179 |
|
1317 | 5180 |
"/ sep := self class separator. |
5181 |
"/ (nameString startsWith:sep) ifTrue:[ |
|
5182 |
"/ parentName := self class parentDirectoryName. |
|
5183 |
"/ (nameString findString:parentName) == 0 ifTrue:[ |
|
5184 |
"/ ^ nameString |
|
5185 |
"/ ] |
|
5186 |
"/ ]. |
|
15811 | 5187 |
^ OperatingSystem pathNameOf:(self species nameWithSpecialExpansions:nameString). |
2 | 5188 |
|
92 | 5189 |
" |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5190 |
'/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
|
5191 |
'.' asFilename pathName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5192 |
'../..' asFilename pathName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5193 |
'../..' asFilename name |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5194 |
'/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
|
5195 |
'/././usr' asFilename pathName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5196 |
'~/..' asFilename pathName |
92 | 5197 |
" |
159 | 5198 |
|
1317 | 5199 |
"Modified: 27.4.1996 / 18:19:52 / cg" |
174 | 5200 |
! |
5201 |
||
11658 | 5202 |
physicalFilename |
5203 |
"return the fileName representing the physical file as represented by the receiver, |
|
5204 |
If the receiver represents a symbolic link, thats the fileName of the |
|
5205 |
final target. Otherwise, its the receivers pathName itself. |
|
5206 |
If any file along the symbolic path does not exist (i.e. is a broken link), |
|
5207 |
nil is returned." |
|
5208 |
||
5209 |
|pathOrNil| |
|
5210 |
||
5211 |
pathOrNil := self physicalPathName. |
|
5212 |
pathOrNil isNil ifTrue:[ |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5213 |
^ nil |
11658 | 5214 |
]. |
5215 |
^ pathOrNil asFilename |
|
5216 |
||
5217 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5218 |
'/foo/bar' asFilename physicalFileName |
11658 | 5219 |
" |
5220 |
! |
|
5221 |
||
2013
5053effe0156
commentary; added #physicalPathName
Claus Gittinger <cg@exept.de>
parents:
2012
diff
changeset
|
5222 |
physicalPathName |
5053effe0156
commentary; added #physicalPathName
Claus Gittinger <cg@exept.de>
parents:
2012
diff
changeset
|
5223 |
"return the full pathname of the physical file represented by the receiver, |
5053effe0156
commentary; added #physicalPathName
Claus Gittinger <cg@exept.de>
parents:
2012
diff
changeset
|
5224 |
If the receiver represents a symbolic link, thats the fileName of the |
5053effe0156
commentary; added #physicalPathName
Claus Gittinger <cg@exept.de>
parents:
2012
diff
changeset
|
5225 |
final target. Otherwise, its the receivers pathName itself. |
5053effe0156
commentary; added #physicalPathName
Claus Gittinger <cg@exept.de>
parents:
2012
diff
changeset
|
5226 |
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
|
5227 |
nil is returned." |
5053effe0156
commentary; added #physicalPathName
Claus Gittinger <cg@exept.de>
parents:
2012
diff
changeset
|
5228 |
|
8477
c962d56c1973
#linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents:
8280
diff
changeset
|
5229 |
|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
|
5230 |
|
c962d56c1973
#linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents:
8280
diff
changeset
|
5231 |
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
|
5232 |
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
|
5233 |
" I do not exist" |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5234 |
^ nil. |
2013
5053effe0156
commentary; added #physicalPathName
Claus Gittinger <cg@exept.de>
parents:
2012
diff
changeset
|
5235 |
]. |
8477
c962d56c1973
#linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents:
8280
diff
changeset
|
5236 |
info isSymbolicLink ifFalse:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5237 |
^ 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
|
5238 |
]. |
c962d56c1973
#linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents:
8280
diff
changeset
|
5239 |
|
2013
5053effe0156
commentary; added #physicalPathName
Claus Gittinger <cg@exept.de>
parents:
2012
diff
changeset
|
5240 |
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
|
5241 |
[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5242 |
path := info path. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5243 |
path isNil ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5244 |
"/ cannot happen |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5245 |
^ nil |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5246 |
]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5247 |
path asFilename isAbsolute ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5248 |
t := path asFilename |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5249 |
] ifFalse:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5250 |
t := (self species named:t directoryName) construct:path. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5251 |
]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5252 |
info := t linkInfo. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5253 |
info isNil ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5254 |
"t does not exist" |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5255 |
^ nil |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5256 |
]. |
8477
c962d56c1973
#linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents:
8280
diff
changeset
|
5257 |
] 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
|
5258 |
|
2013
5053effe0156
commentary; added #physicalPathName
Claus Gittinger <cg@exept.de>
parents:
2012
diff
changeset
|
5259 |
^ t pathName |
5053effe0156
commentary; added #physicalPathName
Claus Gittinger <cg@exept.de>
parents:
2012
diff
changeset
|
5260 |
|
5053effe0156
commentary; added #physicalPathName
Claus Gittinger <cg@exept.de>
parents:
2012
diff
changeset
|
5261 |
" |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5262 |
'/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
|
5263 |
'.' asFilename physicalPathName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5264 |
'../..' asFilename physicalPathName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5265 |
'/usr/tmp' asFilename physicalPathName |
2013
5053effe0156
commentary; added #physicalPathName
Claus Gittinger <cg@exept.de>
parents:
2012
diff
changeset
|
5266 |
" |
5053effe0156
commentary; added #physicalPathName
Claus Gittinger <cg@exept.de>
parents:
2012
diff
changeset
|
5267 |
|
5053effe0156
commentary; added #physicalPathName
Claus Gittinger <cg@exept.de>
parents:
2012
diff
changeset
|
5268 |
"Modified: 21.12.1996 / 15:29:50 / cg" |
5053effe0156
commentary; added #physicalPathName
Claus Gittinger <cg@exept.de>
parents:
2012
diff
changeset
|
5269 |
! |
5053effe0156
commentary; added #physicalPathName
Claus Gittinger <cg@exept.de>
parents:
2012
diff
changeset
|
5270 |
|
615 | 5271 |
tail |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5272 |
"the file's name without directory prefix as a string. |
615 | 5273 |
An alias for baseName, for ST-80 compatiblity." |
174 | 5274 |
|
615 | 5275 |
^ self baseName |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5276 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5277 |
" |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5278 |
Filename currentDirectory tail |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5279 |
'Makefile' asFilename tail |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5280 |
'/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
|
5281 |
" |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5282 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5283 |
"Modified: 29.2.1996 / 20:19:50 / cg" |
2629 | 5284 |
! |
5285 |
||
7307
9cae11d1fea1
new tail: to get the last n path components (as String)
Stefan Vogel <sv@exept.de>
parents:
7291
diff
changeset
|
5286 |
tail:nComponents |
9cae11d1fea1
new tail: to get the last n path components (as String)
Stefan Vogel <sv@exept.de>
parents:
7291
diff
changeset
|
5287 |
"return the last n components of myself. |
9cae11d1fea1
new tail: to get the last n path components (as String)
Stefan Vogel <sv@exept.de>
parents:
7291
diff
changeset
|
5288 |
- thats the file/directory name without leading parent-dirs. |
9cae11d1fea1
new tail: to get the last n path components (as String)
Stefan Vogel <sv@exept.de>
parents:
7291
diff
changeset
|
5289 |
(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
|
5290 |
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
|
5291 |
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
|
5292 |
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
|
5293 |
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
|
5294 |
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
|
5295 |
|
9cae11d1fea1
new tail: to get the last n path components (as String)
Stefan Vogel <sv@exept.de>
parents:
7291
diff
changeset
|
5296 |
|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
|
5297 |
|
15811 | 5298 |
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
|
5299 |
components := self components. |
9cae11d1fea1
new tail: to get the last n path components (as String)
Stefan Vogel <sv@exept.de>
parents:
7291
diff
changeset
|
5300 |
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
|
5301 |
start < 1 ifTrue:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5302 |
start := 1. |
7307
9cae11d1fea1
new tail: to get the last n path components (as String)
Stefan Vogel <sv@exept.de>
parents:
7291
diff
changeset
|
5303 |
]. |
9cae11d1fea1
new tail: to get the last n path components (as String)
Stefan Vogel <sv@exept.de>
parents:
7291
diff
changeset
|
5304 |
start = 1 ifTrue:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5305 |
tail := '' |
7307
9cae11d1fea1
new tail: to get the last n path components (as String)
Stefan Vogel <sv@exept.de>
parents:
7291
diff
changeset
|
5306 |
] ifFalse:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5307 |
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
|
5308 |
]. |
9cae11d1fea1
new tail: to get the last n path components (as String)
Stefan Vogel <sv@exept.de>
parents:
7291
diff
changeset
|
5309 |
start+1 to:components size do:[:i| |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5310 |
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
|
5311 |
]. |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5312 |
^ tail. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5313 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5314 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5315 |
" |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5316 |
'/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
|
5317 |
'/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
|
5318 |
'/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
|
5319 |
'/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
|
5320 |
'.' asFilename tail:3 |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5321 |
'..' asFilename tail:3 |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5322 |
'../..' asFilename tail:2 |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5323 |
'../../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
|
5324 |
'../../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
|
5325 |
'../../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
|
5326 |
'../../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
|
5327 |
'/' asFilename tail:2 |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5328 |
'\' asFilename tail:2 |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5329 |
'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
|
5330 |
'\\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
|
5331 |
" |
9cae11d1fea1
new tail: to get the last n path components (as String)
Stefan Vogel <sv@exept.de>
parents:
7291
diff
changeset
|
5332 |
! |
9cae11d1fea1
new tail: to get the last n path components (as String)
Stefan Vogel <sv@exept.de>
parents:
7291
diff
changeset
|
5333 |
|
2629 | 5334 |
volume |
5335 |
"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
|
5336 |
This is only used with MSDOS and VMS filenames |
2906 | 5337 |
- by default (and on unix), an empty string is returned" |
5338 |
||
2629 | 5339 |
^ '' |
2906 | 5340 |
|
5341 |
"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
|
5342 |
! ! |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5343 |
|
7120 | 5344 |
!Filename methodsFor:'queries-type'! |
5345 |
||
5346 |
isDirectory |
|
5347 |
"return true, if the receiver represents an existing, |
|
5348 |
readable directories pathname." |
|
5349 |
||
5350 |
^ OperatingSystem isDirectory:(self osNameForAccess) |
|
5351 |
||
5352 |
" |
|
5353 |
'/foo/bar' asFilename isDirectory |
|
5354 |
'/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
|
5355 |
'Makefile' asFilename isDirectory |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5356 |
'c:\' asFilename isDirectory |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5357 |
'd:\' asFilename isDirectory |
7120 | 5358 |
" |
5359 |
||
5360 |
"Modified: / 21.9.1998 / 15:53:10 / cg" |
|
5361 |
! |
|
5362 |
||
5363 |
isNonEmptyDirectory |
|
5364 |
"return true, if the receiver represents an existing, |
|
5365 |
readable directories pathname, and the directory is not empty." |
|
5366 |
||
8280
0caa2f092e45
avoid expensive full-blocks (which return)
Claus Gittinger <cg@exept.de>
parents:
8243
diff
changeset
|
5367 |
FileStream openErrorSignal |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5368 |
handle:[:ex| ] |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5369 |
do:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5370 |
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
|
5371 |
]. |
7120 | 5372 |
^ false. |
5373 |
||
5374 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5375 |
'/foo/bar' asFilename isNonEmptyDirectory |
7120 | 5376 |
'/tmp' asFilename isNonEmptyDirectory |
5377 |
'/tmp/empty' asFilename makeDirectory; isNonEmptyDirectory. |
|
5378 |
'/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
|
5379 |
'Makefile' asFilename isNonEmptyDirectory |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5380 |
'c:\' asFilename isNonEmptyDirectory |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5381 |
'd:\' asFilename isNonEmptyDirectory |
7120 | 5382 |
" |
5383 |
||
5384 |
"Modified: / 21.9.1998 / 15:53:10 / cg" |
|
5385 |
! |
|
5386 |
||
8836 | 5387 |
isRegularFile |
5388 |
"return true, if the receiver represents a plain, regular file" |
|
5389 |
||
5390 |
^ self type == #regular |
|
5391 |
||
5392 |
" |
|
5393 |
'/foo/bar' asFilename isRegularFile |
|
5394 |
'/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
|
5395 |
'Makefile' asFilename isRegularFile |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5396 |
'c:\' asFilename isRegularFile |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5397 |
'd:\' asFilename isRegularFile |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5398 |
'/dev/null' asFilename isRegularFile |
8836 | 5399 |
" |
5400 |
! |
|
5401 |
||
7120 | 5402 |
isSpecialFile |
5403 |
"return true, if the receiver represents a socket, named pipe, fifo |
|
5404 |
or device special file (i.e. anything non regular and non-directory)" |
|
5405 |
||
5406 |
|t| |
|
5407 |
||
5408 |
t := self type. |
|
5409 |
^ (t ~= #directory and:[t ~~ #regular and:[t ~~ #symbolicLink]]) |
|
5410 |
||
5411 |
" |
|
5412 |
'/foo/bar' asFilename isSpecialFile |
|
5413 |
'/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
|
5414 |
'Makefile' asFilename isSpecialFile |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5415 |
'c:\' asFilename isSpecialFile |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5416 |
'd:\' asFilename isSpecialFile |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5417 |
'/dev/null' asFilename isSpecialFile |
7120 | 5418 |
" |
5419 |
! |
|
5420 |
||
5421 |
isSymbolicLink |
|
5422 |
"return true, if the file represented by the receiver is a symbolic |
|
5423 |
link. Notice that not all OS's support symbolic links; those that do |
|
5424 |
not will always return false." |
|
5425 |
||
5426 |
^ OperatingSystem isSymbolicLink:(self osNameForFile) |
|
5427 |
||
5428 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5429 |
'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
|
5430 |
'Makefile' asFilename isSymbolicLink |
7120 | 5431 |
" |
5432 |
! ! |
|
5433 |
||
6529 | 5434 |
!Filename methodsFor:'reading-directories'! |
5435 |
||
5436 |
directoryContents |
|
5437 |
"return the contents of the directory as a collection of strings. |
|
5438 |
This excludes any entries for '.' or '..'. |
|
5439 |
Returns nil for non-existing directories; however, this behavior |
|
5440 |
may be changed in the near future, to raise an exception instead. |
|
5441 |
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
|
5442 |
Notice: |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5443 |
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
|
5444 |
see also #directoryContentsAsFilenames, which returns fileName instances." |
6529 | 5445 |
|
12910 | 5446 |
|directoryStream contents| |
5447 |
||
5448 |
contents := OrderedCollection new. |
|
5449 |
directoryStream := DirectoryStream directoryNamed:(self osNameForDirectoryContents). |
|
5450 |
directoryStream isNil ifTrue:[^ nil]. |
|
5451 |
||
5452 |
[ |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5453 |
[directoryStream atEnd] whileFalse:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5454 |
|entry| |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5455 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5456 |
entry := directoryStream nextLine. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5457 |
(entry notNil and:[entry ~= '.' and:[entry ~= '..']]) ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5458 |
contents add:entry |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5459 |
]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5460 |
]. |
6529 | 5461 |
] ensure:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5462 |
directoryStream close |
6529 | 5463 |
]. |
5464 |
||
5465 |
^ contents. |
|
5466 |
||
5467 |
" |
|
5468 |
'.' asFilename directoryContents |
|
5469 |
'/XXXdoesNotExist' asFilename directoryContents |
|
5470 |
" |
|
5471 |
||
5472 |
"Modified: / 18.9.1997 / 18:42:23 / stefan" |
|
5473 |
"Modified: / 3.8.1998 / 21:36:21 / cg" |
|
5474 |
! |
|
5475 |
||
5476 |
directoryContentsAsFilenames |
|
5477 |
"return the contents of the directory as a collection of filenames. |
|
5478 |
This excludes any entries for '.' or '..'. |
|
5479 |
Returns nil for non-existing directories; however, this behavior |
|
5480 |
may be changed in the near future, to raise an exception instead. |
|
5481 |
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
|
5482 |
Notice: |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5483 |
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
|
5484 |
see also #directoryContents, which returns strings." |
6529 | 5485 |
|
5486 |
|names| |
|
5487 |
||
5488 |
names := self directoryContents. |
|
5489 |
names isNil ifTrue:[^ nil]. |
|
12910 | 5490 |
^ names collect:[:entry | self construct:entry]. |
6529 | 5491 |
|
5492 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5493 |
'.' asFilename directoryContentsAsFilenames |
6529 | 5494 |
'/XXXdoesNotExist' asFilename directoryContentsAsFilenames |
5495 |
" |
|
5496 |
! |
|
5497 |
||
5498 |
fullDirectoryContents |
|
5499 |
"return the full contents of the directory as a collection of strings. |
|
5500 |
This is much like #directoryContents, but includes an entry for the |
|
5501 |
parent directory, if there is one. |
|
5502 |
Returns nil for non-existing directories; however, this behavior |
|
5503 |
may be changed in the near future, to raise an exception instead. |
|
5504 |
So users of this method better test for existing directory before." |
|
5505 |
||
5506 |
|files| |
|
5507 |
||
12910 | 5508 |
"here we get the files without '.' and '..'" |
6529 | 5509 |
files := self directoryContents. |
5510 |
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
|
5511 |
"/ 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
|
5512 |
^ files |
6529 | 5513 |
]. |
5514 |
||
12910 | 5515 |
files addFirst:'..'. |
6529 | 5516 |
^ files |
5517 |
||
5518 |
" |
|
5519 |
'.' asFilename fullDirectoryContents |
|
5520 |
'/XXXdoesNotExist' asFilename fullDirectoryContents |
|
5521 |
'd:\FET' asFilename fullDirectoryContents |
|
5522 |
" |
|
5523 |
||
5524 |
"Modified: / 21.9.1998 / 15:33:07 / cg" |
|
5525 |
! |
|
5526 |
||
5527 |
recursiveDirectoryContents |
|
5528 |
"return the contents of the directory and all subdirectories |
|
5529 |
as a collection of strings. |
|
5530 |
This excludes any entries for '.' or '..'. |
|
5531 |
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
|
5532 |
Notice: |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5533 |
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
|
5534 |
see also #recursiveDirectoryContentsAsFilenames, which returns fileName instances. |
7697
1cb1a31cd2c2
recursiveDirectoryContentsAsFilenames
Claus Gittinger <cg@exept.de>
parents:
7685
diff
changeset
|
5535 |
|
6529 | 5536 |
Warning: this may take a long time to execute." |
5537 |
||
5538 |
|fileNames dirNames| |
|
5539 |
||
5540 |
fileNames := OrderedCollection new. |
|
5541 |
dirNames := OrderedCollection new. |
|
5542 |
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
|
5543 |
(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
|
5544 |
dirNames add:f |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5545 |
] ifFalse:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5546 |
fileNames add:f |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5547 |
] |
6529 | 5548 |
]. |
5549 |
||
5550 |
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
|
5551 |
|dd subFiles| |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5552 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5553 |
dd := dN asFilename. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5554 |
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
|
5555 |
fileNames addAll:(subFiles collect:[:f | dd constructString:f]) |
6529 | 5556 |
]. |
5557 |
^ fileNames. |
|
5558 |
||
5559 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5560 |
'.' asFilename recursiveDirectoryContents |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5561 |
'../../clients' asFilename recursiveDirectoryContents |
6529 | 5562 |
" |
7697
1cb1a31cd2c2
recursiveDirectoryContentsAsFilenames
Claus Gittinger <cg@exept.de>
parents:
7685
diff
changeset
|
5563 |
! |
1cb1a31cd2c2
recursiveDirectoryContentsAsFilenames
Claus Gittinger <cg@exept.de>
parents:
7685
diff
changeset
|
5564 |
|
1cb1a31cd2c2
recursiveDirectoryContentsAsFilenames
Claus Gittinger <cg@exept.de>
parents:
7685
diff
changeset
|
5565 |
recursiveDirectoryContentsAsFilenames |
1cb1a31cd2c2
recursiveDirectoryContentsAsFilenames
Claus Gittinger <cg@exept.de>
parents:
7685
diff
changeset
|
5566 |
"return the contents of the directory and all subdirectories |
1cb1a31cd2c2
recursiveDirectoryContentsAsFilenames
Claus Gittinger <cg@exept.de>
parents:
7685
diff
changeset
|
5567 |
as a collection of filenames. |
1cb1a31cd2c2
recursiveDirectoryContentsAsFilenames
Claus Gittinger <cg@exept.de>
parents:
7685
diff
changeset
|
5568 |
This excludes any entries for '.' or '..'. |
1cb1a31cd2c2
recursiveDirectoryContentsAsFilenames
Claus Gittinger <cg@exept.de>
parents:
7685
diff
changeset
|
5569 |
Returns nil for non-existing directories; however, this behavior |
1cb1a31cd2c2
recursiveDirectoryContentsAsFilenames
Claus Gittinger <cg@exept.de>
parents:
7685
diff
changeset
|
5570 |
may be changed in the near future, to raise an exception instead. |
1cb1a31cd2c2
recursiveDirectoryContentsAsFilenames
Claus Gittinger <cg@exept.de>
parents:
7685
diff
changeset
|
5571 |
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
|
5572 |
Notice: |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5573 |
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
|
5574 |
see also #recursiveDirectoryContents, which returns strings. |
7697
1cb1a31cd2c2
recursiveDirectoryContentsAsFilenames
Claus Gittinger <cg@exept.de>
parents:
7685
diff
changeset
|
5575 |
|
1cb1a31cd2c2
recursiveDirectoryContentsAsFilenames
Claus Gittinger <cg@exept.de>
parents:
7685
diff
changeset
|
5576 |
Warning: this may take a long time to execute." |
1cb1a31cd2c2
recursiveDirectoryContentsAsFilenames
Claus Gittinger <cg@exept.de>
parents:
7685
diff
changeset
|
5577 |
|
1cb1a31cd2c2
recursiveDirectoryContentsAsFilenames
Claus Gittinger <cg@exept.de>
parents:
7685
diff
changeset
|
5578 |
|names| |
1cb1a31cd2c2
recursiveDirectoryContentsAsFilenames
Claus Gittinger <cg@exept.de>
parents:
7685
diff
changeset
|
5579 |
|
1cb1a31cd2c2
recursiveDirectoryContentsAsFilenames
Claus Gittinger <cg@exept.de>
parents:
7685
diff
changeset
|
5580 |
names := self recursiveDirectoryContents. |
1cb1a31cd2c2
recursiveDirectoryContentsAsFilenames
Claus Gittinger <cg@exept.de>
parents:
7685
diff
changeset
|
5581 |
names isNil ifTrue:[^ nil]. |
12910 | 5582 |
^ names collect:[:entry | self construct:entry]. |
7697
1cb1a31cd2c2
recursiveDirectoryContentsAsFilenames
Claus Gittinger <cg@exept.de>
parents:
7685
diff
changeset
|
5583 |
|
1cb1a31cd2c2
recursiveDirectoryContentsAsFilenames
Claus Gittinger <cg@exept.de>
parents:
7685
diff
changeset
|
5584 |
" |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5585 |
'.' asFilename recursiveDirectoryContentsAsFilenames |
7697
1cb1a31cd2c2
recursiveDirectoryContentsAsFilenames
Claus Gittinger <cg@exept.de>
parents:
7685
diff
changeset
|
5586 |
'/XXXdoesNotExist' asFilename recursiveDirectoryContentsAsFilenames |
1cb1a31cd2c2
recursiveDirectoryContentsAsFilenames
Claus Gittinger <cg@exept.de>
parents:
7685
diff
changeset
|
5587 |
" |
6529 | 5588 |
! ! |
5589 |
||
5590 |
!Filename methodsFor:'reading-files'! |
|
5591 |
||
5592 |
binaryContentsOfEntireFile |
|
5593 |
"return the binary contents of the file (as a byteArray); |
|
7680 | 5594 |
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
|
5595 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5596 |
^ self |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5597 |
readingFileDo:[:s | |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5598 |
|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
|
5599 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5600 |
s binary. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5601 |
nBytes := self fileSize. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5602 |
(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
|
5603 |
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
|
5604 |
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
|
5605 |
n == nBytes ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5606 |
result := bytes |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5607 |
] ifFalse:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5608 |
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
|
5609 |
] |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5610 |
] ifFalse:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5611 |
result := s contentsOfEntireFile |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5612 |
]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5613 |
result |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5614 |
] |
6529 | 5615 |
|
5616 |
" |
|
5617 |
'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
|
5618 |
'foobar' asFilename binaryContentsOfEntireFile |
6529 | 5619 |
" |
14446
479f02b4c705
changed: #binaryContentsOfEntireFile
Claus Gittinger <cg@exept.de>
parents:
14306
diff
changeset
|
5620 |
|
479f02b4c705
changed: #binaryContentsOfEntireFile
Claus Gittinger <cg@exept.de>
parents:
14306
diff
changeset
|
5621 |
"Modified: / 27-10-2012 / 19:42:07 / cg" |
6529 | 5622 |
! |
5623 |
||
5624 |
contents |
|
5625 |
"return the contents of the file as a collection of lines; |
|
7680 | 5626 |
Raises an error, if the file is unreadable/non-existing. |
6529 | 5627 |
See also #contentsOfEntireFile, which returns a string for textFiles. |
5628 |
CAVEAT: bad naming - but req'd for VW compatibility." |
|
5629 |
||
7888
e76fa60251dc
Remove obsolete nil-checks after opening streams
Stefan Vogel <sv@exept.de>
parents:
7846
diff
changeset
|
5630 |
^ self readingFileDo:[:s | s contents]. |
6529 | 5631 |
|
5632 |
" |
|
5633 |
'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
|
5634 |
'foobar' asFilename contents |
6529 | 5635 |
" |
5636 |
||
5637 |
"Modified: / 2.7.1996 / 12:49:45 / stefan" |
|
5638 |
"Created: / 11.7.1996 / 14:09:11 / cg" |
|
5639 |
"Modified: / 15.10.1998 / 11:41:45 / cg" |
|
5640 |
! |
|
5641 |
||
10780 | 5642 |
contentsAsString |
5643 |
"to compensate for the bad naming, use this to make things explicit. |
|
5644 |
See also #contents, which returns the lines as stringCollection for textFiles." |
|
5645 |
||
11397
872cd41bbe05
oops - contentsAsString was endlessly recursive
Claus Gittinger <cg@exept.de>
parents:
11341
diff
changeset
|
5646 |
^ self contentsOfEntireFile |
872cd41bbe05
oops - contentsAsString was endlessly recursive
Claus Gittinger <cg@exept.de>
parents:
11341
diff
changeset
|
5647 |
|
872cd41bbe05
oops - contentsAsString was endlessly recursive
Claus Gittinger <cg@exept.de>
parents:
11341
diff
changeset
|
5648 |
" |
872cd41bbe05
oops - contentsAsString was endlessly recursive
Claus Gittinger <cg@exept.de>
parents:
11341
diff
changeset
|
5649 |
'Makefile' asFilename contentsAsString |
872cd41bbe05
oops - contentsAsString was endlessly recursive
Claus Gittinger <cg@exept.de>
parents:
11341
diff
changeset
|
5650 |
'foobar' asFilename contentsAsString |
10780 | 5651 |
" |
5652 |
||
5653 |
"Modified: / 02-07-1996 / 12:49:45 / stefan" |
|
5654 |
"Created: / 08-11-2007 / 13:29:59 / cg" |
|
5655 |
! |
|
5656 |
||
6529 | 5657 |
contentsOfEntireFile |
5658 |
"return the contents of the file as a string; |
|
7680 | 5659 |
Raises an error, if the file is unreadable/non-existing. |
6529 | 5660 |
See also #contents, which returns the lines as stringCollection for textFiles. |
5661 |
CAVEAT: bad naming - but req'd for VW compatibility." |
|
5662 |
||
7888
e76fa60251dc
Remove obsolete nil-checks after opening streams
Stefan Vogel <sv@exept.de>
parents:
7846
diff
changeset
|
5663 |
^ self readingFileDo:[:s | s contentsOfEntireFile]. |
6529 | 5664 |
|
5665 |
" |
|
5666 |
'Makefile' asFilename contentsOfEntireFile |
|
19043 | 5667 |
'smalltalk.rc' asFilename contentsOfEntireFile |
6529 | 5668 |
'foobar' asFilename contentsOfEntireFile |
5669 |
" |
|
5670 |
||
5671 |
"Modified: / 2.7.1996 / 12:49:45 / stefan" |
|
5672 |
"Modified: / 15.10.1998 / 11:42:05 / cg" |
|
5673 |
! |
|
5674 |
||
5675 |
readingFileDo:aBlock |
|
5676 |
"create a read-stream on the receiver file, evaluate aBlock, passing that stream as arg, |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5677 |
and return the blocks value. |
7088
cc3233554827
Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents:
7075
diff
changeset
|
5678 |
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
|
5679 |
(old behavior, will vanish:)the block is evaluated with a nil argument. |
6529 | 5680 |
Ensures that the stream is closed." |
5681 |
||
5682 |
|stream result| |
|
5683 |
||
5684 |
stream := self readStream. |
|
5685 |
[ |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5686 |
result := aBlock value:stream |
6529 | 5687 |
] ensure:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5688 |
stream notNil ifTrue:[stream close] |
6529 | 5689 |
]. |
5690 |
^ result |
|
5691 |
||
5692 |
" |
|
5693 |
read the first line from some file: |
|
5694 |
||
5695 |
|rslt| |
|
5696 |
||
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5697 |
rslt := |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5698 |
'/etc/passwd' asFilename |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5699 |
readingFileDo:[:s | |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5700 |
s nextLine |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5701 |
]. |
6529 | 5702 |
Transcript showCR:rslt. |
5703 |
" |
|
5704 |
||
5705 |
" |
|
5706 |
find all used shells in /etc/passwd and count their usage: |
|
5707 |
||
5708 |
|rslt| |
|
5709 |
||
5710 |
rslt := |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5711 |
'/etc/passwd' asFilename |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5712 |
readingFileDo: |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5713 |
[:s | |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5714 |
|shells| |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5715 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5716 |
shells := Bag new. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5717 |
s linesDo: |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5718 |
[:line | |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5719 |
|parts| |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5720 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5721 |
parts := line asCollectionOfSubstringsSeparatedBy:$:. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5722 |
shells add:(parts seventh). |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5723 |
]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5724 |
shells contents |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5725 |
]. |
6529 | 5726 |
Transcript showCR:rslt. |
5727 |
" |
|
6771 | 5728 |
! |
5729 |
||
5730 |
readingLinesDo:aBlock |
|
5731 |
"create a read-stream on the receiver file, |
|
5732 |
evaluate aBlock for each line read from the stream. |
|
5733 |
If the file cannot be opened, an error is raised. |
|
5734 |
Ensures that the stream is closed." |
|
5735 |
||
5736 |
self readingFileDo:[:stream | |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5737 |
stream linesDo:aBlock |
6771 | 5738 |
]. |
5739 |
||
5740 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5741 |
'/etc/passwd' asFilename |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5742 |
readingLinesDo:[:eachLine | |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5743 |
Transcript showCR:eachLine. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5744 |
]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5745 |
" |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5746 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5747 |
" |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5748 |
'/etc/xxxxx' asFilename |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5749 |
readingLinesDo:[:eachLine | |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5750 |
Transcript showCR:eachLine. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5751 |
]. |
6771 | 5752 |
" |
6529 | 5753 |
! ! |
5754 |
||
2922 | 5755 |
!Filename methodsFor:'special accessing'! |
5756 |
||
5757 |
osName |
|
5758 |
"special - return the OS's name for the receiver." |
|
5759 |
||
5760 |
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
|
5761 |
^ self osNameForDirectory |
2922 | 5762 |
]. |
5763 |
^ self osNameForFile |
|
5764 |
! |
|
5765 |
||
2978
e466e478fa43
Handle errors in #filenameCompletion:
Stefan Vogel <sv@exept.de>
parents:
2977
diff
changeset
|
5766 |
osNameForAccess |
e466e478fa43
Handle errors in #filenameCompletion:
Stefan Vogel <sv@exept.de>
parents:
2977
diff
changeset
|
5767 |
"internal - return the OS's name for the receiver to |
3665 | 5768 |
access its fileInfo. |
5769 |
This may be redefined for systems, where a special suffix must be |
|
5770 |
added in order to access directories (or others) as a file. |
|
5771 |
(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
|
5772 |
|
7064 | 5773 |
^ self osNameForFile |
3665 | 5774 |
|
5775 |
"Modified: / 21.7.1998 / 10:40:40 / cg" |
|
2978
e466e478fa43
Handle errors in #filenameCompletion:
Stefan Vogel <sv@exept.de>
parents:
2977
diff
changeset
|
5776 |
! |
e466e478fa43
Handle errors in #filenameCompletion:
Stefan Vogel <sv@exept.de>
parents:
2977
diff
changeset
|
5777 |
|
2922 | 5778 |
osNameForDirectory |
3753 | 5779 |
"internal - return the OS's name for the receiver to |
2922 | 5780 |
access it as a directory." |
5781 |
||
14218 | 5782 |
^ self osNameForFile |
3753 | 5783 |
|
5784 |
"Modified: / 12.8.1998 / 14:44:32 / cg" |
|
2922 | 5785 |
! |
5786 |
||
3720
d2529646d235
oops - needed a kludge to read the top directory under win32
Claus Gittinger <cg@exept.de>
parents:
3719
diff
changeset
|
5787 |
osNameForDirectoryContents |
3753 | 5788 |
"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
|
5789 |
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
|
5790 |
|
d2529646d235
oops - needed a kludge to read the top directory under win32
Claus Gittinger <cg@exept.de>
parents:
3719
diff
changeset
|
5791 |
^ self osNameForDirectory |
d2529646d235
oops - needed a kludge to read the top directory under win32
Claus Gittinger <cg@exept.de>
parents:
3719
diff
changeset
|
5792 |
|
d2529646d235
oops - needed a kludge to read the top directory under win32
Claus Gittinger <cg@exept.de>
parents:
3719
diff
changeset
|
5793 |
"Created: / 3.8.1998 / 21:36:06 / cg" |
3753 | 5794 |
"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
|
5795 |
! |
d2529646d235
oops - needed a kludge to read the top directory under win32
Claus Gittinger <cg@exept.de>
parents:
3719
diff
changeset
|
5796 |
|
2922 | 5797 |
osNameForFile |
5798 |
"internal - return the OS's name for the receiver to |
|
5799 |
access it as a file." |
|
5800 |
||
14220
2a3457b016be
Fix the '~/dir/name' resolution fow windows
Stefan Vogel <sv@exept.de>
parents:
14218
diff
changeset
|
5801 |
(nameString startsWith:'~') ifFalse:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5802 |
^ nameString. |
14220
2a3457b016be
Fix the '~/dir/name' resolution fow windows
Stefan Vogel <sv@exept.de>
parents:
14218
diff
changeset
|
5803 |
]. |
2a3457b016be
Fix the '~/dir/name' resolution fow windows
Stefan Vogel <sv@exept.de>
parents:
14218
diff
changeset
|
5804 |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5805 |
^ self species nameWithSpecialExpansions:nameString. |
2922 | 5806 |
! ! |
5807 |
||
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5808 |
!Filename methodsFor:'suffixes'! |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5809 |
|
11748 | 5810 |
addSuffix:aSuffix |
14306
f41ca29d9b54
comment/format in: #addSuffix:
Stefan Vogel <sv@exept.de>
parents:
14232
diff
changeset
|
5811 |
"return a new filename for the receivers 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
|
5812 |
The new suffix is simply appended to the name, |
14306
f41ca29d9b54
comment/format in: #addSuffix:
Stefan Vogel <sv@exept.de>
parents:
14232
diff
changeset
|
5813 |
regardless whether there is already an existing suffix. |
f41ca29d9b54
comment/format in: #addSuffix:
Stefan Vogel <sv@exept.de>
parents:
14232
diff
changeset
|
5814 |
See also #withSuffix:" |
11748 | 5815 |
|
5816 |
|prefixName| |
|
5817 |
||
5818 |
prefixName := self name. |
|
5819 |
aSuffix isEmptyOrNil ifTrue:[ |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5820 |
^ self species named:prefixName |
11748 | 5821 |
]. |
5822 |
||
15811 | 5823 |
^ self species named: |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5824 |
(prefixName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5825 |
, self species suffixSeparator asString |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5826 |
, aSuffix asString) |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5827 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5828 |
" |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5829 |
'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
|
5830 |
'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
|
5831 |
'.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
|
5832 |
'.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
|
5833 |
'.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
|
5834 |
'.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
|
5835 |
'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
|
5836 |
'.' asFilename addSuffix:nil |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5837 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5838 |
'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
|
5839 |
'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
|
5840 |
'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
|
5841 |
'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
|
5842 |
'.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
|
5843 |
'.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
|
5844 |
'.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
|
5845 |
'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
|
5846 |
'.' asFilename addSuffix:'o' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5847 |
'/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
|
5848 |
'/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
|
5849 |
'/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
|
5850 |
'/foo/bar.c/baz' asFilename addSuffix:'st' |
11748 | 5851 |
" |
5852 |
! |
|
5853 |
||
2906 | 5854 |
hasSuffix:aSuffixString |
5855 |
"return true if my suffix is the same as aString. |
|
5856 |
This cares for systems, where case is ignored in filenames" |
|
5857 |
||
5858 |
|mySuffix| |
|
5859 |
||
5860 |
mySuffix := self suffix. |
|
15811 | 5861 |
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
|
5862 |
^ mySuffix = aSuffixString |
2906 | 5863 |
]. |
5864 |
^ mySuffix asLowercase = aSuffixString asLowercase |
|
5865 |
||
5866 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5867 |
'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
|
5868 |
'abc.ST' asFilename hasSuffix:'st' |
7115
dea26def3167
prefix/suffix definition changed for files beginning with
Claus Gittinger <cg@exept.de>
parents:
7088
diff
changeset
|
5869 |
'.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
|
5870 |
'.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
|
5871 |
'.foorc.sav' asFilename hasSuffix:'sav' |
2906 | 5872 |
" |
5873 |
||
5874 |
"Modified: 7.9.1997 / 02:55:25 / cg" |
|
5875 |
! |
|
5876 |
||
10155 | 5877 |
nameWithoutSuffix |
5878 |
"return the receivers name without the suffix. |
|
5879 |
If the name has no suffix, the original name is returned." |
|
5880 |
||
5881 |
|nm idx idxFromEnd| |
|
5882 |
||
5883 |
nm := self baseName. |
|
15811 | 5884 |
idx := nm lastIndexOf:(self species suffixSeparator). |
10155 | 5885 |
(idx == 0) ifTrue:[^ nameString]. |
5886 |
"/ be careful: if the name consists only of suffix (i.e '.foo'), |
|
5887 |
"/ the suffix is considered empty. |
|
5888 |
(idx == 1) ifTrue:[^ nameString]. |
|
5889 |
||
5890 |
idxFromEnd := nm size - idx. |
|
5891 |
idx := nameString size - idxFromEnd. |
|
5892 |
||
5893 |
^ nameString copyTo:(idx - 1) |
|
5894 |
||
5895 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5896 |
'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
|
5897 |
'abc' asFilename nameWithoutSuffix |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5898 |
'/abc' asFilename nameWithoutSuffix |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5899 |
'/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
|
5900 |
'./abc' asFilename nameWithoutSuffix |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5901 |
'./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
|
5902 |
'./.abc' asFilename nameWithoutSuffix |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5903 |
'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
|
5904 |
'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
|
5905 |
'.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
|
5906 |
'.b.' asFilename nameWithoutSuffix |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5907 |
'.b' asFilename nameWithoutSuffix |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5908 |
'/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
|
5909 |
'/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
|
5910 |
'/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
|
5911 |
'/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
|
5912 |
'/foo/bar/baz/foo.c/bar.c' asFilename nameWithoutSuffix |
10155 | 5913 |
" |
5914 |
||
5915 |
"Modified: / 07-09-1995 / 11:15:42 / claus" |
|
5916 |
"Created: / 07-11-2006 / 13:55:18 / cg" |
|
5917 |
! |
|
5918 |
||
9453 | 5919 |
prefix |
5920 |
"return my prefix. |
|
5921 |
The suffix is the namepart after the final period character, |
|
5922 |
or the empty string, if the name does not contain a period." |
|
5923 |
||
5924 |
^ self prefixAndSuffix at:1 |
|
5925 |
||
5926 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5927 |
'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
|
5928 |
'abc' asFilename prefix |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5929 |
'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
|
5930 |
'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
|
5931 |
'a.' asFilename prefix |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5932 |
'.a' asFilename prefix |
9453 | 5933 |
" |
5934 |
||
5935 |
"Modified: / 07-09-1995 / 11:09:03 / claus" |
|
5936 |
"Created: / 13-07-2006 / 10:27:19 / fm" |
|
5937 |
! |
|
5938 |
||
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5939 |
prefixAndSuffix |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5940 |
"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
|
5941 |
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
|
5942 |
the prefix everything before, except for the period. |
1517 | 5943 |
The directory name part is stripped off (i.e. the returned prefix |
16578 | 5944 |
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
|
5945 |
(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
|
5946 |
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
|
5947 |
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
|
5948 |
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
|
5949 |
'.foorc'. |
1517 | 5950 |
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
|
5951 |
Notice: |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5952 |
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
|
5953 |
the period character as suffixCharacter." |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5954 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5955 |
|nm idx| |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5956 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5957 |
nm := self baseName. |
15811 | 5958 |
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
|
5959 |
"/ 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
|
5960 |
"/ the suffix is considered empty. |
dea26def3167
prefix/suffix definition changed for files beginning with
Claus Gittinger <cg@exept.de>
parents:
7088
diff
changeset
|
5961 |
((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
|
5962 |
^ Array with:nm with:'' |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5963 |
]. |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5964 |
^ Array |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5965 |
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
|
5966 |
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
|
5967 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5968 |
" |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5969 |
'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
|
5970 |
'abc' asFilename prefixAndSuffix |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5971 |
'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
|
5972 |
'/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
|
5973 |
'a.' asFilename prefixAndSuffix |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5974 |
'.a' asFilename prefixAndSuffix |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5975 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5976 |
|parts| |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5977 |
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
|
5978 |
((parts at:1) , '.o') asFilename |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5979 |
" |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5980 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5981 |
"Modified: 7.9.1995 / 11:15:42 / claus" |
1517 | 5982 |
"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
|
5983 |
! |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
5984 |
|
2906 | 5985 |
suffix |
5986 |
"return my suffix. |
|
5987 |
The suffix is the namepart after the final period character, |
|
5988 |
or the empty string, if the name does not contain a period." |
|
5989 |
||
5990 |
^ self prefixAndSuffix at:2 |
|
5991 |
||
5992 |
" |
|
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5993 |
'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
|
5994 |
'abc' asFilename suffix |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5995 |
'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
|
5996 |
'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
|
5997 |
'a.' asFilename suffix |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
5998 |
'.a' asFilename suffix |
2906 | 5999 |
" |
6000 |
||
6001 |
"Modified: 7.9.1995 / 11:09:03 / claus" |
|
6002 |
! |
|
6003 |
||
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
6004 |
withSuffix:aSuffix |
2922 | 6005 |
"return a new filename for the receivers name with a different suffix. |
6256 | 6006 |
If the name already has a suffix, the new suffix replaces it; |
1993 | 6007 |
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
|
6008 |
|
7115
dea26def3167
prefix/suffix definition changed for files beginning with
Claus Gittinger <cg@exept.de>
parents:
7088
diff
changeset
|
6009 |
|prefixName| |
dea26def3167
prefix/suffix definition changed for files beginning with
Claus Gittinger <cg@exept.de>
parents:
7088
diff
changeset
|
6010 |
|
10155 | 6011 |
prefixName := self nameWithoutSuffix. |
7115
dea26def3167
prefix/suffix definition changed for files beginning with
Claus Gittinger <cg@exept.de>
parents:
7088
diff
changeset
|
6012 |
aSuffix isEmptyOrNil ifTrue:[ |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6013 |
^ self species named:prefixName |
6262 | 6014 |
]. |
6015 |
||
15811 | 6016 |
^ self species named: |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6017 |
(prefixName |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6018 |
, self class suffixSeparator asString |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6019 |
, aSuffix asString) |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6020 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6021 |
" |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6022 |
'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
|
6023 |
'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
|
6024 |
'.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
|
6025 |
'.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
|
6026 |
'.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
|
6027 |
'.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
|
6028 |
'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
|
6029 |
'.' asFilename withSuffix:nil |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6030 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6031 |
'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
|
6032 |
'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
|
6033 |
'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
|
6034 |
'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
|
6035 |
'.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
|
6036 |
'.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
|
6037 |
'.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
|
6038 |
'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
|
6039 |
'.' asFilename withSuffix:'o' |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6040 |
'/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
|
6041 |
'/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
|
6042 |
'/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
|
6043 |
'/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
|
6044 |
" |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
6045 |
|
10155 | 6046 |
"Modified: / 07-09-1995 / 11:15:42 / claus" |
6047 |
"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
|
6048 |
! |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
6049 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
6050 |
withoutSuffix |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
6051 |
"return a new filename for the receivers name without the suffix. |
10155 | 6052 |
If the name has no suffix, a filename representing the same file as the receiver is returned." |
6053 |
||
6054 |
|n| |
|
6055 |
||
6056 |
n := self nameWithoutSuffix. |
|
6057 |
n = nameString ifTrue:[^ self]. |
|
15811 | 6058 |
^ self species named:n |
1049
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
6059 |
|
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
6060 |
" |
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6061 |
'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
|
6062 |
'abc' asFilename withoutSuffix |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6063 |
'/abc' asFilename withoutSuffix |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6064 |
'/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
|
6065 |
'./abc' asFilename withoutSuffix |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6066 |
'./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
|
6067 |
'./.abc' asFilename withoutSuffix |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6068 |
'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
|
6069 |
'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
|
6070 |
'.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
|
6071 |
'.b.' asFilename withoutSuffix |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6072 |
'.b' asFilename withoutSuffix |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6073 |
'/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
|
6074 |
'/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
|
6075 |
'/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
|
6076 |
'/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
|
6077 |
'/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
|
6078 |
" |
6f7b6c18a748
new goodies (bells & whistles upon claus's request)
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
6079 |
|
10155 | 6080 |
"Modified: / 07-09-1995 / 11:15:42 / claus" |
6081 |
"Modified: / 07-11-2006 / 13:57:45 / cg" |
|
174 | 6082 |
! ! |
6083 |
||
5597 | 6084 |
!Filename methodsFor:'testing'! |
6085 |
||
6086 |
isFilename |
|
6087 |
"return true, if the receiver is some kind of filename; |
|
6088 |
false is returned here - the method is redefined from Object." |
|
6089 |
||
6090 |
^true |
|
6091 |
||
6092 |
||
6093 |
! ! |
|
6094 |
||
10271 | 6095 |
!Filename methodsFor:'writing-files'! |
6096 |
||
14512 | 6097 |
appendingFileDo:aBlock |
6098 |
"create a append-stream on the receiver file, evaluate aBlock, passing that stream as arg, |
|
19088 | 6099 |
and return the block's value. |
14512 | 6100 |
If the file cannot be opened, an exception is raised. |
6101 |
Ensures that the stream is closed." |
|
6102 |
||
6103 |
|stream result| |
|
6104 |
||
6105 |
stream := self appendStream. |
|
6106 |
[ |
|
19088 | 6107 |
result := aBlock value:stream |
14512 | 6108 |
] ensure:[ |
19088 | 6109 |
stream close |
14512 | 6110 |
]. |
6111 |
^ result |
|
6112 |
||
6113 |
" |
|
14513 | 6114 |
'ttt' asFilename appendingFileDo:[:s | |
19088 | 6115 |
s nextPutLine:'hello'. |
6116 |
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
|
6117 |
] |
14512 | 6118 |
" |
6119 |
||
6120 |
"Created: / 09-11-2012 / 10:07:41 / sr" |
|
6121 |
! |
|
6122 |
||
10779 | 6123 |
contents:aStringOrCollectionOfLines |
10271 | 6124 |
"create (or overwrite) a file given its contents as a collection of lines. |
6125 |
Raises an error, if the file is unwritable." |
|
6126 |
||
18667
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6127 |
^ self |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6128 |
writingFileDo:[:s | |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6129 |
aStringOrCollectionOfLines isNonByteCollection ifTrue:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6130 |
"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
|
6131 |
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
|
6132 |
] ifFalse:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6133 |
"something string-like" |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6134 |
aStringOrCollectionOfLines isString ifFalse:[ |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6135 |
s binary |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6136 |
]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6137 |
s nextPutAll:aStringOrCollectionOfLines |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6138 |
] |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6139 |
]. |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6140 |
|
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6141 |
" |
ed22f49c33f1
temporarily disabled recent changes - expecco's keyfile check failed with them.
Claus Gittinger <cg@exept.de>
parents:
18659
diff
changeset
|
6142 |
'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
|
6143 |
'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
|
6144 |
'foo3' asFilename contents:#[1 2 3 4 5] |
10271 | 6145 |
" |
6146 |
||
6147 |
"Created: / 11-12-2006 / 14:11:21 / cg" |
|
10779 | 6148 |
"Modified: / 08-11-2007 / 13:28:41 / cg" |
10271 | 6149 |
! |
6150 |
||
6151 |
writingFileDo:aBlock |
|
6152 |
"create a write-stream on the receiver file, evaluate aBlock, passing that stream as arg, |
|
19088 | 6153 |
and return the block's value. |
10271 | 6154 |
If the file cannot be opened, an exception is raised. |
6155 |
Ensures that the stream is closed." |
|
6156 |
||
6157 |
|stream result| |
|
6158 |
||
6159 |
stream := self writeStream. |
|
6160 |
[ |
|
19088 | 6161 |
result := aBlock value:stream |
10271 | 6162 |
] ensure:[ |
19088 | 6163 |
stream close |
10271 | 6164 |
]. |
6165 |
^ result |
|
6166 |
||
6167 |
" |
|
6168 |
'ttt' asFilename writingFileDo:[:s | |
|
19088 | 6169 |
s nextPutLine:'hello'. |
6170 |
s nextPutLine:'world'. |
|
10271 | 6171 |
] |
6172 |
" |
|
6173 |
||
6174 |
"Created: / 11-12-2006 / 14:09:39 / cg" |
|
6175 |
! ! |
|
6176 |
||
1859
7f6040320daf
changes for new return from OS>>infoOf:
Claus Gittinger <cg@exept.de>
parents:
1614
diff
changeset
|
6177 |
!Filename class methodsFor:'documentation'! |
630 | 6178 |
|
6179 |
version |
|
18490 | 6180 |
^ '$Header$' |
12318 | 6181 |
! |
6182 |
||
6183 |
version_CVS |
|
18490 | 6184 |
^ '$Header$' |
630 | 6185 |
! ! |
6771 | 6186 |
|
14628 | 6187 |
|
2906 | 6188 |
Filename initialize! |