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 int symlink(const char *oldpath
, const char *newpath
)
22 struct FileInfoBlock
*fib
;
26 int bufferincrease
= 256;
27 int buffersize
= bufferincrease
;
29 if (!oldpath
|| !newpath
) /*safety check */
35 if(oldpath
= strdup(__path_u2a(oldpath
)))
37 newpath
= __path_u2a(newpath
);
44 if(lock
= Lock((STRPTR
)oldpath
, SHARED_LOCK
)) {
47 if(!(buffer
= AllocVec(buffersize
, MEMF_ANY
)))
49 ioerr
= ERROR_NO_FREE_STORE
;
54 /* Get the full path of oldpath */
55 if(NameFromLock(lock
, buffer
, buffersize
))
57 if(MakeLink((STRPTR
)newpath
,
68 else if(IoErr() != ERROR_LINE_TOO_LONG
)
75 buffersize
+= bufferincrease
;
77 while(retval
!= RETURN_OK
);
83 /* I'm not sure if MakeLink is allowed to create symlinks to
84 non-existing files or directories. If yes, then it's fine to
85 enable the following code */
87 if(ioerr
== ERROR_OBJECT_NOT_FOUND
)
89 /* On Unices it's perfectly fine to create symlinks to
90 non-existing files or directories, however in this case it
91 may be difficult to get the full absolute path, so we are
92 simply trusting the user here for now */
93 if(MakeLink((STRPTR
)newpath
,
110 if(errorset
) errno
= IoErr2errno(ioerr
);