Add -f flag to ln
This commit is contained in:
parent
f458b93c2b
commit
9486a5004e
9
src/ln.c
9
src/ln.c
|
@ -10,13 +10,16 @@ main(int argc, char *argv[])
|
||||||
printf("Usage: ln oldfile newfile\n");
|
printf("Usage: ln oldfile newfile\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
int opts;
|
int opts, fd, fflag;
|
||||||
int fd;
|
while((opts = getopt(argc, argv, "sf")) != -1)
|
||||||
while((opts = getopt(argc, argv, "s:")) != -1)
|
|
||||||
{
|
{
|
||||||
switch(opts)
|
switch(opts)
|
||||||
{
|
{
|
||||||
|
case 'f':
|
||||||
|
fflag=1;
|
||||||
case 's':
|
case 's':
|
||||||
|
if(fflag && (access(argv[3], F_OK) != 1))
|
||||||
|
unlink(argv[3]);
|
||||||
symlink(argv[2],argv[3]);
|
symlink(argv[2],argv[3]);
|
||||||
break;
|
break;
|
||||||
case '?':
|
case '?':
|
||||||
|
|
Loading…
Reference in New Issue