Best way to test for file existence?

All,

What is the best way to determine the existence of a file (more
specifically, a directory)?

Are there Perl - like file test operators available?

Wes

···

--
Posted via http://www.ruby-forum.com/.

File.exist?

Sorry to waste time.

Wes Gamble wrote:

···

All,

What is the best way to determine the existence of a file (more
specifically, a directory)?

Are there Perl - like file test operators available?

Wes

--
Posted via http://www.ruby-forum.com/\.

Wes Gamble wrote:

All,

What is the best way to determine the existence of a file (more
specifically, a directory)?

Are there Perl - like file test operators available?

Wes

$ ri test | cat
------------------------------------------------------------ Kernel#test
     test(int_cmd, file1 [, file2] ) => obj

···

------------------------------------------------------------------------
      Uses the integer <em>aCmd</em> to perform various tests on
      <em>file1</em> (first table below) or on <em>file1</em> and
      <em>file2</em> (second table).

      File tests on a single file:

        Test Returns Meaning
         ?A | Time | Last access time for file1
         ?b | boolean | True if file1 is a block device
         ?c | boolean | True if file1 is a character device
...

and so on...

--
      vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407

Wes Gamble wrote:

File.exist?

Sorry to waste time.

I was so excited to finally see a question I could answer! That raised
my spirits. Definitely not a waste of my time!

···

--
Posted via http://www.ruby-forum.com/\.

File.exist?

Sorry to waste time.

Wes Gamble wrote:
> All,
>
> What is the best way to determine the existence of a file (more
> specifically, a directory)?

And since you're looking for directories, there's also:
File.directory?

···

On 4/11/06, Wes Gamble <weyus@att.net> wrote:

> Are there Perl - like file test operators available?
>
> Wes

--
Posted via http://www.ruby-forum.com/\.

--
Bill Guindon (aka aGorilla)
The best answer to most questions is "it depends".