2 Copyright © 2004, The AROS Development Team. All rights reserved.
5 POSIX function symlink().
8 #include <aros/debug.h>
11 #include <proto/dos.h>
15 #include <aros/debug.h>
17 /*****************************************************************************
44 ******************************************************************************/
52 if (!oldpath
|| !newpath
) /*safety check */
58 oldpath
= __path_u2a(oldpath
);
62 oldpath
= strdup(oldpath
);
69 newpath
= __path_u2a(newpath
);
72 free((void*) oldpath
);
76 if((lock
= Lock((STRPTR
)oldpath
, SHARED_LOCK
)))
80 if(!(buffer
= AllocVec(buffersize
, MEMF_ANY
)))
82 ioerr
= ERROR_NO_FREE_STORE
;
86 /* Get the full path of oldpath */
87 if(NameFromLock(lock
, buffer
, buffersize
))
89 if(MakeLink((STRPTR
)newpath
, (STRPTR
)buffer
, TRUE
))
98 else if(IoErr() != ERROR_LINE_TOO_LONG
)
107 while(retval
!= RETURN_OK
);
112 /* MakeLink can create symlinks to non-existing files or
114 if(IoErr() == ERROR_OBJECT_NOT_FOUND
)
116 /* In this case it may be difficult to get the full absolute
117 path, so we simply trust the caller here for now */
118 if(MakeLink((STRPTR
)newpath
, (STRPTR
)oldpath
, TRUE
))
126 free((void*) oldpath
);
129 errno
= IoErr2errno(ioerr
);