Replace Dir.exists by File.directory for Ruby 1.8 compatibility