From 2e92359b381db4bd8f1fce7e6360bebc6f44d7c7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?R=C3=A9mi=20Denis-Courmont?= Date: Mon, 11 Jul 2011 18:49:19 +0300 Subject: [PATCH] make_URI: use vlc_getcwd() This lifts the PATH_MAX characters limit, and should fix encoding on POSIX non-UTF-8 systems. --- src/text/strings.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/text/strings.c b/src/text/strings.c index 830d8c4054..ca56bcc8b4 100644 --- a/src/text/strings.c +++ b/src/text/strings.c @@ -47,6 +47,7 @@ #include #include #include +#include #include #include @@ -1129,13 +1130,15 @@ char *make_URI (const char *path, const char *scheme) else if (path[0] != DIR_SEP_CHAR) { /* Relative path: prepend the current working directory */ - char cwd[PATH_MAX]; + char *cwd, *ret; - if (getcwd (cwd, sizeof (cwd)) == NULL) /* FIXME: UTF8? */ + if ((cwd = vlc_getcwd ()) == NULL) return NULL; - if (asprintf (&buf, "%s/%s", cwd, path) == -1) - return NULL; - char *ret = make_URI (buf, scheme); + if (asprintf (&buf, "%s"DIR_SEP"%s", cwd, path) == -1) + buf = NULL; + + free (cwd); + ret = (buf != NULL) ? make_URI (buf, scheme) : NULL; free (buf); return ret; } -- 2.39.5