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.

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?

···

On 5/15/06, Pieter Steyn <pieter@clue.co.za> wrote:

--
Nicolas Desprès

File.exists?(file_name)

Thanks alot!

That's so simple, hehe!

···

On Monday 15 May 2006 10:11, Nicolas Desprès wrote:

On 5/15/06, Pieter Steyn <pieter@clue.co.za> 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?