2 Copyright © 2004, The AROS Development Team. All rights reserved.
5 POSIX function symlink().
8 #include <aros/debug.h>
12 #include <proto/dos.h>
16 #include <aros/debug.h>
18 /*****************************************************************************
44 ******************************************************************************/
48 struct FileInfoBlock
*fib
;
52 int bufferincrease
= 256;
53 int buffersize
= bufferincrease
;
55 if (!oldpath
|| !newpath
) /*safety check */
61 if(oldpath
= strdup(__path_u2a(oldpath
)))
63 newpath
= __path_u2a(newpath
);
70 if(lock
= Lock((STRPTR
)oldpath
, SHARED_LOCK
)) {
73 if(!(buffer
= AllocVec(buffersize
, MEMF_ANY
)))
75 ioerr
= ERROR_NO_FREE_STORE
;
80 /* Get the full path of oldpath */
81 if(NameFromLock(lock
, buffer
, buffersize
))
83 if(MakeLink((STRPTR
)newpath
,
94 else if(IoErr() != ERROR_LINE_TOO_LONG
)
101 buffersize
+= bufferincrease
;
103 while(retval
!= RETURN_OK
);
109 /* I'm not sure if MakeLink is allowed to create symlinks to
110 non-existing files or directories. If yes, then it's fine to
111 enable the following code */
113 if(ioerr
== ERROR_OBJECT_NOT_FOUND
)
115 /* On Unices it's perfectly fine to create symlinks to
116 non-existing files or directories, however in this case it
117 may be difficult to get the full absolute path, so we are
118 simply trusting the user here for now */
119 if(MakeLink((STRPTR
)newpath
,
136 if(errorset
) errno
= IoErr2errno(ioerr
);