link(p1, p2)
public
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")
IO.readlines(".testfile")[0]
Show source
/*
* 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;
{
SafeStringValue(from);
SafeStringValue(to);
if (link(StringValueCStr(from), StringValueCStr(to)) < 0) {
sys_fail2(from, to);
}
return INT2FIX(0);
rb_notimplement();
return Qnil; /* not reached */
}