[vlc-commits] addons: fix path vs uri usage

Francois Cartegnie git at videolan.org
Fri Feb 14 00:55:19 CET 2014


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Thu Feb 13 23:58:33 2014 +0100| [dd22f44cef872d84e5fba18a5e11b3ef3ae53549] | committer: Francois Cartegnie

addons: fix path vs uri usage

fixes Win32 installs

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=dd22f44cef872d84e5fba18a5e11b3ef3ae53549
---

 modules/misc/addons/fsstorage.c    |   13 +++++++++----
 modules/misc/addons/vorepository.c |   31 ++++++++++++++++++++-----------
 2 files changed, 29 insertions(+), 15 deletions(-)

diff --git a/modules/misc/addons/fsstorage.c b/modules/misc/addons/fsstorage.c
index 2b2f34a..040fcf5 100644
--- a/modules/misc/addons/fsstorage.c
+++ b/modules/misc/addons/fsstorage.c
@@ -34,6 +34,7 @@
 #include <vlc_fs.h>
 #include <vlc_strings.h>
 #include <vlc_xml.h>
+#include <vlc_url.h>
 #include "xmlreading.h"
 
 #include <sys/stat.h>
@@ -652,7 +653,7 @@ static int LoadCatalog( addons_finder_t *p_finder )
     char * psz_userdir = config_GetUserDir( VLC_DATA_DIR );
     if ( !psz_userdir ) return VLC_ENOMEM;
 
-    if ( asprintf( &psz_path, "file://%s%s", psz_userdir, ADDONS_CATALOG ) < 1 )
+    if ( asprintf( &psz_path, "%s%s", psz_userdir, ADDONS_CATALOG ) < 1 )
     {
         free( psz_userdir );
         return VLC_ENOMEM;
@@ -671,16 +672,20 @@ static int LoadCatalog( addons_finder_t *p_finder )
     char *psz_filename = NULL;
     int i_filetype = -1;
 
-    const char *psz_statpath = psz_path + 7; // + scheme
     struct stat stat_;
-    if ( vlc_stat( psz_statpath, &stat_ ) )
+    if ( vlc_stat( psz_path, &stat_ ) )
     {
         free( psz_path );
         return VLC_EGENERIC;
     }
 
-    stream_t *p_stream = stream_UrlNew( p_finder, psz_path );
+    char *psz_catalog_uri = vlc_path2uri( psz_path, "file" );
     free( psz_path );
+    if ( !psz_catalog_uri )
+        return VLC_EGENERIC;
+
+    stream_t *p_stream = stream_UrlNew( p_finder, psz_catalog_uri );
+    free( psz_catalog_uri );
     if (! p_stream ) return VLC_EGENERIC;
 
     xml_reader_t *p_xml_reader = xml_ReaderCreate( p_finder, p_stream );
diff --git a/modules/misc/addons/vorepository.c b/modules/misc/addons/vorepository.c
index 9b21479..3a21791 100644
--- a/modules/misc/addons/vorepository.c
+++ b/modules/misc/addons/vorepository.c
@@ -32,6 +32,7 @@
 #include <vlc_addons.h>
 #include <vlc_xml.h>
 #include <vlc_fs.h>
+#include <vlc_url.h>
 #include "xmlreading.h"
 
 #include "assert.h"
@@ -77,7 +78,7 @@ struct addons_finder_sys_t
 };
 
 static int ParseManifest( addons_finder_t *p_finder, addon_entry_t *p_entry,
-                          const char *psz_tempfile, stream_t *p_stream )
+                          const char *psz_tempfileuri, stream_t *p_stream )
 {
     int i_num_entries_created = 0;
     const char *p_node;
@@ -164,8 +165,8 @@ static int ParseManifest( addons_finder_t *p_finder, addon_entry_t *p_entry,
                     addon_file_t *p_file = malloc( sizeof(addon_file_t) );
                     p_file->e_filetype = i_filetype;
                     p_file->psz_filename = strdup( psz_filename );
-                    if ( asprintf( & p_file->psz_download_uri, "unzip://%s!/%s",
-                                   psz_tempfile, psz_filename  ) > 0 )
+                    if ( asprintf( & p_file->psz_download_uri, "%s!/%s",
+                                   psz_tempfileuri, psz_filename  ) > 0 )
                     {
                         ARRAY_APPEND( p_entry->files, p_file );
                         msg_Dbg( p_finder, "manifest lists file %s extractable from %s",
@@ -404,20 +405,28 @@ static int Retrieve( addons_finder_t *p_finder, addon_entry_t *p_entry )
 
     msg_Dbg( p_finder, "Reading manifest from %s", p_finder->p_sys->psz_tempfile );
 
-    char *psz_manifest;
-    if ( asprintf( &psz_manifest, "unzip://%s!/manifest.xml",
-                   p_finder->p_sys->psz_tempfile ) < 1 )
+    char *psz_tempfileuri = vlc_path2uri( p_finder->p_sys->psz_tempfile, "unzip" );
+    if ( !psz_tempfileuri )
         return VLC_ENOMEM;
 
-    p_stream = stream_UrlNew( p_finder, psz_manifest );
-    free( psz_manifest );
+    char *psz_manifest_uri;
+    if ( asprintf( &psz_manifest_uri, "%s!/manifest.xml", psz_tempfileuri ) < 1 )
+    {
+        free( psz_tempfileuri );
+        return VLC_ENOMEM;
+    }
+
+    p_stream = stream_UrlNew( p_finder, psz_manifest_uri );
+    free( psz_manifest_uri );
     if ( !p_stream )
+    {
+        free( psz_tempfileuri );
         return VLC_EGENERIC;
+    }
 
-    int i_ret = ( ParseManifest( p_finder, p_entry,
-                                 p_finder->p_sys->psz_tempfile, p_stream ) > 0 )
+    int i_ret = ( ParseManifest( p_finder, p_entry, psz_tempfileuri, p_stream ) > 0 )
                     ? VLC_SUCCESS : VLC_EGENERIC;
-
+    free( psz_tempfileuri );
     stream_Delete( p_stream );
 
     return i_ret;



More information about the vlc-commits mailing list