From 1657cf599c20fe16b20676463671ee45f6ccded2 Mon Sep 17 00:00:00 2001 From: Wolfgang Thaller Date: Mon, 9 Oct 2017 15:43:52 +0200 Subject: [PATCH] make _open_r more independent of interfaces&libraries version --- libretro/syscalls.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/libretro/syscalls.c b/libretro/syscalls.c index fcb977595b..6245137d03 100644 --- a/libretro/syscalls.c +++ b/libretro/syscalls.c @@ -30,6 +30,8 @@ #include #include #include +#include +#include #include #include @@ -83,7 +85,17 @@ ssize_t _read_r(struct _reent *reent, int fd, void *buf, size_t count) int _open_r(struct _reent *reent, const char* name, int flags, int mode) { Str255 pname; +#if TARGET_API_MAC_CARBON + // Carbon has the new, sane version. c2pstrcpy(pname,name); +#else + // It is also availble in various glue code libraries and + // in some versions of InterfaceLib, but it's confusing. + // Using the inplace variant, c2pstr, isn't much better than + // doing things by hand: + strncpy(&pname[1],name,255); + pname[0] = strlen(name); +#endif short ref; SInt8 permission;