Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
class method
Dir.delete
(::path dirname) -> 0
Dir.delete(dirpath) → 0
Dir.rmdir(dirpath) → 0
Dir.unlink(dirpath) → 0
dir.c
View on GitHub ↗
static VALUE
dir_s_rmdir(VALUE obj, VALUE dir)
{
const char *p;
int r;
dir = check_dirname(dir);
p = RSTRING_PTR(dir);
r = IO_WITHOUT_GVL_INT(nogvl_rmdir, (void *)p);
if (r < 0)
rb_sys_fail_path(dir);
return INT2FIX(0);
}
Removes the directory entry (hard link) at dirpath, along with its associated inode:
Example
dirpath = '/tmp/tmpdir' Dir.mkdir(dirpath) Dir.rmdir(dirpath) # => 0
Raises an exception if the directory is not empty.