"Thomas R. Kimpton" <tkimpton@maned.com> writes: }Oops sent a version of this, before it was done, to Strider, }via email... here's what I wound up with: } }use Mac::Files; } }$dir = "Internal:temp"; }chdir $dir || die "Can't chdir $dir : $!"; }&readDir( $dir ); } }sub readDir (){ } local($path) = @_; } local($i); } local($fil); } opendir( DIR, $path ) || die "Can't open $path : $!"; } local(@fileList) = readdir( DIR ); } closedir( DIR ); } } # Unless you change $[, Perl arrays are zero based... } # $# is the index of the last item in the array, so } # we need to add 1 to get the size of the array. } $numFiles += $#fileList + 1; which you can also get by $numFiles = @fileList; } for ($i = 0; $i <= $#fileList; $i++) { } $fil = "$path:$fileList[$i]"; One bizzare thing that can happen is that you can run across a file whose name is "" (the null string). Stuffit Expander used to have a habit of making these. Maybe a "next unless $fileList[$i];" is a good idea right about here. } @info = stat($fil); }# print "$fil($fileList[$i]) $info[2]\n"; } $has = FSpGetCatInfo($fil); } # remember: directories are files, also... just special } # ones that contain overhead, add them in to the }size also. } $total += $has->{ioFlLgLen} + $has->{ioFlRLgLen}; } # physical size is how many blocks (in bytes) the }file takes } # up and will be different on different sized }volumnes. HFS } # doesn't do frags (though, you'd still have a physical } # size > logical size with frags.) } $totalPhys += $has->{ioFlPyLen} + $has->{ioFlRPyLen}; } # file tests with '_' use the result of the last stat call. } if(-d _) { I think you'd better also put a if (! -l _ && -d _) here, because I believe aliases to folders answer true to -d. If you have an alias in the wrong place, you can find yourself looping forever. } &readDir( "$fil" ); } } } } }} }print "$numFiles for $total(logical) bytes, $totalPhys(physical) bytes\n"; } }Tom Kimpton }-- }Mrs. Bun: Have you got anything without spam? }Waitress: Well, there's spam egg sausage and spam, that's not got }much spam in it. }Mrs. Bun: I don't want any spam! } } } --- Paul J. Schinder NASA Goddard Space Flight Center Code 693, Greenbelt, MD 20771 schinder@pjstoaster.pg.md.us ***** Want to unsubscribe from this list? ***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch