2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
9 /******************************************************************************
18 FROM/A, TO/A, HARD/S, FORCE/S
26 Create a link to a file
30 FROM -- The name of the link
31 TO -- The name of the file or directory to link to
32 HARD -- If specified, the link will be a hard-link; default is
34 FORCE -- Allow a hard-link to point to a directory
50 04.05.2000 SDuvan implemented
52 ******************************************************************************/
55 #include <dos/dosextens.h>
56 #include <dos/rdargs.h>
57 #include <dos/stdio.h>
58 #include <proto/dos.h>
59 #include <proto/exec.h>
60 #include <utility/tagitem.h>
62 static const char version
[] = "$VER: MakeLink 41.1 (02.06.2000)\n";
64 enum { ARG_FROM
= 0, ARG_TO
, ARG_HARD
, ARG_FORCE
};
70 int retval
= RETURN_FAIL
;
71 IPTR args
[] = { NULL
, NULL
, (IPTR
)FALSE
, (IPTR
)FALSE
};
74 rda
= ReadArgs("FROM/A,TO/A,HARD/S,FORCE/S", args
, NULL
);
80 lock
= Lock((STRPTR
)args
[ARG_TO
], SHARED_LOCK
);
84 struct FileInfoBlock
*fib
= AllocDosObject(DOS_FIB
, NULL
);
88 if(Examine(lock
, fib
) == DOSTRUE
)
90 /* Directories may only be hard-linked to if FORCE is
92 if(fib
->fib_DirEntryType
>= 0 &&
93 !(BOOL
)args
[ARG_FORCE
] && (BOOL
)args
[ARG_HARD
])
95 PutStr("Hard-links to directories require the FORCE"
101 if(MakeLink((STRPTR
)args
[ARG_FROM
],
102 (BOOL
)args
[ARG_HARD
] ? lock
:
103 (STRPTR
)args
[ARG_TO
],
104 !(BOOL
)args
[ARG_HARD
]) == DOSTRUE
)
107 PrintFault(IoErr(), "MakeLink");
111 FreeDosObject(DOS_FIB
, fib
);
118 PutStr((STRPTR
)args
[ARG_TO
]);
119 PrintFault(IoErr(), "");
124 PrintFault(IoErr(), "MakeLink");
125 retval
= RETURN_FAIL
;