软链接(itop基于4412)
2018-07-13 本文已影响0人
嵌入式工作
使用man 2 symlink的解释

用法
软链接函数
• int symlink(const char oldpath, const char newpath);
– 参数oldpath:已有的文件路径
– 参数newpath:新建的符号链接文件路径
– 返回值:成功返回0,错误返回-1
代码
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <dirent.h>
int main(int argv,char*argc[])
{
printf("pls input file or content path and want change path\n");
if(argv<3)
{
printf("need 3 para \n");
exit(1);
}
if(0!=symlink(argc[1],argc[2]))
{
printf("chg err \n");
}else
{
printf("sym link chg success \n");
}
return 0;
}
测试
