chmod(p1)
Changes permission bits on file to the bit pattern represented by mode_int. Actual effects are platform dependent; on Unix systems, see chmod(2) for details. Follows symbolic links. Also see File#lchmod.
f = File.new("out", "w"); f.chmod(0644) #=> 0
static VALUE rb_file_chmod(VALUE obj, VALUE vmode) { rb_io_t *fptr; int mode; #ifndef HAVE_FCHMOD VALUE path; #endif rb_secure(2); mode = NUM2INT(vmode); GetOpenFile(obj, fptr); #ifdef HAVE_FCHMOD if (fchmod(fptr->fd, mode) == -1) rb_sys_fail_path(fptr->pathv); #else if (NIL_P(fptr->pathv)) return Qnil; path = rb_str_encode_ospath(fptr->pathv); if (chmod(RSTRING_PTR(path), mode) == -1) rb_sys_fail_path(fptr->pathv); #endif return INT2FIX(0); }