如何用c/c++编程创建一个软链接?

时间:2021-01-03 01:28:23

How do I create a soft link programmatically in c/c++? link() system call in freebsd will create a hard link.

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

2 个解决方案

#1


10  

The system call you want is symlink(2).

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

#include <unistd.h>

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

A symbolic link name2 is created to name1

一个符号链接name2被创建为name1。

#2


4  

You can call 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.

#1


10  

The system call you want is symlink(2).

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

#include <unistd.h>

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

A symbolic link name2 is created to name1

一个符号链接name2被创建为name1。

#2


4  

You can call 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.