home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Atari FTP
/
ATARI_FTP_0693.zip
/
ATARI_FTP_0693
/
Mint
/
mntlib32.zoo
/
symlink.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-05-23
|
1KB
|
69 lines
/* soft link routines */
#include <mintbind.h>
#include <errno.h>
#include <string.h>
#include <limits.h>
#include "lib.h"
extern int __mint;
/*
* If MiNT 0.9 or later is active, use the kernel routines for these;
* otherwise, try to choose failure modes that applications will best be
* able to handle
*/
int
symlink(old, new)
const char *old, *new;
{
char linkname[PATH_MAX];
char path[PATH_MAX];
long r;
if (__mint >= 9) {
_unx2dos(old, path);
_unx2dos(new, linkname);
r = Fsymlink(path, linkname);
if (r) {
errno = (int) -r;
return -1;
}
return (int) r;
}
errno = EINVAL;
return -1;
}
int
readlink(unxname, buf, siz)
char *unxname, *buf;
int siz;
{
long r;
size_t l;
char filename[PATH_MAX];
char linkto[PATH_MAX+1];
if (__mint < 9) {
errno = EINVAL;
return -1;
}
_unx2dos(unxname, filename);
r = Freadlink(PATH_MAX, linkto, filename);
if (r < 0) {
errno = (int) -r;
return -1;
}
linkto[PATH_MAX] = 0;
_dos2unx(linkto, filename);
l = strlen(filename);
if (l > siz) {
errno = ERANGE;
return -1;
}
strncpy(buf, filename, siz);
return (int) l;
}