How to programmatically create a soft link in C / C ++?

How to programmatically create a soft link in C / C ++? The link () system call in freebsd will create a hard link.

+10
source share
2 answers

The system call you want is symlink (2) .

#include <unistd.h> int symlink(const char *name1, const char *name2); 

Symbolic link name2 created for name1

+17
source

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. 
+4
source

Source: https://habr.com/ru/post/976043/


All Articles