tags:

views:

123

answers:

2

If I run the Find module with a relative directory as a parameter, the files returned by it will be relative ones. Can I do anything to make sure I always have absolute paths ?

require "find"

Find.find(dir) do |file|
  # do I need to make it absolute myself? will File#extend_path be enough?
end
+2  A: 

Yes, expand_path will do it.

require 'find'
Find.find(dir) {|file| puts File.expand_path(file)}
Greg Campbell
+4  A: 
require 'find'
Find.find(File.expand_path(dir))

also seems to work.

giorgian
This is actually better than my solution, since it only calls expand_path once, as opposed to once per file.
Greg Campbell