2 Copyright © 1995-2008, 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.1 (2.6.2000)\n";
65 enum { ARG_FROM
= 0, ARG_TO
, ARG_HARD
, ARG_FORCE
};
71 int retval
= RETURN_FAIL
;
72 IPTR args
[] = { (IPTR
)NULL
, (IPTR
)NULL
, (IPTR
)FALSE
, (IPTR
)FALSE
};
75 rda
= ReadArgs("FROM/A,TO/A,HARD/S,FORCE/S", args
, NULL
);
83 lock
= Lock((STRPTR
)args
[ARG_TO
], SHARED_LOCK
);
87 struct FileInfoBlock
*fib
= AllocDosObject(DOS_FIB
, NULL
);
91 if(Examine(lock
, fib
))
93 /* Directories may only be hard-linked to if FORCE is
95 if(fib
->fib_DirEntryType
>= 0 && !(BOOL
)args
[ARG_FORCE
])
97 PutStr("Hard links to directories require the"
103 if(MakeLink((STRPTR
)args
[ARG_FROM
], (APTR
)lock
, FALSE
))
106 PrintFault(IoErr(), "MakeLink");
110 FreeDosObject(DOS_FIB
, fib
);
117 PutStr((STRPTR
)args
[ARG_TO
]);
118 PrintFault(IoErr(), "");
123 if(MakeLink((STRPTR
)args
[ARG_FROM
], (STRPTR
)args
[ARG_TO
], TRUE
))
129 PrintFault(IoErr(), "MakeLink");
130 retval
= RETURN_FAIL
;