[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Help-smalltalk] Re: similar Directory methods, different behavior (was
From: |
Stephen Compall |
Subject: |
[Help-smalltalk] Re: similar Directory methods, different behavior (was (no subject)) |
Date: |
Tue, 09 Jan 2007 01:53:31 -0600 |
On Mon, 2007-01-08 at 23:03 -0700, J Pfersich wrote:
> I have a question about the behavior of two methods in Directory.
> I get this from filesMatching:
> st> var2 filesMatching: 'test*' do: [:file | ( file name) display.
> st> ', ' display.
> st> file printNl ] !
> /Users/johnp/projects/smalltalk/gnu/test.st, a File
> /Users/johnp/projects/smalltalk/gnu/testing, a Directory
> /Users/johnp/projects/smalltalk/gnu/testing3, a Directory
>
> and I get this from allFilesMatching:
> var2 allFilesMatching: 'test*' do: [:file | (file name) display.
> st> ', ' display.
> st> file printNl] !
> /Users/johnp/projects/smalltalk/gnu/test.st, a File
> /Users/johnp/projects/smalltalk/gnu/testing3/testing3-file, a File
> /Users/johnp/projects/smalltalk/gnu/testing3/testing3-file-2, a File
>
> Shouldn't they produce the same objects? I mean either all files and
> directories or just files?
The first one is correct; after all, a Directory is a File, and those
directories are "in" .../gnu/. allFilesMatching:do: does seem like it
should call its block with a superset of those found by
filesMatching:do:, though.
Attached is a patch that implements this behavior by modifying
Directory>>allFilesMatching:do:.
--
Stephen Compall
http://scompall.nocandysw.com/blog
afmdo-like-fmdo.diff
Description: Text Data
signature.asc
Description: This is a digitally signed message part