home *** CD-ROM | disk | FTP | other *** search
- #include "amiga.h"
- #include <string.h>
-
- int readlink(char *path, char *buf, int bufsiz)
- {
- struct DevProc *dev = NULL;
-
- chkabort();
-
- while (1)
- {
- struct DevProc *newdev = GetDeviceProc(path, dev);
- long err;
-
- FreeDeviceProc(dev);
- if (!(dev = newdev)) ERROR;
-
- buf[0] = '\0';
- if (ReadLink(dev->dvp_Port, dev->dvp_Lock, path, buf, bufsiz + 1))
- {
- FreeDeviceProc(dev);
- if (!buf[0])
- {
- /* Play games with apparent 2.x ram: bug */
- errno = ENOENT;
- return -1;
- }
- return strlen(buf);
- }
- err = IoErr();
- if (!(err == ERROR_OBJECT_NOT_FOUND && (dev->dvp_Flags & DVPF_ASSIGN)))
- {
- FreeDeviceProc(dev);
- errno = convert_oserr(err);
- return -1;
- }
- }
- }
-