2 Copyright © 2004-2012, The AROS Development Team. All rights reserved.
5 POSIX function symlink().
8 #include <aros/debug.h>
11 #include <proto/dos.h>
14 #include <aros/debug.h>
16 /*****************************************************************************
43 ******************************************************************************/
51 if (!oldpath
|| !newpath
) /*safety check */
57 oldpath
= __path_u2a(oldpath
);
61 oldpath
= strdup(oldpath
);
68 newpath
= __path_u2a(newpath
);
71 free((void*) oldpath
);
75 if((lock
= Lock((STRPTR
)oldpath
, SHARED_LOCK
)))
79 if(!(buffer
= AllocVec(buffersize
, MEMF_ANY
)))
81 ioerr
= ERROR_NO_FREE_STORE
;
85 /* Get the full path of oldpath */
86 if(NameFromLock(lock
, buffer
, buffersize
))
88 if(MakeLink((STRPTR
)newpath
, (STRPTR
)buffer
, TRUE
))
97 else if(IoErr() != ERROR_LINE_TOO_LONG
)
106 while(retval
!= RETURN_OK
);
111 /* MakeLink can create symlinks to non-existing files or
113 if(IoErr() == ERROR_OBJECT_NOT_FOUND
)
115 /* In this case it may be difficult to get the full absolute
116 path, so we simply trust the caller here for now */
117 if(MakeLink((STRPTR
)newpath
, (STRPTR
)oldpath
, TRUE
))
125 free((void*) oldpath
);
128 errno
= __arosc_ioerr2errno(ioerr
);