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

Re: [MacPerl] FSpIterateDirectory not working?



At 5:29 PM -0700 2/24/98, Jim Burton wrote:
>#!/usr/bin/perl
>
>#walker!
>
>use Mac::MoreFiles;
>FSpIterateDirectory (":",0,DoThis,dummy);
>print "\nFinished\n\n";
>
>sub DoThis {
> print "Information returned: @_\n";
>	}
>-----
>
>This should return the filename of all files and folders (and files
>within subfolders) inside the current directory. It runs without error
>messages, but it seems to return information only about the first file in
>the current directory. All other files are ignored.
>
>I see in the archives that Aaron Munter asked about FSpIterateDirectory
>back in April 1997, but it appears he never got an answer!

The function needs to return 0; returning a non-zero value stops the iteration.

Try:

#!perl

use Mac::MoreFiles;

FSpIterateDirectory(":", 0, DoThis, "Information returned: ");

sub DoThis {
	print $_[1], $_[0], "\n";
	return 0;
}

I found this out by looking at the Shuck documentation and looking at the
Iterate.t file.

Note that the documentation is wrong: the function is not called as

    $quit = &$filterFunction(YOURDATAPTR, SPEC);

but as

    $quit = &$filterFunction(SPEC, YOURDATAPTR);

 - Tim

Tim Dierks - Software Haruspex - tim@dierks.org
 "Well, cyberterrorists may be difficult to capture in the act, but from what I
  know about people who are highly skilled with computers, they should be easy
  to beat up." - Ernest Cey, quoted in The Onion, <http://www.theonion.com>



***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch