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
static VALUE
rb_file_s_link(VALUE klass, VALUE from, VALUE to)
{
FilePathValue(from);
FilePathValue(to);
from = rb_str_encode_ospath(from);
to = rb_str_encode_ospath(to);
if (link(StringValueCStr(from), StringValueCStr(to)) < 0) {
sys_fail2(from, to);
}
return INT2FIX(0);
}