

#include <unistd.h> int link(char *oldfile, char *newname);
link creates a hard link to an existing OpenEdition file.
oldfile is the existing file. If oldfile is a symbolic
link, the link refers to the file that is referenced by the pathname in
the symbolic link. newname is the new pathname. If the old name
is removed, the file continues to exist with the new name.
You cannot create a link to a directory.
Both oldfile and newname must specify OpenEdition HFS
filenames. For programs not compiled with the posix option,
style prefixes may be required. See File Naming Conventions for
information on specifying OpenEdition filenames.
link returns a 0 if it is successful; link increments the link
count that refers to the number of links to the file. link
returns a - 1 if it is not successful; the link count is not incremented.
link and unlink to change the name of
an HFS file. It differs from the rename function in two ways:
#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>
int chname(char *oldname, char *newname)
{
int rc;
rc = link(oldname, newname);
if (rc != 0) {
perror("link error");
return -1; /* Go no further if the link fails. */
}
/* The link worked. Now we can unlink the old name. */
rc = unlink(oldname);
if (rc != 0) {
perror("unlink error");
return -1;
}
return 0;
}
symlink, unlink
Copyright (c) 1998 SAS Institute Inc. Cary, NC, USA. All rights reserved.