author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Sat, 26 Nov 2011 08:36:46 +0000 | |
branch | jv |
changeset 17900 | b9614a1cf804 |
parent 17892 | d86c8bd5ece3 |
child 17910 | 8d796ca8bd1d |
permissions | -rw-r--r-- |
1 | 1 |
" |
5 | 2 |
COPYRIGHT (c) 1989 by Claus Gittinger |
172 | 3 |
All Rights Reserved |
1 | 4 |
|
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
5556 | 12 |
"{ Package: 'stx:libbasic' }" |
13 |
||
1 | 14 |
Collection subclass:#FileDirectory |
1290 | 15 |
instanceVariableNames:'pathName lazy' |
16 |
classVariableNames:'PathOfCurrentDirectory' |
|
17 |
poolDictionaries:'' |
|
3203
09a9b6bde8af
Moved into category 'Obsolete'.
Stefan Vogel <sv@exept.de>
parents:
3201
diff
changeset
|
18 |
category:'Obsolete' |
1 | 19 |
! |
20 |
||
17734
406b1590afe8
Merged with trunk r10476
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17728
diff
changeset
|
21 |
ArrayedCollection subclass:#DirectoryEntry |
406b1590afe8
Merged with trunk r10476
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17728
diff
changeset
|
22 |
instanceVariableNames:'name creationTime modificationTime dirFlag fileSize' |
406b1590afe8
Merged with trunk r10476
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17728
diff
changeset
|
23 |
classVariableNames:'' |
406b1590afe8
Merged with trunk r10476
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17728
diff
changeset
|
24 |
poolDictionaries:'' |
406b1590afe8
Merged with trunk r10476
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17728
diff
changeset
|
25 |
privateIn:FileDirectory |
406b1590afe8
Merged with trunk r10476
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17728
diff
changeset
|
26 |
! |
406b1590afe8
Merged with trunk r10476
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17728
diff
changeset
|
27 |
|
88 | 28 |
!FileDirectory class methodsFor:'documentation'! |
29 |
||
30 |
copyright |
|
31 |
" |
|
32 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
172 | 33 |
All Rights Reserved |
1 | 34 |
|
88 | 35 |
This software is furnished under a license and may be used |
36 |
only in accordance with the terms of that license and with the |
|
37 |
inclusion of the above copyright notice. This software may not |
|
38 |
be provided or otherwise made available to, or used by, any |
|
39 |
other person. No title to or ownership of the software is |
|
40 |
hereby transferred. |
|
41 |
" |
|
42 |
! |
|
1 | 43 |
|
88 | 44 |
documentation |
45 |
" |
|
3203
09a9b6bde8af
Moved into category 'Obsolete'.
Stefan Vogel <sv@exept.de>
parents:
3201
diff
changeset
|
46 |
Notice: |
09a9b6bde8af
Moved into category 'Obsolete'.
Stefan Vogel <sv@exept.de>
parents:
3201
diff
changeset
|
47 |
This class is obsolete and does work only under UNIX. |
09a9b6bde8af
Moved into category 'Obsolete'.
Stefan Vogel <sv@exept.de>
parents:
3201
diff
changeset
|
48 |
Use Filename instead. |
09a9b6bde8af
Moved into category 'Obsolete'.
Stefan Vogel <sv@exept.de>
parents:
3201
diff
changeset
|
49 |
|
09a9b6bde8af
Moved into category 'Obsolete'.
Stefan Vogel <sv@exept.de>
parents:
3201
diff
changeset
|
50 |
This class is not available in other ST-systems; |
09a9b6bde8af
Moved into category 'Obsolete'.
Stefan Vogel <sv@exept.de>
parents:
3201
diff
changeset
|
51 |
in contrast, ST-80 provides a Filename class. |
09a9b6bde8af
Moved into category 'Obsolete'.
Stefan Vogel <sv@exept.de>
parents:
3201
diff
changeset
|
52 |
Therefore, Filename has taken over the functionality. |
09a9b6bde8af
Moved into category 'Obsolete'.
Stefan Vogel <sv@exept.de>
parents:
3201
diff
changeset
|
53 |
|
88 | 54 |
FileDirectories represent directories in the underlying host system. |
55 |
They provide various methods to create/delete and query for files and/or |
|
202 | 56 |
directories. Also, since FileDirectory inherits from Collection, it |
57 |
provides all enumeration and testing protocol. For example, you can |
|
58 |
loop over the filenames in a directory using 'aFileDirectory do:[:nm | ...]'. |
|
59 |
||
1290 | 60 |
[author:] |
61 |
Claus Gittinger |
|
62 |
||
63 |
[see also:] |
|
64 |
Filename |
|
65 |
FileStream DirectoryStream OperatingSystem |
|
88 | 66 |
" |
67 |
! ! |
|
1 | 68 |
|
2 | 69 |
!FileDirectory class methodsFor:'initialization'! |
70 |
||
71 |
initialize |
|
276 | 72 |
"/ |
73 |
"/ want to know about image restart |
|
74 |
"/ |
|
2 | 75 |
ObjectMemory addDependent:self |
76 |
! |
|
77 |
||
1469 | 78 |
update:something with:aParameter from:changedObject |
276 | 79 |
"/ |
80 |
"/ currentDirectory may be different when restarted |
|
81 |
"/ |
|
3941
574defdaaa40
flush cached current-dir-path earlier.
Claus Gittinger <cg@exept.de>
parents:
3203
diff
changeset
|
82 |
something == #earlySystemInstallation ifTrue:[ |
1469 | 83 |
PathOfCurrentDirectory := nil |
2 | 84 |
] |
1469 | 85 |
|
3941
574defdaaa40
flush cached current-dir-path earlier.
Claus Gittinger <cg@exept.de>
parents:
3203
diff
changeset
|
86 |
"Created: / 15.6.1996 / 15:20:21 / cg" |
574defdaaa40
flush cached current-dir-path earlier.
Claus Gittinger <cg@exept.de>
parents:
3203
diff
changeset
|
87 |
"Modified: / 11.12.1998 / 16:28:40 / cg" |
2 | 88 |
! ! |
89 |
||
1 | 90 |
!FileDirectory class methodsFor:'instance creation'! |
91 |
||
92 |
currentDirectory |
|
93 |
"create and return a new FileDirectory for the current directory" |
|
94 |
||
2951 | 95 |
"/ self obsoleteMethodWarning:'use Filename'. |
17851 | 96 |
^ self on:(Filename currentDirectory name) |
88 | 97 |
|
98 |
" |
|
99 |
FileDirectory currentDirectory contents |
|
100 |
FileDirectory currentDirectory files |
|
101 |
FileDirectory currentDirectory isReadable |
|
102 |
FileDirectory currentDirectory pathName |
|
103 |
" |
|
17851 | 104 |
|
105 |
"Modified: / 20-08-2011 / 12:19:51 / cg" |
|
1 | 106 |
! |
107 |
||
605 | 108 |
directoryNamed:name |
109 |
"create and return a new FileDirectory for the directory |
|
110 |
with given pathname" |
|
111 |
||
2951 | 112 |
"/ self obsoleteMethodWarning:'use Filename'. |
2921 | 113 |
name asString = '.' ifTrue:[ |
17851 | 114 |
Filename currentDirectory name ~= '.' ifTrue:[ |
115 |
^ self currentDirectory |
|
116 |
] |
|
2921 | 117 |
]. |
17851 | 118 |
^ self on:(name asFilename constructString:'') |
605 | 119 |
|
120 |
" |
|
121 |
(FileDirectory directoryNamed:'..') pathName |
|
122 |
(FileDirectory directoryNamed:'../..') files |
|
123 |
" |
|
17851 | 124 |
|
125 |
"Modified: / 20-08-2011 / 12:19:57 / cg" |
|
605 | 126 |
! |
127 |
||
1 | 128 |
directoryNamed:name in:aFileDirectory |
129 |
"create and return a new FileDirectory for the directory with given name |
|
130 |
in another FileDirectory" |
|
131 |
||
2961 | 132 |
|baseName| |
1 | 133 |
|
2951 | 134 |
"/ self obsoleteMethodWarning:'use Filename'. |
2921 | 135 |
|
136 |
name asFilename isAbsolute ifTrue:[ |
|
2590
6855cfa1e628
temporary kludge for drive specifiers in MSDOS fileNames.
Claus Gittinger <cg@exept.de>
parents:
1469
diff
changeset
|
137 |
^ self directoryNamed:name |
1 | 138 |
]. |
2921 | 139 |
|
1 | 140 |
(aFileDirectory isKindOf:FileDirectory) ifTrue:[ |
2590
6855cfa1e628
temporary kludge for drive specifiers in MSDOS fileNames.
Claus Gittinger <cg@exept.de>
parents:
1469
diff
changeset
|
141 |
baseName := aFileDirectory pathName |
1 | 142 |
] ifFalse:[ |
2590
6855cfa1e628
temporary kludge for drive specifiers in MSDOS fileNames.
Claus Gittinger <cg@exept.de>
parents:
1469
diff
changeset
|
143 |
baseName := aFileDirectory |
1 | 144 |
]. |
17851 | 145 |
^ self on:((Filename named:baseName) constructString:name) |
2590
6855cfa1e628
temporary kludge for drive specifiers in MSDOS fileNames.
Claus Gittinger <cg@exept.de>
parents:
1469
diff
changeset
|
146 |
|
17851 | 147 |
"Modified: / 28-04-1997 / 22:34:47 / dq" |
148 |
"Modified: / 20-08-2011 / 12:20:03 / cg" |
|
149 |
! |
|
150 |
||
151 |
on:aDirectoryPathName |
|
152 |
^ (self basicNew) pathName:aDirectoryPathName |
|
153 |
||
154 |
"Created: / 20-08-2011 / 12:19:28 / cg" |
|
605 | 155 |
! |
156 |
||
157 |
rootDirectory |
|
158 |
"create and return a new FileDirectory for the root directory" |
|
159 |
||
2951 | 160 |
"/ self obsoleteMethodWarning:'use Filename'. |
17851 | 161 |
^ self on:(Filename rootDirectory name) |
605 | 162 |
|
163 |
" |
|
164 |
FileDirectory rootDirectory contents |
|
165 |
FileDirectory rootDirectory files |
|
166 |
FileDirectory rootDirectory isReadable |
|
167 |
" |
|
17851 | 168 |
|
169 |
"Modified: / 20-08-2011 / 12:20:09 / cg" |
|
276 | 170 |
! ! |
171 |
||
7305 | 172 |
!FileDirectory class methodsFor:'Compatibility-Squeak'! |
5729 | 173 |
|
7655 | 174 |
default |
175 |
^ (self basicNew) pathName:(Filename defaultDirectory name) |
|
176 |
! |
|
177 |
||
5777 | 178 |
localNameFor:aFileNameString |
179 |
^ aFileNameString asFilename baseName |
|
180 |
! |
|
181 |
||
5729 | 182 |
pathNameDelimiter |
183 |
^ Filename separator |
|
17851 | 184 |
! |
185 |
||
186 |
slash |
|
187 |
^ Filename separator asString |
|
188 |
||
189 |
"Created: / 20-08-2011 / 12:18:27 / cg" |
|
5729 | 190 |
! ! |
191 |
||
276 | 192 |
!FileDirectory class methodsFor:'private'! |
193 |
||
194 |
fullPathNameOf:name in:path |
|
195 |
|sep| |
|
196 |
||
197 |
sep := OperatingSystem fileSeparator asString. |
|
2590
6855cfa1e628
temporary kludge for drive specifiers in MSDOS fileNames.
Claus Gittinger <cg@exept.de>
parents:
1469
diff
changeset
|
198 |
|
6855cfa1e628
temporary kludge for drive specifiers in MSDOS fileNames.
Claus Gittinger <cg@exept.de>
parents:
1469
diff
changeset
|
199 |
"/ is it an absolute path ? |
6855cfa1e628
temporary kludge for drive specifiers in MSDOS fileNames.
Claus Gittinger <cg@exept.de>
parents:
1469
diff
changeset
|
200 |
|
276 | 201 |
(name startsWith:sep) ifTrue:[ |
2590
6855cfa1e628
temporary kludge for drive specifiers in MSDOS fileNames.
Claus Gittinger <cg@exept.de>
parents:
1469
diff
changeset
|
202 |
^ name |
276 | 203 |
]. |
2590
6855cfa1e628
temporary kludge for drive specifiers in MSDOS fileNames.
Claus Gittinger <cg@exept.de>
parents:
1469
diff
changeset
|
204 |
|
6855cfa1e628
temporary kludge for drive specifiers in MSDOS fileNames.
Claus Gittinger <cg@exept.de>
parents:
1469
diff
changeset
|
205 |
"/ temporary kludge; this and the previous should |
6855cfa1e628
temporary kludge for drive specifiers in MSDOS fileNames.
Claus Gittinger <cg@exept.de>
parents:
1469
diff
changeset
|
206 |
"/ go into OS isAbsolutePath .. |
6855cfa1e628
temporary kludge for drive specifiers in MSDOS fileNames.
Claus Gittinger <cg@exept.de>
parents:
1469
diff
changeset
|
207 |
|
6855cfa1e628
temporary kludge for drive specifiers in MSDOS fileNames.
Claus Gittinger <cg@exept.de>
parents:
1469
diff
changeset
|
208 |
OperatingSystem isMSDOSlike ifTrue:[ |
6855cfa1e628
temporary kludge for drive specifiers in MSDOS fileNames.
Claus Gittinger <cg@exept.de>
parents:
1469
diff
changeset
|
209 |
('[a-zA-Z]:*' match:name) ifTrue:[ |
6855cfa1e628
temporary kludge for drive specifiers in MSDOS fileNames.
Claus Gittinger <cg@exept.de>
parents:
1469
diff
changeset
|
210 |
"/ drive spec ... |
6855cfa1e628
temporary kludge for drive specifiers in MSDOS fileNames.
Claus Gittinger <cg@exept.de>
parents:
1469
diff
changeset
|
211 |
^ name |
6855cfa1e628
temporary kludge for drive specifiers in MSDOS fileNames.
Claus Gittinger <cg@exept.de>
parents:
1469
diff
changeset
|
212 |
] |
6855cfa1e628
temporary kludge for drive specifiers in MSDOS fileNames.
Claus Gittinger <cg@exept.de>
parents:
1469
diff
changeset
|
213 |
]. |
276 | 214 |
^ path , sep , name |
2590
6855cfa1e628
temporary kludge for drive specifiers in MSDOS fileNames.
Claus Gittinger <cg@exept.de>
parents:
1469
diff
changeset
|
215 |
|
6855cfa1e628
temporary kludge for drive specifiers in MSDOS fileNames.
Claus Gittinger <cg@exept.de>
parents:
1469
diff
changeset
|
216 |
"Modified: 28.4.1997 / 22:06:17 / cg" |
6855cfa1e628
temporary kludge for drive specifiers in MSDOS fileNames.
Claus Gittinger <cg@exept.de>
parents:
1469
diff
changeset
|
217 |
"Modified: 28.4.1997 / 22:34:18 / dq" |
1 | 218 |
! ! |
219 |
||
7655 | 220 |
!FileDirectory methodsFor:'Compatibility-Squeak'! |
221 |
||
17728
bbc5fa73dfab
Merged with trunk r10466
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
222 |
assureExistence |
bbc5fa73dfab
Merged with trunk r10466
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
223 |
self asFilename recursiveMakeDirectory |
bbc5fa73dfab
Merged with trunk r10466
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
224 |
! |
bbc5fa73dfab
Merged with trunk r10466
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
225 |
|
bbc5fa73dfab
Merged with trunk r10466
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
226 |
containingDirectory |
bbc5fa73dfab
Merged with trunk r10466
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
227 |
^ self class |
bbc5fa73dfab
Merged with trunk r10466
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
228 |
directoryNamed:(self asFilename directory pathName) |
bbc5fa73dfab
Merged with trunk r10466
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
229 |
! |
bbc5fa73dfab
Merged with trunk r10466
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
230 |
|
7655 | 231 |
deleteDirectory:dirName |
9332 | 232 |
"Squeak/ST80 compatibility" |
7655 | 233 |
|
234 |
^ self removeDirectory:dirName |
|
235 |
! |
|
236 |
||
237 |
deleteFileNamed:fileName |
|
9332 | 238 |
"Squeak/ST80 compatibility" |
7655 | 239 |
|
240 |
^ self removeFile:fileName |
|
241 |
! |
|
242 |
||
17734
406b1590afe8
Merged with trunk r10476
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17728
diff
changeset
|
243 |
directoryEntryFor:name |
406b1590afe8
Merged with trunk r10476
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17728
diff
changeset
|
244 |
|info| |
406b1590afe8
Merged with trunk r10476
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17728
diff
changeset
|
245 |
|
406b1590afe8
Merged with trunk r10476
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17728
diff
changeset
|
246 |
info := self infoOf:name. |
17859 | 247 |
info isNil ifTrue:[ |
248 |
info := (self filenameFor:name) linkInfo. |
|
249 |
]. |
|
17734
406b1590afe8
Merged with trunk r10476
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17728
diff
changeset
|
250 |
^ DirectoryEntry new |
406b1590afe8
Merged with trunk r10476
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17728
diff
changeset
|
251 |
name:name |
406b1590afe8
Merged with trunk r10476
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17728
diff
changeset
|
252 |
creationTime:(info creationTime) |
406b1590afe8
Merged with trunk r10476
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17728
diff
changeset
|
253 |
modificationTime:(info modificationTime) |
406b1590afe8
Merged with trunk r10476
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17728
diff
changeset
|
254 |
dirFlag:(info isDirectory) |
406b1590afe8
Merged with trunk r10476
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17728
diff
changeset
|
255 |
fileSize:(info isDirectory) |
406b1590afe8
Merged with trunk r10476
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17728
diff
changeset
|
256 |
|
406b1590afe8
Merged with trunk r10476
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17728
diff
changeset
|
257 |
" |
406b1590afe8
Merged with trunk r10476
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17728
diff
changeset
|
258 |
(FileDirectory directoryNamed:'.') entries |
406b1590afe8
Merged with trunk r10476
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17728
diff
changeset
|
259 |
" |
17859 | 260 |
|
261 |
"Modified: / 29-08-2011 / 08:19:48 / cg" |
|
17734
406b1590afe8
Merged with trunk r10476
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17728
diff
changeset
|
262 |
! |
406b1590afe8
Merged with trunk r10476
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17728
diff
changeset
|
263 |
|
9332 | 264 |
directoryExists:dir |
265 |
"Squeak/ST80 compatibility" |
|
266 |
||
267 |
|f| |
|
268 |
||
269 |
f := self filenameFor:dir. |
|
270 |
^ f exists and:[f isDirectory ]. |
|
271 |
! |
|
272 |
||
7655 | 273 |
directoryNames |
9332 | 274 |
"Squeak/ST80 compatibility" |
7655 | 275 |
|
276 |
^ self directories |
|
277 |
! |
|
278 |
||
17728
bbc5fa73dfab
Merged with trunk r10466
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
279 |
entries |
17734
406b1590afe8
Merged with trunk r10476
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17728
diff
changeset
|
280 |
^ self contents collect:[:nm | self directoryEntryFor:nm]. |
17728
bbc5fa73dfab
Merged with trunk r10466
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
281 |
! |
bbc5fa73dfab
Merged with trunk r10466
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
282 |
|
9334 | 283 |
fileExists:dir |
284 |
"Squeak/ST80 compatibility" |
|
285 |
||
286 |
|f| |
|
287 |
||
288 |
f := self filenameFor:dir. |
|
289 |
^ f exists and:[f isDirectory not ]. |
|
290 |
! |
|
291 |
||
7655 | 292 |
fileNames |
9332 | 293 |
"Squeak/ST80 compatibility" |
7655 | 294 |
|
295 |
^ self files |
|
296 |
! |
|
297 |
||
17900 | 298 |
fileNamesMatching:pattern |
299 |
"Same as directoryContants, but returns only files |
|
300 |
that match the given pattern. |
|
301 |
This uses String>>matches: for glob pattern matching" |
|
302 |
||
303 |
| names | |
|
304 |
||
305 |
names := self asFilename directoryContents. |
|
306 |
names isNil ifTrue:[^ nil]. |
|
307 |
^ names select: [:e | e matches: pattern]. |
|
308 |
||
309 |
"Created: / 12-09-2010 / 18:41:09 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
310 |
"Modified (format): / 18-11-2011 / 14:45:42 / cg" |
|
311 |
! |
|
312 |
||
17728
bbc5fa73dfab
Merged with trunk r10466
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
313 |
forceNewFileNamed:fn |
bbc5fa73dfab
Merged with trunk r10466
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
314 |
"Squeak/ST80 compatibility" |
bbc5fa73dfab
Merged with trunk r10466
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
315 |
|
bbc5fa73dfab
Merged with trunk r10466
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
316 |
|f| |
bbc5fa73dfab
Merged with trunk r10466
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
317 |
|
bbc5fa73dfab
Merged with trunk r10466
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
318 |
f := self filenameFor:fn. |
bbc5fa73dfab
Merged with trunk r10466
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
319 |
^ f writeStream |
bbc5fa73dfab
Merged with trunk r10466
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
320 |
! |
bbc5fa73dfab
Merged with trunk r10466
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
321 |
|
7655 | 322 |
includesKey:name |
9332 | 323 |
"Squeak/ST80 compatibility" |
7655 | 324 |
|
325 |
^ self exists:name |
|
17728
bbc5fa73dfab
Merged with trunk r10466
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
326 |
! |
bbc5fa73dfab
Merged with trunk r10466
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
327 |
|
bbc5fa73dfab
Merged with trunk r10466
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
328 |
readOnlyFileNamed:fn |
bbc5fa73dfab
Merged with trunk r10466
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
329 |
"Squeak/ST80 compatibility" |
bbc5fa73dfab
Merged with trunk r10466
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
330 |
|
bbc5fa73dfab
Merged with trunk r10466
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
331 |
|f| |
bbc5fa73dfab
Merged with trunk r10466
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
332 |
|
bbc5fa73dfab
Merged with trunk r10466
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
333 |
f := self filenameFor:fn. |
bbc5fa73dfab
Merged with trunk r10466
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
334 |
^ f readStream |
bbc5fa73dfab
Merged with trunk r10466
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
335 |
! |
bbc5fa73dfab
Merged with trunk r10466
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
336 |
|
bbc5fa73dfab
Merged with trunk r10466
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
337 |
recursiveDelete |
bbc5fa73dfab
Merged with trunk r10466
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
338 |
self asFilename recursiveRemove |
7655 | 339 |
! ! |
7305 | 340 |
|
1 | 341 |
!FileDirectory methodsFor:'accessing'! |
342 |
||
343 |
baseName |
|
344 |
"return my baseName |
|
345 |
- thats the directory name without leading parent-dirs" |
|
346 |
||
347 |
lazy ifTrue:[self getFullPathName]. |
|
2921 | 348 |
^ pathName asFilename baseName |
1 | 349 |
! |
350 |
||
351 |
contents |
|
2708
6c4a4f30d540
skip '.' and '..' in #contents
Claus Gittinger <cg@exept.de>
parents:
2590
diff
changeset
|
352 |
"return a collection with all files and subdirectories in the receiver. |
6c4a4f30d540
skip '.' and '..' in #contents
Claus Gittinger <cg@exept.de>
parents:
2590
diff
changeset
|
353 |
Skips any '.' or '..' entries (UNIX)" |
1 | 354 |
|
355 |
|coll| |
|
356 |
||
357 |
coll := OrderedCollection new. |
|
358 |
self do:[:name | |
|
2708
6c4a4f30d540
skip '.' and '..' in #contents
Claus Gittinger <cg@exept.de>
parents:
2590
diff
changeset
|
359 |
name ~= '.' ifTrue:[ |
6c4a4f30d540
skip '.' and '..' in #contents
Claus Gittinger <cg@exept.de>
parents:
2590
diff
changeset
|
360 |
name ~= '..' ifTrue:[ |
6c4a4f30d540
skip '.' and '..' in #contents
Claus Gittinger <cg@exept.de>
parents:
2590
diff
changeset
|
361 |
coll add:name |
6c4a4f30d540
skip '.' and '..' in #contents
Claus Gittinger <cg@exept.de>
parents:
2590
diff
changeset
|
362 |
] |
6c4a4f30d540
skip '.' and '..' in #contents
Claus Gittinger <cg@exept.de>
parents:
2590
diff
changeset
|
363 |
] |
1 | 364 |
]. |
276 | 365 |
coll sort. |
1 | 366 |
^ coll |
2708
6c4a4f30d540
skip '.' and '..' in #contents
Claus Gittinger <cg@exept.de>
parents:
2590
diff
changeset
|
367 |
|
6c4a4f30d540
skip '.' and '..' in #contents
Claus Gittinger <cg@exept.de>
parents:
2590
diff
changeset
|
368 |
"Modified: 20.6.1997 / 17:05:43 / cg" |
1 | 369 |
! |
370 |
||
371 |
directories |
|
372 |
"return a collection with all subdirectories in the receiver directory" |
|
373 |
||
374 |
|coll| |
|
375 |
||
376 |
coll := OrderedCollection new. |
|
377 |
self directoriesDo:[:name | |
|
172 | 378 |
coll add:name |
1 | 379 |
]. |
276 | 380 |
coll sort. |
1 | 381 |
^ coll |
382 |
! |
|
383 |
||
605 | 384 |
directoryName |
385 |
"return my directoryName |
|
386 |
- thats the directory name where I'm in" |
|
387 |
||
388 |
lazy ifTrue:[self getFullPathName]. |
|
2921 | 389 |
^ pathName asFilename directoryName |
605 | 390 |
! |
391 |
||
1 | 392 |
files |
393 |
"return a collection with all plain files in the receiver directory" |
|
394 |
||
395 |
|coll| |
|
396 |
||
397 |
coll := OrderedCollection new. |
|
398 |
self filesDo:[:name | |
|
172 | 399 |
coll add:name |
1 | 400 |
]. |
276 | 401 |
coll sort. |
402 |
^ coll |
|
605 | 403 |
! |
404 |
||
405 |
pathName |
|
406 |
"return my full pathname" |
|
407 |
||
408 |
lazy ifTrue:[self getFullPathName]. |
|
409 |
^ pathName |
|
410 |
! |
|
411 |
||
412 |
pathName:dirName |
|
413 |
"set my pathname; return nil if not a valid path; self otherwise" |
|
414 |
||
415 |
pathName := dirName. |
|
416 |
(dirName startsWith:OperatingSystem fileSeparator) ifFalse:[ |
|
417 |
lazy := true |
|
418 |
] ifTrue:[ |
|
419 |
(dirName startsWith:'./') ifFalse:[ |
|
420 |
"/ (dirName includes:$.) ifTrue:[ |
|
421 |
lazy := true |
|
422 |
] |
|
423 |
]. |
|
424 |
^ self |
|
425 |
! ! |
|
426 |
||
427 |
!FileDirectory methodsFor:'basic'! |
|
428 |
||
429 |
createDirectory:newName |
|
430 |
"create a new filedirectory as a subdirectory of myself; |
|
431 |
return true if successful" |
|
432 |
||
433 |
|realName| |
|
434 |
||
435 |
(newName notNil and:[newName notEmpty]) ifTrue:[ |
|
436 |
(newName ~= '.' and:[newName ~= '..']) ifTrue:[ |
|
437 |
((newName at:1) == OperatingSystem fileSeparator) ifTrue:[ |
|
438 |
realName := newName copyFrom:2 |
|
439 |
] ifFalse:[ |
|
440 |
realName := newName |
|
441 |
]. |
|
2921 | 442 |
^ (self filenameFor:realName) makeDirectory |
605 | 443 |
] |
444 |
]. |
|
445 |
^ false |
|
446 |
! |
|
447 |
||
448 |
link:oldFileName to:newFileName |
|
449 |
"link oldFileName to newFileName in myself, return true if successful" |
|
450 |
||
451 |
|path1 path2| |
|
452 |
||
453 |
path1 := self pathNameOf:oldFileName. |
|
454 |
path2 := self pathNameOf:newFileName. |
|
455 |
^ OperatingSystem linkFile:path1 to:path2 |
|
456 |
! |
|
457 |
||
458 |
remove:aFileOrDirectoryName |
|
459 |
"remove the file or directory from myself; return true if successful" |
|
460 |
||
2921 | 461 |
^ (self filenameFor:aFileOrDirectoryName) remove |
605 | 462 |
! |
463 |
||
464 |
removeDirectory:dirName |
|
465 |
"remove the directory 'dirName' from myself; return true if successful. |
|
466 |
If the directory is not empty, the containing files/directories are also |
|
467 |
removed." |
|
468 |
||
2921 | 469 |
^ (self filenameFor:dirName) recursiveRemove |
605 | 470 |
! |
471 |
||
472 |
removeFile:fileName |
|
473 |
"remove the file 'fileName' from myself; return true if successful" |
|
474 |
||
2921 | 475 |
^ (self filenameFor:fileName) remove |
605 | 476 |
! |
477 |
||
478 |
renameFile:oldFileName newName:newFileName |
|
479 |
"rename the file; return true if successful" |
|
480 |
||
2921 | 481 |
|f1 f2| |
605 | 482 |
|
2921 | 483 |
f1 := self filenameFor:oldFileName. |
484 |
f2 := self filenameFor:newFileName. |
|
485 |
^ f1 renameTo:f2 |
|
1 | 486 |
! ! |
487 |
||
172 | 488 |
!FileDirectory methodsFor:'converting'! |
489 |
||
490 |
asFilename |
|
491 |
"return myself as a filename" |
|
492 |
||
493 |
^ self pathName asFilename |
|
494 |
! |
|
495 |
||
496 |
asFilename:someFile |
|
497 |
"return a filename for a file named someFile in myself" |
|
498 |
||
276 | 499 |
^ self asFilename construct:someFile |
172 | 500 |
! ! |
501 |
||
605 | 502 |
!FileDirectory methodsFor:'enumerating'! |
503 |
||
504 |
allDirectoriesDo:aBlock |
|
505 |
"evaluate the argument, aBlock for every directory name |
|
506 |
in the directory and in all subdirectories" |
|
507 |
||
508 |
|aStream command line| |
|
509 |
||
510 |
lazy ifTrue:[self getFullPathName]. |
|
511 |
command := 'cd ' , pathName , '; find . -type d -print'. |
|
512 |
aStream := PipeStream readingFrom:command. |
|
513 |
aStream isNil ifTrue:[^ nil]. |
|
514 |
[aStream atEnd] whileFalse:[ |
|
515 |
line := aStream nextLine. |
|
516 |
line notNil ifTrue:[ |
|
517 |
(line = '.') ifFalse:[ |
|
518 |
"cut off initial ./" |
|
519 |
line := line copyFrom:3 |
|
520 |
]. |
|
521 |
aBlock value:line |
|
522 |
] |
|
523 |
]. |
|
524 |
aStream close |
|
525 |
! |
|
526 |
||
527 |
allFilesDo:aBlock |
|
528 |
"evaluate the argument, aBlock for every file name in the directory and in all |
|
529 |
subdirectories" |
|
530 |
||
531 |
|aStream command line| |
|
532 |
||
533 |
lazy ifTrue:[self getFullPathName]. |
|
534 |
command := 'cd ' , pathName , '; find . -print'. |
|
535 |
aStream := PipeStream readingFrom:command. |
|
536 |
aStream isNil ifTrue:[^ nil]. |
|
537 |
[aStream atEnd] whileFalse:[ |
|
538 |
line := aStream nextLine. |
|
539 |
line notNil ifTrue:[ |
|
540 |
(line = '.') ifFalse:[ |
|
541 |
"cut off initial ./" |
|
542 |
line := line copyFrom:3 |
|
543 |
]. |
|
544 |
aBlock value:line |
|
545 |
] |
|
546 |
]. |
|
547 |
aStream close |
|
548 |
! |
|
549 |
||
550 |
directoriesDo:aBlock |
|
551 |
"evaluate the argument, aBlock for every subdirectory name in the directory" |
|
552 |
||
553 |
self where:[:name | (self isDirectory:name) ifTrue:[ |
|
554 |
((name ~= '.') and:[name ~= '..']) |
|
555 |
] ifFalse:[ |
|
556 |
false |
|
557 |
] |
|
558 |
] do:aBlock |
|
559 |
! |
|
560 |
||
561 |
do:aBlock |
|
562 |
"evaluate the argument, aBlock for every name in the directory" |
|
563 |
||
564 |
self where:[:name | true] do:aBlock |
|
565 |
! |
|
566 |
||
567 |
filesDo:aBlock |
|
568 |
"evaluate the argument, aBlock for every plain file name in the directory" |
|
569 |
||
570 |
self where:[:name | (self isDirectory:name) not] do:aBlock |
|
571 |
! |
|
572 |
||
573 |
namesDo:aBlock |
|
574 |
"evaluate the argument, aBlock for every name in the directory. |
|
575 |
for ST-80 compatibility" |
|
576 |
||
577 |
self do:aBlock |
|
578 |
! |
|
579 |
||
580 |
where:testBlock do:aBlock |
|
581 |
"evaluate the argument, aBlock for every object in the directory |
|
582 |
for which testBlock evaluates to true." |
|
583 |
||
584 |
|aStream name| |
|
585 |
||
7655 | 586 |
ExternalStream openErrorSignal catch:[ |
587 |
aStream := DirectoryStream directoryNamed:pathName. |
|
588 |
]. |
|
605 | 589 |
aStream isNil ifTrue:[^ nil]. |
590 |
[aStream atEnd] whileFalse:[ |
|
7655 | 591 |
name := aStream nextLine. |
592 |
name notNil ifTrue:[ |
|
593 |
(testBlock value:name) ifTrue:[ |
|
594 |
aBlock value:name |
|
595 |
] |
|
596 |
] |
|
605 | 597 |
]. |
598 |
aStream close |
|
599 |
! ! |
|
600 |
||
601 |
!FileDirectory methodsFor:'more instance creation'! |
|
602 |
||
603 |
directoryNamed:aName |
|
2961 | 604 |
"create & return a new fileDirectory for a subdirectory in myself" |
605 |
||
605 | 606 |
^ self class directoryNamed:aName in:self pathName |
607 |
! ! |
|
608 |
||
609 |
!FileDirectory methodsFor:'printing & storing'! |
|
610 |
||
611 |
printOn:aStream |
|
4392 | 612 |
"append a user printed representation of the receiver to aStream. |
613 |
The format is suitable for a human - not meant to be read back." |
|
605 | 614 |
|
615 |
lazy ifTrue:[self getFullPathName]. |
|
616 |
aStream nextPutAll:'(a FileDirectory pathName:'; |
|
4392 | 617 |
nextPutAll:pathName; |
618 |
nextPutAll:')' |
|
605 | 619 |
! |
620 |
||
621 |
storeOn:aStream |
|
622 |
"append a printed representation of the receiver to aStream, |
|
623 |
which allows reconstructing it via readFrom:" |
|
624 |
||
625 |
lazy ifTrue:[self getFullPathName]. |
|
626 |
aStream nextPutAll:'(FileDirectory directoryNamed:'. |
|
627 |
aStream nextPutAll:pathName. |
|
628 |
aStream nextPut:$) |
|
629 |
! ! |
|
630 |
||
1 | 631 |
!FileDirectory methodsFor:'private'! |
632 |
||
3201
4e72e420fdc3
Documentation: FileDirectory is obsolete and works only under Unix.
Stefan Vogel <sv@exept.de>
parents:
2961
diff
changeset
|
633 |
filenameFor:fileName |
6972
0a2f38d186d5
filenameFor: same algorithm found in Filename
Claus Gittinger <cg@exept.de>
parents:
6550
diff
changeset
|
634 |
"return a filename representing the argument, fileName |
0a2f38d186d5
filenameFor: same algorithm found in Filename
Claus Gittinger <cg@exept.de>
parents:
6550
diff
changeset
|
635 |
either in myself (if the arg is a releative path) or absolute otherwise." |
3201
4e72e420fdc3
Documentation: FileDirectory is obsolete and works only under Unix.
Stefan Vogel <sv@exept.de>
parents:
2961
diff
changeset
|
636 |
|
6972
0a2f38d186d5
filenameFor: same algorithm found in Filename
Claus Gittinger <cg@exept.de>
parents:
6550
diff
changeset
|
637 |
^ pathName asFilename filenameFor:fileName |
3201
4e72e420fdc3
Documentation: FileDirectory is obsolete and works only under Unix.
Stefan Vogel <sv@exept.de>
parents:
2961
diff
changeset
|
638 |
! |
4e72e420fdc3
Documentation: FileDirectory is obsolete and works only under Unix.
Stefan Vogel <sv@exept.de>
parents:
2961
diff
changeset
|
639 |
|
9334 | 640 |
fullNameFor:fileName |
641 |
"return a filename representing the argument, fileName |
|
642 |
either in myself (if the arg is a releative path) or absolute otherwise." |
|
643 |
||
644 |
^ (pathName asFilename filenameFor:fileName) asAbsoluteFilename |
|
645 |
! |
|
646 |
||
1 | 647 |
getFullPathName |
648 |
"make my pathname be a full pathname - i.e. starting at root" |
|
649 |
||
308 | 650 |
|shortPathName| |
1 | 651 |
|
2921 | 652 |
|
159 | 653 |
(pathName = OperatingSystem fileSeparator asString) ifTrue:[ |
172 | 654 |
lazy := false. |
655 |
^ self |
|
1 | 656 |
]. |
657 |
||
658 |
"since currentDirectory is used very often, cache its path here" |
|
659 |
||
660 |
(pathName = '.') ifTrue:[ |
|
172 | 661 |
PathOfCurrentDirectory notNil ifTrue:[ |
662 |
pathName := PathOfCurrentDirectory. |
|
663 |
lazy := false. |
|
664 |
^ self |
|
665 |
] |
|
1 | 666 |
]. |
667 |
||
668 |
shortPathName := pathName. |
|
669 |
||
308 | 670 |
pathName := OperatingSystem pathNameOf:pathName. |
671 |
lazy := false. |
|
1 | 672 |
|
308 | 673 |
" |
674 |
if it was the current dir, keep name for next query |
|
675 |
" |
|
1 | 676 |
(shortPathName = '.') ifTrue:[ |
308 | 677 |
PathOfCurrentDirectory := pathName |
1 | 678 |
] |
276 | 679 |
! |
680 |
||
681 |
pathNameOf:fileName |
|
2961 | 682 |
"return the pathname for an entry in myself" |
683 |
||
2921 | 684 |
^ (pathName asFilename construct:fileName) osName |
1 | 685 |
! ! |
686 |
||
605 | 687 |
!FileDirectory methodsFor:'queries'! |
1 | 688 |
|
605 | 689 |
accessModeOf:name |
690 |
"return the access-mode bits (rwxrwxrwx) of a file in myself" |
|
1 | 691 |
|
605 | 692 |
^ OperatingSystem accessModeOf:(self pathNameOf:name) |
1 | 693 |
! |
694 |
||
605 | 695 |
changeAccessModeOf:name to:modeBits |
696 |
"set the access-mode bits (rwxrwxrwx) of a file in myself" |
|
1 | 697 |
|
605 | 698 |
^ OperatingSystem changeAccessModeOf:(self pathNameOf:name) to:modeBits |
1 | 699 |
! |
700 |
||
701 |
exists |
|
702 |
"return true if this directory exists" |
|
703 |
||
2921 | 704 |
^ (Filename named:pathName) isDirectory |
159 | 705 |
|
706 |
" |
|
707 |
(FileDirectory directoryNamed:'fooBar') exists |
|
708 |
(FileDirectory directoryNamed:'/tmp') exists |
|
709 |
" |
|
1 | 710 |
! |
711 |
||
605 | 712 |
exists:name |
713 |
"return true, if the given name exists in myself" |
|
714 |
||
2921 | 715 |
^ (self filenameFor:name) exists |
605 | 716 |
! |
717 |
||
718 |
id |
|
719 |
"return the directories file-id (inode number)" |
|
720 |
||
2921 | 721 |
^ (Filename named:pathName) id |
605 | 722 |
! |
723 |
||
724 |
infoOf:name |
|
725 |
"return an array filled with file info for the file 'aFileName'; |
|
726 |
return nil if such a file does not exist" |
|
727 |
||
2921 | 728 |
^ (self filenameFor:name) info |
605 | 729 |
! |
730 |
||
731 |
isDirectory:name |
|
732 |
"return true, if the given name is that of a directory in myself" |
|
733 |
||
2921 | 734 |
^ (self filenameFor:name) isDirectory |
605 | 735 |
! |
736 |
||
737 |
isExecutable:name |
|
738 |
"return true, if the given file is executable" |
|
1 | 739 |
|
2921 | 740 |
^ (self filenameFor:name) isExecutable |
1 | 741 |
! |
742 |
||
743 |
isReadable:name |
|
744 |
"return true, if the given file is readable" |
|
745 |
||
2921 | 746 |
^ (self filenameFor:name) isReadable |
1 | 747 |
! |
748 |
||
749 |
isWritable:name |
|
750 |
"return true, if the given file is readable" |
|
751 |
||
2921 | 752 |
^ (self filenameFor:name) isWritable |
1 | 753 |
! |
754 |
||
605 | 755 |
species |
6550 | 756 |
"return the type of collection to be returned by collect, select etc." |
757 |
||
605 | 758 |
^ OrderedCollection |
1 | 759 |
! |
760 |
||
605 | 761 |
timeOfLastChange |
762 |
"return the timeStamp of myself" |
|
1 | 763 |
|
2921 | 764 |
^ (Filename named:pathName) modificationTime |
1 | 765 |
! |
766 |
||
605 | 767 |
timeOfLastChange:name |
768 |
"return the timeStamp of a file in myself" |
|
1 | 769 |
|
2921 | 770 |
^ (self filenameFor:name) modificationTime |
1 | 771 |
! |
772 |
||
605 | 773 |
typeOf:name |
774 |
"return the symbolic type of a file in myself" |
|
1 | 775 |
|
2921 | 776 |
^ (self filenameFor:name) type |
605 | 777 |
! ! |
1 | 778 |
|
5556 | 779 |
!FileDirectory methodsFor:'testing'! |
780 |
||
781 |
isEmpty |
|
782 |
"return true, if the directory is empty; |
|
783 |
redefined since '.' and '..' do not count as entries here." |
|
784 |
||
785 |
self do:[:fName | |
|
786 |
((fName ~= '.') and:[fName ~= '..']) ifTrue:[^ false]. |
|
787 |
]. |
|
788 |
^ true |
|
789 |
! ! |
|
790 |
||
17734
406b1590afe8
Merged with trunk r10476
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17728
diff
changeset
|
791 |
!FileDirectory::DirectoryEntry methodsFor:'accessing'! |
406b1590afe8
Merged with trunk r10476
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17728
diff
changeset
|
792 |
|
406b1590afe8
Merged with trunk r10476
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17728
diff
changeset
|
793 |
at: index |
406b1590afe8
Merged with trunk r10476
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17728
diff
changeset
|
794 |
"compatibility interface" |
406b1590afe8
Merged with trunk r10476
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17728
diff
changeset
|
795 |
"self halt: 'old-style access to DirectoryEntry'" |
406b1590afe8
Merged with trunk r10476
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17728
diff
changeset
|
796 |
index = 1 ifTrue: [ ^self name ]. |
406b1590afe8
Merged with trunk r10476
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17728
diff
changeset
|
797 |
index = 2 ifTrue: [ ^self creationTime ]. |
406b1590afe8
Merged with trunk r10476
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17728
diff
changeset
|
798 |
index = 3 ifTrue: [ ^self modificationTime ]. |
406b1590afe8
Merged with trunk r10476
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17728
diff
changeset
|
799 |
index = 4 ifTrue:[ ^self isDirectory ]. |
406b1590afe8
Merged with trunk r10476
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17728
diff
changeset
|
800 |
index = 5 ifTrue:[ ^self fileSize ]. |
406b1590afe8
Merged with trunk r10476
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17728
diff
changeset
|
801 |
self error: 'invalid index specified'. |
406b1590afe8
Merged with trunk r10476
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17728
diff
changeset
|
802 |
! |
406b1590afe8
Merged with trunk r10476
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17728
diff
changeset
|
803 |
|
406b1590afe8
Merged with trunk r10476
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17728
diff
changeset
|
804 |
creationTime |
406b1590afe8
Merged with trunk r10476
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17728
diff
changeset
|
805 |
^ creationTime |
406b1590afe8
Merged with trunk r10476
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17728
diff
changeset
|
806 |
! |
406b1590afe8
Merged with trunk r10476
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17728
diff
changeset
|
807 |
|
406b1590afe8
Merged with trunk r10476
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17728
diff
changeset
|
808 |
dirFlag |
406b1590afe8
Merged with trunk r10476
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17728
diff
changeset
|
809 |
^ dirFlag |
406b1590afe8
Merged with trunk r10476
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17728
diff
changeset
|
810 |
! |
406b1590afe8
Merged with trunk r10476
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17728
diff
changeset
|
811 |
|
406b1590afe8
Merged with trunk r10476
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17728
diff
changeset
|
812 |
fileSize |
406b1590afe8
Merged with trunk r10476
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17728
diff
changeset
|
813 |
^ fileSize |
406b1590afe8
Merged with trunk r10476
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17728
diff
changeset
|
814 |
! |
406b1590afe8
Merged with trunk r10476
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17728
diff
changeset
|
815 |
|
406b1590afe8
Merged with trunk r10476
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17728
diff
changeset
|
816 |
modificationTime |
406b1590afe8
Merged with trunk r10476
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17728
diff
changeset
|
817 |
^ modificationTime |
406b1590afe8
Merged with trunk r10476
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17728
diff
changeset
|
818 |
! |
406b1590afe8
Merged with trunk r10476
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17728
diff
changeset
|
819 |
|
406b1590afe8
Merged with trunk r10476
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17728
diff
changeset
|
820 |
name |
406b1590afe8
Merged with trunk r10476
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17728
diff
changeset
|
821 |
^ name |
406b1590afe8
Merged with trunk r10476
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17728
diff
changeset
|
822 |
! |
406b1590afe8
Merged with trunk r10476
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17728
diff
changeset
|
823 |
|
406b1590afe8
Merged with trunk r10476
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17728
diff
changeset
|
824 |
name:nameArg creationTime:creationTimeArg modificationTime:modificationTimeArg dirFlag:dirFlagArg fileSize:fileSizeArg |
406b1590afe8
Merged with trunk r10476
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17728
diff
changeset
|
825 |
name := nameArg. |
406b1590afe8
Merged with trunk r10476
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17728
diff
changeset
|
826 |
creationTime := creationTimeArg. |
406b1590afe8
Merged with trunk r10476
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17728
diff
changeset
|
827 |
modificationTime := modificationTimeArg. |
406b1590afe8
Merged with trunk r10476
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17728
diff
changeset
|
828 |
dirFlag := dirFlagArg. |
406b1590afe8
Merged with trunk r10476
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17728
diff
changeset
|
829 |
fileSize := fileSizeArg. |
406b1590afe8
Merged with trunk r10476
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17728
diff
changeset
|
830 |
! ! |
406b1590afe8
Merged with trunk r10476
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17728
diff
changeset
|
831 |
|
629 | 832 |
!FileDirectory class methodsFor:'documentation'! |
833 |
||
834 |
version |
|
17900 | 835 |
^ '$Header: /cvs/stx/stx/libbasic/FileDirectory.st,v 1.52 2011/11/24 17:29:22 cg Exp $' |
17734
406b1590afe8
Merged with trunk r10476
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17728
diff
changeset
|
836 |
! |
406b1590afe8
Merged with trunk r10476
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17728
diff
changeset
|
837 |
|
406b1590afe8
Merged with trunk r10476
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17728
diff
changeset
|
838 |
version_CVS |
17900 | 839 |
^ 'Header: /cvs/stx/stx/libbasic/FileDirectory.st,v 1.52 2011/11/24 17:29:22 cg Exp ' |
17865 | 840 |
! |
841 |
||
842 |
version_SVN |
|
17900 | 843 |
^ '$Id: FileDirectory.st 10741 2011-11-26 08:36:46Z vranyj1 $' |
629 | 844 |
! ! |
6972
0a2f38d186d5
filenameFor: same algorithm found in Filename
Claus Gittinger <cg@exept.de>
parents:
6550
diff
changeset
|
845 |
|
17846 | 846 |
FileDirectory initialize! |
17892 | 847 |
|
17900 | 848 |