From db9f741875ad1fd3c7c3e5b932420081862159bc Mon Sep 17 00:00:00 2001 From: "Rafael G. Martins" Date: Sat, 22 Dec 2018 02:47:07 +0100 Subject: wip --- src/common/file.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/common/file.c') diff --git a/src/common/file.c b/src/common/file.c index a2f7340..b44b202 100644 --- a/src/common/file.c +++ b/src/common/file.c @@ -7,9 +7,11 @@ */ #include +#include #include #include #include +#include #include #include "file.h" #include "error.h" @@ -64,3 +66,25 @@ bc_file_get_contents(const char *path, bool utf8, size_t *len, bc_error_t **err) return bc_string_free(str, false); } + + +char* +bc_file_get_realpath(const char *path) +{ + if (path == NULL) + return NULL; + +#if defined(WIN32) || defined(_WIN32) + char *buf = bc_malloc(_MAX_PATH); + if (NULL == _fullpath(buf, path, _MAX_PATH)) { +#else + char *buf = bc_malloc(PATH_MAX); + if (NULL == realpath(path, buf)) { +#endif + + free(buf); + return NULL; + } + + return buf; +} -- cgit v1.2.3-18-g5258