Testing for Directories and Files

J

Jay Sanders

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!
 
R

Robert Klemme

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
 
R

Rodrigo Bermejo

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,077
Latest member
SangMoor21

Latest Threads

Top