From 18b707bdccb71a9ac26b431cca8deac42fc0501a Mon Sep 17 00:00:00 2001 From: midipix Date: Sun, 2 Jun 2019 04:25:19 +0000 Subject: glue layer: added a framework-specific realpath() implementation. --- src/misc/nt32/realpath.c | 30 ++++++++++++++++++++++++++++++ src/misc/nt64/realpath.c | 30 ++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 src/misc/nt32/realpath.c create mode 100644 src/misc/nt64/realpath.c (limited to 'src') diff --git a/src/misc/nt32/realpath.c b/src/misc/nt32/realpath.c new file mode 100644 index 0000000..0376011 --- /dev/null +++ b/src/misc/nt32/realpath.c @@ -0,0 +1,30 @@ +#include +#include +#include +#include +#include +#include "psxglue.h" + +extern const struct __psx_vtbl * __psx_vtbl; + +char * realpath(const char * restrict filename, char * restrict resolved) +{ + int ecode; + char buf[PATH_MAX]; + + ecode = filename + ? __psx_vtbl->fs_rpath( + AT_FDCWD,filename, + O_NONBLOCK|O_CLOEXEC, + buf,sizeof(buf)) + : -EINVAL; + + if (ecode < 0) { + errno = -ecode; + return 0; + } + + return resolved + ? strcpy(resolved,buf) + : strdup(buf); +} diff --git a/src/misc/nt64/realpath.c b/src/misc/nt64/realpath.c new file mode 100644 index 0000000..0376011 --- /dev/null +++ b/src/misc/nt64/realpath.c @@ -0,0 +1,30 @@ +#include +#include +#include +#include +#include +#include "psxglue.h" + +extern const struct __psx_vtbl * __psx_vtbl; + +char * realpath(const char * restrict filename, char * restrict resolved) +{ + int ecode; + char buf[PATH_MAX]; + + ecode = filename + ? __psx_vtbl->fs_rpath( + AT_FDCWD,filename, + O_NONBLOCK|O_CLOEXEC, + buf,sizeof(buf)) + : -EINVAL; + + if (ecode < 0) { + errno = -ecode; + return 0; + } + + return resolved + ? strcpy(resolved,buf) + : strdup(buf); +} -- cgit v1.2.3