create_hard_link Function

Creates a hard link to an existing file.

pathpathvoid create_hard_link(
   const path& pval1,
   const path& pval2
);
void create_hard_link(
   const path& pval1,
   const path& pval2,
   error_code& code
) noexcept;

Parameters

  • pval1
    A path object that represents the file name of an existing file. path can be either a path or a type that is derived from path.

  • pval2
    A path object that contains the file name of the hard link.

  • code
    An error_code object.

Return Value

The second function returns code.

Remarks

A hard link is the file system representation of a file by which more than one path references a file in the same volume.

If the hard link cannot be created, the first function throws a filesystem_error.

The second function assigns any error code that is associated with the operation to code.

Requirements

Header: filesystem

Namespace: std::tr2::sys

See Also

Reference

<filesystem>

Other Resources

C++ Standard Library Header Files