help-smalltalk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Help-smalltalk] Re: walking a directory tree


From: Sean Allen
Subject: [Help-smalltalk] Re: walking a directory tree
Date: Sat, 10 Jan 2009 11:44:04 -0500

when i try to apply this patch, it gets rejected.

i did by hand and i got the blox building errors.

i tried on a git master copy. same issues.

On Jan 9, 2009, at 4:09 AM, Paolo Bonzini wrote:

diff --git a/kernel/FilePath.st b/kernel/FilePath.st
index 54a14dc..f35156e 100644
--- a/kernel/FilePath.st
+++ b/kernel/FilePath.st
@@ -736,7 +736,10 @@ size and timestamps.'>

    all [
        "Return a decorator of the receiver that will provide recursive
-        descent into directories for iteration methods."
+        descent into directories for iteration methods.  Furthermore,
+        iteration on the returned wrapper will not include '.' or '..'
+        directory entries, and will include the receiver (directly, not
+        via '.')."

        <category: 'decoration'>
        ^Kernel.RecursiveFileWrapper on: self
@@ -813,7 +816,9 @@ size and timestamps.'>

    do: aBlock [
"Evaluate aBlock once for each file in the directory represented by the
-        receiver, passing its name."
+ receiver, passing a FilePath object (or a subclass) to it. It depends
+        on the subclass whether iteration will include the '.' and '..'
+        directory entries."

        <category: 'enumerating'>
        self namesDo: [ :name |
@@ -822,7 +827,8 @@ size and timestamps.'>

    namesDo: aBlock [
"Evaluate aBlock once for each file in the directory represented by the
-        receiver, passing its name."
+        receiver, passing its name.  It depends on the subclass whether
+        iteration will include the '.' and '..'  directory entries."

        <category: 'enumerating'>
        self subclassResponsibility
diff --git a/kernel/VFS.st b/kernel/VFS.st
index 9a01b02..d344a04 100644
--- a/kernel/VFS.st
+++ b/kernel/VFS.st
@@ -352,15 +352,16 @@ VFS.FileWrapper subclass: RecursiveFileWrapper [
"Same as the wrapped #do:, but reuses the file object for efficiency."

        <category: 'enumerating'>
+       aBlock value: self file.
        self file namesDo:
                [:name |
-                | f |
-                f := self at: name.
-                aBlock value: f.
-                f isDirectory
-                    ifTrue:
- [((#('.' '..') includes: name) or: [f isSymbolicLink])
-                            ifFalse: [f do: aBlock]]]
+                | f period |
+               period := #('.' '..') includes: name.
+                period ifFalse: [
+                   f := self at: name.
+                   aBlock value: f file.
+                   (f isDirectory and: [f isSymbolicLink not])
+                        ifTrue: [f do: aBlock]]]
     ]

     namesDo: aBlock prefixLength: anInteger [
@@ -371,15 +372,15 @@ VFS.FileWrapper subclass: RecursiveFileWrapper [
        <category: 'private'>
        self file namesDo:
                [:name |
-                | f |
-                f := self at: name.
-                aBlock value: (f asString copyFrom: anInteger).
-                f isDirectory
-                    ifTrue:
- [((#('.' '..') includes: name) or: [f isSymbolicLink])
-                            ifFalse: [f
-                               namesDo: aBlock
-                               prefixLength: anInteger ]]]
+                | f period |
+               period := #('.' '..') includes: name.
+                period ifFalse: [
+                   f := self at: name.
+                    aBlock value: (f asString copyFrom: anInteger).
+                   (f isDirectory and: [f isSymbolicLink not])
+                        ifTrue: [f
+                           namesDo: aBlock
+                           prefixLength: anInteger ]]]
     ]

     namesDo: aBlock [
@@ -387,6 +388,7 @@ VFS.FileWrapper subclass: RecursiveFileWrapper [
         tree recursively."

        <category: 'enumerating'>
+       aBlock value: '.'.
        self namesDo: aBlock prefixLength: self asString size + 2
     ]

@@ -422,7 +424,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 +436,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 +447,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 +460,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 ]) ] ]
    ]





reply via email to

[Prev in Thread] Current Thread [Next in Thread]