Method: Dir.children
- Defined in:
- dir.c
permalink .children(dirpath) ⇒ Array .children(dirpath, encoding: 'UTF-8') ⇒ Array
Returns an array of the entry names in the directory at dirpath
except for '.'
and '..'
; sets the given encoding onto each returned entry name:
Dir.children('/example') # => ["config.h", "lib", "main.rb"]
Dir.children('/example').first.encoding
# => #<Encoding:UTF-8>
Dir.children('/example', encoding: 'US-ASCII').first.encoding
# => #<Encoding:US-ASCII>
See String Encoding.
Raises an exception if the directory does not exist.
3595 3596 3597 3598 3599 3600 3601 3602 |
# File 'dir.c', line 3595
static VALUE
dir_s_children(int argc, VALUE *argv, VALUE io)
{
VALUE dir;
dir = dir_open_dir(argc, argv);
return rb_ensure(dir_collect_children, dir, dir_close, dir);
}
|