Hi,
How do I check if a file (possibly a directory) exists? This is probably
easy, but I was not able to find it.
Thanks,
Maurício
Hi,
How do I check if a file (possibly a directory) exists? This is probably
easy, but I was not able to find it.
Thanks,
Maurício
It’s kinda hard to find - the FileTest object is what you’re looking for
The method ‘exists?’ can tell you if it exists…
The method ‘file?’ can tell you if it’s a file…
The method ‘directory?’ can tell you if it’s a directory…
But I use
returnedString = File.ftype (“nameOfFile_or_directory”)
Which returns strings like - ``file'', ``directory'',
characterSpecial'',
blockSpecial’‘, fifo'',
link’‘, or ``socket’'.
(taken from the Ruby help files…)
-Rich
----- Original Message -----
From: “Maurício” briqueabraque@yahoo.com
Newsgroups: gmane.comp.lang.ruby.general
To: “ruby-talk ML” ruby-talk@ruby-lang.org
Sent: Tuesday, August 13, 2002 6:25 PM
Subject: Checking for file existance
Hi,
How do I check if a file (possibly a directory) exists? This is
probably
easy, but I was not able to find it.
Thanks, Maurício
Hi,
At Wed, 14 Aug 2002 09:25:25 +0900, Maurício wrote:
How do I check if a file (possibly a directory) exists? This is probably
easy, but I was not able to find it.
File.exist?(“filename”)
–
Nobu Nakada