aboutsummaryrefslogtreecommitdiffstats
path: root/src/common/file.c
diff options
context:
space:
mode:
authorRafael G. Martins <rafael@rafaelmartins.eng.br>2018-12-22 02:47:07 +0100
committerRafael G. Martins <rafael@rafaelmartins.eng.br>2018-12-22 02:47:07 +0100
commitdb9f741875ad1fd3c7c3e5b932420081862159bc (patch)
tree03962b496e79b041ee1a0d503090a4fd9457739b /src/common/file.c
parent5fa28dc2b871b11f93d4206bea2780262f85af5e (diff)
downloadblogc-db9f741875ad1fd3c7c3e5b932420081862159bc.tar.gz
blogc-db9f741875ad1fd3c7c3e5b932420081862159bc.tar.bz2
blogc-db9f741875ad1fd3c7c3e5b932420081862159bc.zip
wip
Diffstat (limited to 'src/common/file.c')
-rw-r--r--src/common/file.c24
1 files changed, 24 insertions, 0 deletions
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 <errno.h>
+#include <limits.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#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;
+}