Blame src/misc/nt32/realpath.c

18b707
#include <limits.h>
18b707
#include <unistd.h>
18b707
#include <fcntl.h>
18b707
#include <string.h>
18b707
#include <errno.h>
18b707
#include "psxglue.h"
18b707
18b707
extern const struct __psx_vtbl *  __psx_vtbl;
18b707
18b707
char * realpath(const char * restrict filename, char * restrict resolved)
18b707
{
18b707
	int  ecode;
18b707
	char buf[PATH_MAX];
18b707
18b707
	ecode = filename
18b707
		? __psx_vtbl->fs_rpath(
18b707
			AT_FDCWD,filename,
18b707
			O_NONBLOCK|O_CLOEXEC,
18b707
			buf,sizeof(buf))
18b707
		: -EINVAL;
18b707
18b707
	if (ecode < 0) {
18b707
		errno = -ecode;
18b707
		return 0;
18b707
	}
18b707
18b707
	return resolved
18b707
		? strcpy(resolved,buf)
18b707
		: strdup(buf);
18b707
}