How to return path when doing directory recursion?

All-

Recently Matz (thanks too, Chris) advised me to use the code below to read files in directories/subdirectories recursively.

A related question: In the “do_stuff_here” part of the for loop, is there a function I can call that will return the path of the file being read?

Thanks!

-Kurt

for f in Dir.glob("./some_directory/**/*")
File.open(f) { |file|
do_stuff_here
} if File.file?(f)
end

Isn’t it f?

···

On Fri, Aug 30, 2002 at 01:18:00AM +0900, Kurt Euler wrote:

All-

Recently Matz (thanks too, Chris) advised me to use the code below to read files in directories/subdirectories recursively.

A related question: In the “do_stuff_here” part of the for loop, is there a function I can call that will return the path of the file being read?

Thanks!

-Kurt

for f in Dir.glob(“./some_directory/**/*”)
File.open(f) { |file|
do_stuff_here
} if File.file?(f)
end


Alan Chen
Digikata LLC
http://digikata.com