]> git.sesse.net Git - vlc/commitdiff
make_URI: use vlc_getcwd()
authorRémi Denis-Courmont <remi@remlab.net>
Mon, 11 Jul 2011 15:49:19 +0000 (18:49 +0300)
committerRémi Denis-Courmont <remi@remlab.net>
Mon, 11 Jul 2011 15:49:35 +0000 (18:49 +0300)
This lifts the PATH_MAX characters limit, and should fix encoding on
POSIX non-UTF-8 systems.

src/text/strings.c

index 830d8c40541c1fa495f76d97381dbfd398ece98d..ca56bcc8b4931de3c149906c9cdef90ce272619c 100644 (file)
@@ -47,6 +47,7 @@
 #include <vlc_strings.h>
 #include <vlc_url.h>
 #include <vlc_charset.h>
+#include <vlc_fs.h>
 #include <libvlc.h>
 #include <errno.h>
 
@@ -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;
     }