[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-smalltalk] walking a directory tree
From: |
Paolo Bonzini |
Subject: |
Re: [Help-smalltalk] walking a directory tree |
Date: |
Fri, 09 Jan 2009 09:58:15 +0100 |
User-agent: |
Thunderbird 2.0.0.19 (Macintosh/20081209) |
> if i do:
> file := File name: '/Users/Spooneybarger'
> file all do: [ :e | e isDirectory ifTrue: [ e directories printNl ] ]
>
> i get no output other than: "Global garbage collection... done, heap grown"
> over and over and over
The problem here is that every file that you get in "file all do:" is in
turn a RecursiveFileWrapper. In other words what you wanted was just
file all directories do: [ :each | each printNl ]
(try "file all directories").
I'm wondering whether this is totally counter-intuitive though. After
all, you're already doing a recursive visit, so it makes sense to get
the original files (it may make sense for other kinds of wrapper, but
probably not for RecursiveFileWrapper).
The attached patch fixes the above misfeature.
> i'm really just playing around right now. shouldnt i get output from the
>
> ifTrue: [ e directories printNl ]
>
> does the fact that I'm not mean that I have a messed up build?
No.
>> Thanks for your work again, every stumbling of yours will
>> make GST a better product for others to learn.
>
> I would call my stumblings work, but you are welcome nonetheless.
Your stumblings so far were mostly my fault, if it makes my intention
clearer. :-)
Paolo
diff --git a/kernel/VFS.st b/kernel/VFS.st
index 9a01b02..a472258 100644
--- a/kernel/VFS.st
+++ b/kernel/VFS.st
@@ -356,7 +356,7 @@ VFS.FileWrapper subclass: RecursiveFileWrapper [
[:name |
| f |
f := self at: name.
- aBlock value: f.
+ aBlock value: f file.
f isDirectory
ifTrue:
[((#('.' '..') includes: name) or: [f isSymbolicLink])
@@ -422,7 +422,7 @@ VFS.FileWrapper subclass: RecursiveFileWrapper [
self isDirectory ifFalse: [
^super lastAccessTime: accessDateTime lastModifyTime:
modifyDateTime ].
self do: [ :each |
- each file lastAccessTime: accessDateTime lastModifyTime:
modifyDateTime ]
+ each lastAccessTime: accessDateTime lastModifyTime: modifyDateTime ]
]
owner: ownerString group: groupString [
@@ -434,7 +434,7 @@ VFS.FileWrapper subclass: RecursiveFileWrapper [
"These special calls cache the uid and gid to avoid repeated lookups."
[
File setOwnerFor: nil owner: ownerString group: groupString.
- self do: [ :each | each file owner: ownerString group: groupString
]
+ self do: [ :each | each owner: ownerString group: groupString ]
] ensure: [ File setOwnerFor: nil owner: nil group: nil ]
]
@@ -445,8 +445,7 @@ VFS.FileWrapper subclass: RecursiveFileWrapper [
<category: 'accessing'>
self isDirectory ifFalse: [ ^super mode: anInteger ].
- self do: [ :each |
- each isDirectory ifFalse: [ each file mode: anInteger ] ]
+ self do: [ :each | each isDirectory ifFalse: [ each mode: anInteger ] ]
]
fileMode: fMode directoryMode: dMode [
@@ -459,8 +458,7 @@ VFS.FileWrapper subclass: RecursiveFileWrapper [
super mode: dMode.
self isDirectory ifTrue: [
self do: [ :each |
- each file
- mode: (each isDirectory
+ each mode: (each isDirectory
ifTrue: [ dMode ]
ifFalse: [ fMode ]) ] ]
]
- [Help-smalltalk] walking a directory tree, Sean Allen, 2009/01/08
- Re: [Help-smalltalk] walking a directory tree, Paolo Bonzini, 2009/01/09
- Re: [Help-smalltalk] walking a directory tree, Sean Allen, 2009/01/09
- Re: [Help-smalltalk] walking a directory tree,
Paolo Bonzini <=
- [Help-smalltalk] Re: walking a directory tree, Paolo Bonzini, 2009/01/09
- [Help-smalltalk] Re: walking a directory tree, Sean Allen, 2009/01/10
- [Help-smalltalk] Re: walking a directory tree, Paolo Bonzini, 2009/01/11
- [Help-smalltalk] Re: walking a directory tree, Sean Allen, 2009/01/11
- [Help-smalltalk] Re: walking a directory tree, Paolo Bonzini, 2009/01/11
- [Help-smalltalk] Re: walking a directory tree, Paolo Bonzini, 2009/01/12
- [Help-smalltalk] Re: walking a directory tree, Sean Allen, 2009/01/12
- [Help-smalltalk] Re: walking a directory tree, Paolo Bonzini, 2009/01/12
- [Help-smalltalk] Re: walking a directory tree, Sean Allen, 2009/01/12
- Re: [Help-smalltalk] walking a directory tree, Sean Allen, 2009/01/09