Commit dd22f44c authored by Francois Cartegnie's avatar Francois Cartegnie

addons: fix path vs uri usage

fixes Win32 installs
parent 6b19dc64
......@@ -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 );
......
......@@ -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;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment