[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: How distinguish between a file and a directory?

Allen Riddle

10/16/2007 3:10:00 PM

There are class side methods called "file?" and "directory?" on the File
class that you can use. (ex. File.directory?("path/to/directory") )

-----Original Message-----
From: Bazsl [mailto:hs@dbginc.com]
Sent: Tuesday, October 16, 2007 10:01 AM
To: ruby-talk ML
Subject: How distinguish between a file and a directory?

A newbie question. The code

Dir.foreach(Dir.getwd) do |f|
if ((f != '.') && (f != '..'))
puts f
end
end

lists the files and directories in the current working directory but
does not identify which is a file and which is a directory. How can I
add that information to the listing? Thanks.