[vlc-commits] commit: dvdread: clean up path handling and fix error message encoding ( Rémi Denis-Courmont )
git at videolan.org
git at videolan.org
Sun Oct 10 12:26:32 CEST 2010
vlc/vlc-1.1 | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun Oct 10 13:18:23 2010 +0300| [4637e0690748471cc2e589d014e7116b6ce8a1a6] | committer: Rémi Denis-Courmont
dvdread: clean up path handling and fix error message encoding
Paths given to msg_*() function must be UTF-8, not local.
(cherry picked from commit 140a43f3d3394f92b3d8079ce79e343dd0a6738e)
Conflicts:
modules/access/dvdread.c
> http://git.videolan.org/gitweb.cgi/vlc/vlc-1.1.git/?a=commit;h=4637e0690748471cc2e589d014e7116b6ce8a1a6
---
modules/access/dvdread.c | 37 ++++++++++++++++++++++---------------
1 files changed, 22 insertions(+), 15 deletions(-)
diff --git a/modules/access/dvdread.c b/modules/access/dvdread.c
index 66a9b84..fd32b6a 100644
--- a/modules/access/dvdread.c
+++ b/modules/access/dvdread.c
@@ -174,8 +174,7 @@ static int Open( vlc_object_t *p_this )
{
demux_t *p_demux = (demux_t*)p_this;
demux_sys_t *p_sys;
- char *psz_name;
- dvd_reader_t *p_dvdread;
+ char *psz_file;
ifo_handle_t *p_vmg_file;
if( !p_demux->psz_path || !*p_demux->psz_path )
@@ -184,30 +183,38 @@ static int Open( vlc_object_t *p_this )
if( !p_demux->psz_access || !*p_demux->psz_access )
return VLC_EGENERIC;
- psz_name = var_CreateGetString( p_this, "dvd" );
- if( !psz_name )
- {
- psz_name = strdup("");
- }
+ psz_file = var_InheritString( p_this, "dvd" );
}
else
- psz_name = ToLocaleDup( p_demux->psz_path );
+ psz_file = strdup( p_demux->psz_path );
#ifdef WIN32
- if( psz_name[0] && psz_name[1] == ':' &&
- psz_name[2] == '\\' && psz_name[3] == '\0' ) psz_name[2] = '\0';
+ if( psz_file != NULL )
+ {
+ size_t flen = strlen( psz_file );
+ if( flen > 0 && psz_file[flen - 1] == '\\' )
+ psz_file[flen - 1] = '\0';
+ }
+ else
+ psz_file = strdup("");
#endif
+ if( unlikely(psz_file == NULL) )
+ return VLC_EGENERIC;
/* Open dvdread */
- if( !(p_dvdread = DVDOpen( psz_name )) )
+ const char *psz_path = ToLocale( psz_file );
+ dvd_reader_t *p_dvdread = DVDOpen( psz_path );
+
+ LocaleFree( psz_path );
+ if( p_dvdread == NULL )
{
- msg_Err( p_demux, "DVDRead cannot open source: %s", psz_name );
+ msg_Err( p_demux, "DVDRead cannot open source: %s", psz_file );
dialog_Fatal( p_demux, _("Playback failure"),
- _("DVDRead could not open the disc \"%s\"."), psz_name );
- free( psz_name );
+ _("DVDRead could not open the disc \"%s\"."), psz_file );
+ free( psz_file );
return VLC_EGENERIC;
}
- free( psz_name );
+ free( psz_file );
/* Ifo allocation & initialisation */
if( !( p_vmg_file = ifoOpen( p_dvdread, 0 ) ) )
More information about the vlc-commits
mailing list