[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

Testing for Directories and Files

Jay Sanders

3/24/2008 7:17:00 PM

Hello. I have a question regarding Files and Directories. I have a
class method that opens a directory and reads the contents. What is the
most efficient way to test whether an entry is a directory or a file?

Also, the purpose of this program is to read through a tree directory
structure and turn the directory names into database entries. Any
suggestions on how to make a complete spider that utilizes Ruby's
specialties?

Thanks!
--
Posted via http://www.ruby-....

2 Answers

Robert Klemme

3/24/2008 8:11:00 PM

0

On 24.03.2008 20:16, Jay Sanders wrote:
> Hello. I have a question regarding Files and Directories. I have a
> class method that opens a directory and reads the contents. What is the
> most efficient way to test whether an entry is a directory or a file?

File.directory? path
File.file? path

> Also, the purpose of this program is to read through a tree directory
> structure and turn the directory names into database entries. Any
> suggestions on how to make a complete spider that utilizes Ruby's
> specialties?

Look at Find.

Kind regards

robert

Rodrigo Bermejo

3/24/2008 8:48:00 PM

0


>> Also, the purpose of this program is to read through a tree directory
>> structure and turn the directory names into database entries. Any
>> suggestions on how to make a complete spider that utilizes Ruby's
>> specialties?

If you are on a *ix box you can create your dir/file database getting
the friendly output of 'du -a /mypath > somefile' ...size are also
included.

-r.

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