2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
9 /******************************************************************************
17 FROM/A, TO/A, HARD/S, FORCE/S
25 Create a link to a file.
29 FROM -- The name of the link
30 TO -- The name of the file or directory to link to
31 HARD -- If specified, the link will be a hard link; default is
33 FORCE -- Allow a hard-link to point to a directory
37 Standard DOS error codes.
41 Not all file systems support links.
46 Creates an 'ls' file with a soft link to the 'List' command in C:.
54 ******************************************************************************/
57 #include <dos/dosextens.h>
58 #include <dos/rdargs.h>
59 #include <proto/dos.h>
60 #include <proto/exec.h>
61 #include <aros/debug.h>
63 const TEXT version
[] = "$VER: MakeLink 41.2 (3.4.2014)\n";
65 enum { ARG_FROM
= 0, ARG_TO
, ARG_HARD
, ARG_FORCE
};
71 int retval
= RETURN_FAIL
;
73 IPTR args
[] = { (IPTR
)NULL
, (IPTR
)NULL
, (IPTR
)FALSE
, (IPTR
)FALSE
};
76 rda
= ReadArgs("FROM/A,TO/A,HARD/S,FORCE/S", args
, NULL
);
84 lock
= Lock((STRPTR
)args
[ARG_TO
], SHARED_LOCK
);
88 struct FileInfoBlock
*fib
= AllocDosObject(DOS_FIB
, NULL
);
92 if(Examine(lock
, fib
))
94 /* Directories may only be hard-linked to if FORCE is
96 if(fib
->fib_DirEntryType
>= 0 && !(BOOL
)args
[ARG_FORCE
])
98 PutStr("Hard links to directories require the"
104 if(MakeLink((STRPTR
)args
[ARG_FROM
], (SIPTR
)lock
, FALSE
))
109 PrintFault(error
, "MakeLink");
114 FreeDosObject(DOS_FIB
, fib
);
122 PutStr((STRPTR
)args
[ARG_TO
]);
123 PrintFault(error
, "");
128 if(MakeLink((STRPTR
)args
[ARG_FROM
], (SIPTR
)args
[ARG_TO
], TRUE
))
135 PrintFault(error
, "MakeLink");
136 retval
= RETURN_FAIL
;