chmod(p1)
public
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)
Show source
static VALUE
rb_file_chmod(VALUE obj, VALUE vmode)
{
rb_io_t *fptr;
int mode;
VALUE path;
rb_secure(2);
mode = NUM2INT(vmode);
GetOpenFile(obj, fptr);
if (fchmod(fptr->fd, mode) == -1)
rb_sys_fail_path(fptr->pathv);
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);
return INT2FIX(0);
}