mirror of https://github.com/mpv-player/mpv
add uri2filename converter
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@6997 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
parent
2d55a9e67c
commit
b5bb6e8f73
|
@ -29,6 +29,14 @@
|
|||
#include <inttypes.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifdef USE_ICONV
|
||||
#ifdef __FreeBSD__
|
||||
#include <giconv.h>
|
||||
#else
|
||||
#include <iconv.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include "../libmpdemux/stream.h"
|
||||
#include "../libmpdemux/demuxer.h"
|
||||
|
||||
|
@ -76,6 +84,49 @@ void gset( char ** str,char * what )
|
|||
else gstrcat( str,what );
|
||||
}
|
||||
|
||||
#ifdef USE_ICONV
|
||||
char * gconvert_uri_to_filename( char * str )
|
||||
{
|
||||
iconv_t d;
|
||||
char * out = strdup( str );
|
||||
char * tmp = NULL;
|
||||
char * ize;
|
||||
size_t inb,outb;
|
||||
char * charset = "ISO8859-1";
|
||||
char * cs;
|
||||
|
||||
if ( !strchr( str,'%' ) ) return str;
|
||||
|
||||
{
|
||||
char * t = calloc( 1,strlen( out ) );
|
||||
int i,c = 0;
|
||||
for ( i=0;i < (int)strlen( out );i++ )
|
||||
if ( out[i] != '%' ) t[c++]=out[i];
|
||||
else
|
||||
{
|
||||
char tmp[4] = "0xXX";
|
||||
// if ( out[++i] == '%' ) { t[c++]='%'; continue; };
|
||||
tmp[2]=out[++i]; tmp[3]=out[++i];
|
||||
t[c++]=(char)strtol( tmp,(char **)NULL,0 );
|
||||
}
|
||||
free( out );
|
||||
out=t;
|
||||
}
|
||||
|
||||
if ( (cs=getenv( "CHARSET" )) && *cs ) charset=cs;
|
||||
|
||||
inb=outb=strlen( out );
|
||||
tmp=calloc( 1,outb + 1 );
|
||||
ize=tmp;
|
||||
d=iconv_open( charset,"UTF-8" );
|
||||
if ( (iconv_t)(-1) == d ) return str;
|
||||
iconv( d,&out,&inb,&tmp,&outb );
|
||||
iconv_close( d );
|
||||
free( out );
|
||||
return ize;
|
||||
}
|
||||
#endif
|
||||
|
||||
void guiInit( void )
|
||||
{
|
||||
memset( &guiIntfStruct,0,sizeof( guiIntfStruct ) );
|
||||
|
|
|
@ -171,6 +171,7 @@ extern float gtkEquChannels[6][10];
|
|||
|
||||
extern void * gtkSet( int cmd,float param, void * vparam );
|
||||
|
||||
extern char * gconvert_uri_to_filename( char * str );
|
||||
extern char * gstrdup( char * str );
|
||||
extern int gstrcmp( char * a,char * b );
|
||||
extern void gfree( void ** p );
|
||||
|
|
|
@ -668,20 +668,13 @@ void mplDandDHandler(int num,const char** files)
|
|||
char* str = strdup( files[f] );
|
||||
plItem* item;
|
||||
|
||||
#ifdef USE_ICONV
|
||||
if ( strchr( str,'%' ) )
|
||||
{
|
||||
char * t = calloc( 1,strlen( str ) );
|
||||
int i,c = 0;
|
||||
for ( i=0;i < strlen( str );i++ )
|
||||
if ( str[i] != '%' ) t[c++]=str[i];
|
||||
else
|
||||
{
|
||||
char tmp[4] = "0xXX";
|
||||
// if ( str[++i] == '%' ) { t[c++]='%'; continue; };
|
||||
tmp[2]=str[++i]; tmp[3]=str[++i]; t[c++]=(char)strtol( tmp,(char **)NULL,16 );
|
||||
}
|
||||
free( str ); str=t;
|
||||
char * tmp=gconvert_uri_to_filename( str );
|
||||
free( str ); str=tmp;
|
||||
}
|
||||
#endif
|
||||
|
||||
if(stat(str,&buf) == 0 && S_ISDIR(buf.st_mode) == 0) {
|
||||
/* this is not a directory so try to play it */
|
||||
|
|
|
@ -107,9 +107,11 @@ void mplEnd( void )
|
|||
guiIntfStruct.TimeSec=0;
|
||||
guiIntfStruct.Position=0;
|
||||
guiIntfStruct.AudioType=0;
|
||||
#ifdef USE_DVDREAD
|
||||
guiIntfStruct.DVD.current_title=1;
|
||||
guiIntfStruct.DVD.current_chapter=1;
|
||||
guiIntfStruct.DVD.current_angle=1;
|
||||
#endif
|
||||
|
||||
if ( !appMPlayer.subWindow.isFullScreen )
|
||||
{
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
|
||||
#include "../../config.h"
|
||||
#include "../../help_mp.h"
|
||||
#include "../../mp_msg.h"
|
||||
|
||||
GtkWidget * PopUpMenu = NULL;
|
||||
|
||||
|
|
Loading…
Reference in New Issue