(no subject)

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

(no subject)

J Pfersich
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?



_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: (no subject)

Paolo Bonzini

> 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

This one does not descend into directories, and returns files or
directories that match 'test*'.

> 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

This one descends into directories (not symlinks to directories)
irrespective of whether they match 'test*', and returns file in those
directories that match 'test*'.

If the method comment is not helpful, please propose an alternative wording.

Paolo


_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: similar Directory methods, different behavior (was (no subject))

S11001001
In reply to this post by J Pfersich
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

_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk

afmdo-like-fmdo.diff (866 bytes) Download Attachment
signature.asc (196 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Re: similar Directory methods, different behavior (was (no subject))

Paolo Bonzini

> 2007-01-09  Stephen Compall  <[hidden email]>
>
> * kernel/Directory.st (allFilesMatching:do:): Pass Directory
> entries to aBlock if they match aPattern.

I have no problems with this patch if there's consensus that this
behavior is better.  Actually, unless somebody stands up, I'll apply it
in a couple of days.

Thanks,

Paolo


_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: Re: similar Directory methods, different behavior (was (no subject))

Mike Anderson-3
Paolo Bonzini wrote:
>
>> 2007-01-09  Stephen Compall  <[hidden email]>
>>
>>     * kernel/Directory.st (allFilesMatching:do:): Pass Directory
>>     entries to aBlock if they match aPattern.
>
> I have no problems with this patch if there's consensus that this
> behavior is better.  Actually, unless somebody stands up, I'll apply it
> in a couple of days.

It gets my vote.

Mike


_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk