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>
15 /*****************************************************************************
42 ******************************************************************************/
50 if (!oldpath
|| !newpath
) /*safety check */
56 oldpath
= __path_u2a(oldpath
);
60 oldpath
= strdup(oldpath
);
67 newpath
= __path_u2a(newpath
);
70 free((void*) oldpath
);
74 if((lock
= Lock((STRPTR
)oldpath
, SHARED_LOCK
)))
78 if(!(buffer
= AllocVec(buffersize
, MEMF_ANY
)))
80 ioerr
= ERROR_NO_FREE_STORE
;
84 /* Get the full path of oldpath */
85 if(NameFromLock(lock
, buffer
, buffersize
))
87 if(MakeLink((STRPTR
)newpath
, (STRPTR
)buffer
, TRUE
))
96 else if(IoErr() != ERROR_LINE_TOO_LONG
)
105 while(retval
!= RETURN_OK
);
110 /* MakeLink can create symlinks to non-existing files or
112 if(IoErr() == ERROR_OBJECT_NOT_FOUND
)
114 /* In this case it may be difficult to get the full absolute
115 path, so we simply trust the caller here for now */
116 if(MakeLink((STRPTR
)newpath
, (STRPTR
)oldpath
, TRUE
))
124 free((void*) oldpath
);
127 errno
= __arosc_ioerr2errno(ioerr
);