Test if file exists

Hi,

Look at this :

if (ARGV.size != 2)
puts ‘usage: ./compare file1 file2’

else
filename1 = ARGV[0]
filename2 = ARGV[1]


How would I test if the arguments given (filename1 and 2) are actually
files
that exist?

Thanks.

On 5/15/06, Pieter S. [email protected] wrote:

Hi,

Hi,

[…]

How would I test if the arguments given (filename1 and 2) are actually files
that exist?

File.exists?(filename1)

or

require ‘pathname’
Pathname.new(filename1).exists?

File.exists?(file_name)

Thanks alot!

That’s so simple, hehe!