static public Method

File.chown(...)

File.chown(owner_int, group_int, file_name,... )  integer

Changes the owner and group of the named file(s) to the given numeric owner and group id’s. Only a process with superuser privileges may change the owner of a file. The current owner of a file may change the file’s group to any group to which the owner belongs. A nil or -1 owner or group id is ignored. Returns the number of files processed.

File.chown(nil, 100, "testfile")

Source Code

/*
*  call-seq:
*     File.chown(owner_int, group_int, file_name,... ) -> integer
*  
*  Changes the owner and group of the named file(s) to the given
*  numeric owner and group id's. Only a process with superuser
*  privileges may change the owner of a file. The current owner of a
*  file may change the file's group to any group to which the owner
*  belongs. A <code>nil</code> or -1 owner or group id is ignored.
*  Returns the number of files processed.
*     
*     File.chown(nil, 100, "testfile")
*     
*/

static VALUE
rb_file_s_chown(argc, argv)
   int argc;
   VALUE *argv;
{
   VALUE o, g, rest;
   struct chown_args arg;
   long n;

   rb_secure(2);
   rb_scan_args(argc, argv, "2*", &o, &g, &rest);
   if (NIL_P(o)) {
       arg.owner = -1;
   }
   else {
       arg.owner = NUM2INT(o);
   }
   if (NIL_P(g)) {
       arg.group = -1;
   }
   else {
       arg.group = NUM2INT(g);
   }

   n = apply2files(chown_internal, rest, &arg);
   return LONG2FIX(n);
}
Comments

Have your say
Please use Textile formatting (click here for a cheat sheet). Use <code/> and <pre/> for code samples.
Click here to login with OpenID to to post comments.