entries(p1) public

Returns an array containing all of the filenames in the given directory. Will raise a SystemCallError if the named directory doesn’t exist.

Dir.entries("testdir")   #=> [".", "..", "config.h", "main.rb"]
Show source
Register or log in to add new notes.
April 30, 2009
1 thank

For specific entries, use Dir.glob

When working with the contents of a directory it’s not uncommon to be interested in a specific subset of the entries present.

Dir.glob can be used to fetch entries by name and File.stat can be used to determine the type of file.