From e2aa774a6a3b1f072d345438ff53e4d8437966ce Mon Sep 17 00:00:00 2001 From: belliash Date: Mon, 23 Jul 2018 20:45:30 +0200 Subject: [PATCH] Reimplement SyRealPath(); fix build. --- engine/lib/utils.c | 10 ++++++++++ engine/vfs.c | 2 +- include/ph7.h | 5 +++++ include/ph7int.h | 1 + 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/engine/lib/utils.c b/engine/lib/utils.c index f864024..bc3c537 100644 --- a/engine/lib/utils.c +++ b/engine/lib/utils.c @@ -628,4 +628,14 @@ PH7_PRIVATE sxi32 SyStrToReal(const char *zSrc, sxu32 nLen, void *pOutVal, const *(sxreal *)pOutVal = Val; } return zSrc >= zEnd ? SXRET_OK : SXERR_SYNTAX; +} +PH7_PRIVATE sxi32 SyRealPath(const char *zPath, char **fPath) { +#ifdef __WINNT__ + if(GetFullPathName(zPath, PATH_MAX, fPath, NULL) != 0) { +#else + if(realpath(zPath, fPath) == NULL) { +#endif + return PH7_IO_ERR; + } + return PH7_OK; } \ No newline at end of file diff --git a/engine/vfs.c b/engine/vfs.c index c6a85e1..0bb473b 100644 --- a/engine/vfs.c +++ b/engine/vfs.c @@ -2916,7 +2916,7 @@ PH7_PRIVATE void *PH7_StreamOpenHandle(ph7_vm *pVm, const ph7_io_stream *pStream if(rc == PH7_OK) { if(bPushInclude) { /* Mark as included */ - PH7_VmPushFilePath(pVm, sFile.zString, FALSE, pNew); + PH7_VmPushFilePath(pVm, sFile.zString, -1, FALSE, pNew); } } } else { diff --git a/include/ph7.h b/include/ph7.h index 5052c23..4a139e1 100644 --- a/include/ph7.h +++ b/include/ph7.h @@ -50,6 +50,11 @@ /* $SymiscID: ph7.h v2.1 UNIX|WIN32/64 2012-09-15 09:43 stable $ */ #include /* needed for the definition of va_list */ #include /* needed for the definition of snprintf */ +#include /* needed for MAX_PATH */ + +#ifndef PATH_MAX + #define PATH_MAX MAX_PATH +#endif /* * Compile time engine version, signature, identification in the symisc source tree * and copyright notice. diff --git a/include/ph7int.h b/include/ph7int.h index b8d972b..232a299 100644 --- a/include/ph7int.h +++ b/include/ph7int.h @@ -1772,6 +1772,7 @@ PH7_PRIVATE sxi32 SyLexInit(SyLex *pLex, SySet *pSet, ProcTokenizer xTokenizer, PH7_PRIVATE sxi32 SyBase64Encode(const char *zSrc, sxu32 nLen, ProcConsumer xConsumer, void *pUserData); #endif /* PH7_DISABLE_BUILTIN_FUNC */ PH7_PRIVATE sxi32 SyStrToReal(const char *zSrc, sxu32 nLen, void *pOutVal, const char **zRest); +PH7_PRIVATE sxi32 SyRealPath(const char *zPath, char **fPath); PH7_PRIVATE sxi32 SyBinaryStrToInt64(const char *zSrc, sxu32 nLen, void *pOutVal, const char **zRest); PH7_PRIVATE sxi32 SyOctalStrToInt64(const char *zSrc, sxu32 nLen, void *pOutVal, const char **zRest); PH7_PRIVATE sxi32 SyHexStrToInt64(const char *zSrc, sxu32 nLen, void *pOutVal, const char **zRest);