summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2019-06-02 04:25:19 +0000
committermidipix <writeonce@midipix.org>2019-06-02 04:26:09 +0000
commit18b707bdccb71a9ac26b431cca8deac42fc0501a (patch)
treef277ff165368229d54ba7288be5d9cf921a73287 /src
parenta2a4d0ef1cadcad4363cd02f76ef594b4fbb024e (diff)
downloadmmglue-18b707bdccb71a9ac26b431cca8deac42fc0501a.tar.bz2
mmglue-18b707bdccb71a9ac26b431cca8deac42fc0501a.tar.xz
glue layer: added a framework-specific realpath() implementation.
Diffstat (limited to 'src')
-rw-r--r--src/misc/nt32/realpath.c30
-rw-r--r--src/misc/nt64/realpath.c30
2 files changed, 60 insertions, 0 deletions
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 <limits.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <string.h>
+#include <errno.h>
+#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 <limits.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <string.h>
+#include <errno.h>
+#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);
+}