Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I create a soft link programmatically in C/C++?

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

like image 611
Professor_Chaos Avatar asked Sep 30 '14 09:09

Professor_Chaos


2 Answers

The system call you want is symlink(2).

#include <unistd.h>

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

A symbolic link name2 is created to name1

like image 169
Mike Seymour Avatar answered Oct 20 '22 23:10

Mike Seymour


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.
like image 37
SSC Avatar answered Oct 21 '22 01:10

SSC