Method: Dir.open

Defined in:
dir.c

.open(string) ⇒ Dir .open(string, encoding: enc) ⇒ Dir .open(string) {|aDir| ... } ⇒ Object .open(string, encoding: enc) {|aDir| ... } ⇒ Object

The optional encoding keyword argument specifies the encoding of the directory. If not specified, the filesystem encoding is used.

With no block, open is a synonym for Dir::new. If a block is present, it is passed aDir as a parameter. The directory is closed at the end of the block, and Dir::open returns the value of the block.

Overloads:

  • .open(string) ⇒ Dir

    Returns:

  • .open(string, encoding: enc) ⇒ Dir

    Returns:

  • .open(string) {|aDir| ... } ⇒ Object

    Yields:

    • (aDir)

    Returns:

  • .open(string, encoding: enc) {|aDir| ... } ⇒ Object

    Yields:

    • (aDir)

    Returns:



600
601
602
603
604
605
606
607
608
609
610
611
612
# File 'dir.c', line 600

static VALUE
dir_s_open(int argc, VALUE *argv, VALUE klass)
{
    struct dir_data *dp;
    VALUE dir = TypedData_Make_Struct(klass, struct dir_data, &dir_data_type, dp);

    dir_initialize(argc, argv, dir);
    if (rb_block_given_p()) {
	return rb_ensure(rb_yield, dir, dir_close, dir);
    }

    return dir;
}