如何在C/C++中以编程方式创建软链接?

v7pvogib  于 12个月前  发布在  C/C++
关注(0)|答案(3)|浏览(163)

如何在C/C++中以编程方式创建软链接?freebsd中的link()系统调用将创建一个硬链接。

xghobddn

xghobddn1#

您需要的系统调用是symlink(2)

#include <unistd.h>

int symlink(const char  *name1, const char *name2);

创建到name1的符号链接name2

v8wbuo2f

v8wbuo2f2#

您可以调用symlink()

int  symlink(const char *name1, const char *name2);

A symbolic  link name2 is created to name1 (name2 is the name of the file
created, name1 is the string used in creating the symbolic  link).  Either
name may be an arbitrary path name; the files need  not be on the same
file system.

相关问题