Method: Dir.entries
- Defined in:
- dir.c
permalink .entries(dirname, encoding: 'UTF-8') ⇒ Array
Returns an array of the entry names in the directory at dirpath
; sets the given encoding onto each returned entry name:
Dir.entries('/example') # => ["config.h", "lib", "main.rb", "..", "."]
Dir.entries('/example').first.encoding
# => #<Encoding:UTF-8>
Dir.entries('/example', encoding: 'US-ASCII').first.encoding
# => #<Encoding:US-ASCII>
See String Encoding.
Raises an exception if the directory does not exist.
3498 3499 3500 3501 3502 3503 3504 3505 |
# File 'dir.c', line 3498 static VALUE dir_entries(int argc, VALUE *argv, VALUE io) { VALUE dir; dir = dir_open_dir(argc, argv); return rb_ensure(dir_collect, dir, dir_close, dir); } |