static public Method

File.link(p1, p2)

File.link(old_name, new_name)     0

Creates a new name for an existing file using a hard link. Will not overwrite new_name if it already exists (raising a subclass of SystemCallError). Not available on all platforms.

File.link("testfile", ".testfile")   #=> 0
IO.readlines(".testfile")[0]         #=> "This is line one\n"

Source Code

/*
*  call-seq:
*     File.link(old_name, new_name)    => 0
*  
*  Creates a new name for an existing file using a hard link. Will not
*  overwrite <i>new_name</i> if it already exists (raising a subclass
*  of <code>SystemCallError</code>). Not available on all platforms.
*     
*     File.link("testfile", ".testfile")   #=> 0
*     IO.readlines(".testfile")[0]         #=> "This is line one\n"
*/

static VALUE
rb_file_s_link(klass, from, to)
   VALUE klass, from, to;
{
#ifdef HAVE_LINK
   SafeStringValue(from);
   SafeStringValue(to);

   if (link(StringValueCStr(from), StringValueCStr(to)) < 0) {
       sys_fail2(from, to);
   }
   return INT2FIX(0);
#else
   rb_notimplement();
   return Qnil;                /* not reached */
#endif
}
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.