Commit 543574fd authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont
Browse files

Another bunch of Unicode file names fixes (refs #528)

parent 19ae2576
......@@ -164,11 +164,9 @@ static int Open( vlc_object_t *p_this )
{
if( psz_name[0] == '~' && psz_name[1] == '/' )
{
psz = malloc( strlen(p_access->p_vlc->psz_homedir)
+ strlen(psz_name) );
/* This is incomplete : we should also support the ~cmassiot/
* syntax. */
sprintf( psz, "%s/%s", p_access->p_vlc->psz_homedir, psz_name + 2 );
asprintf( &psz, "%s/%s", p_access->p_vlc->psz_homedir, psz_name + 2 );
free( psz_name );
psz_name = psz;
}
......@@ -186,15 +184,12 @@ static int Open( vlc_object_t *p_this )
#endif
#ifdef HAVE_SYS_STAT_H
psz = ToLocale( psz_name );
if( stat( psz, &stat_info ) )
if( utf8_stat( psz_name, &stat_info ) )
{
msg_Warn( p_access, "%s: %s", psz_name, strerror( errno ) );
LocaleFree( psz );
free( psz_name );
return VLC_EGENERIC;
}
LocaleFree( psz );
#endif
}
......@@ -607,13 +602,9 @@ static int Control( access_t *p_access, int i_query, va_list args )
static int _OpenFile( access_t * p_access, const char * psz_name )
{
access_sys_t *p_sys = p_access->p_sys;
const char *psz_localname;
psz_localname = ToLocale( psz_name );
#ifdef UNDER_CE
p_sys->fd = fopen( psz_localname, "rb" );
LocaleFree( psz_localname );
p_sys->fd = utf8_fopen( psz_name, "rb" );
if ( !p_sys->fd )
{
msg_Err( p_access, "cannot open file %s", psz_name );
......@@ -625,6 +616,12 @@ static int _OpenFile( access_t * p_access, const char * psz_name )
p_access->info.i_update |= INPUT_UPDATE_SIZE;
fseek( p_sys->fd, 0, SEEK_SET );
#else
const char *psz_localname = ToLocale( psz_name );
if( psz_localname == NULL )
{
msg_Err( p_access, "incorrect file name %s", psz_name );
return VLC_EGENERIC;
}
p_sys->fd = open( psz_localname, O_NONBLOCK /*| O_LARGEFILE*/ );
LocaleFree( psz_localname );
......
......@@ -858,7 +858,7 @@ static int OpenVCDImage( vlc_object_t * p_this, const char *psz_dev,
/* Open the cue file and try to parse it */
msg_Dbg( p_this,"trying .cue file: %s", psz_cuefile );
cuefile = fopen( psz_cuefile, "rt" );
cuefile = utf8_fopen( psz_cuefile, "rt" );
if( cuefile && fscanf( cuefile, "FILE %c", line ) &&
fgets( line, 1024, cuefile ) )
{
......
......@@ -405,7 +405,7 @@ static void Dump( access_t *p_access, uint8_t *p_buffer, int i_buffer )
msg_Dbg( p_access, "dump in file '%s'", p_sys->psz_file );
p_sys->f = fopen( p_sys->psz_file, "wb" );
p_sys->f = utf8_fopen( p_sys->psz_file, "wb" );
if( p_sys->f == NULL )
{
msg_Err( p_access, "cannot open file '%s' (%s)",
......
......@@ -375,7 +375,7 @@ static int WriteBlockToFile( access_t *p_access, block_t *p_block )
sprintf( p_sys->psz_filename, "%s%i.dat",
p_sys->psz_filename_base, p_sys->i_files );
file = fopen( p_sys->psz_filename, "w+b" );
file = utf8_fopen( p_sys->psz_filename, "w+b" );
if( !file && p_sys->i_files < 2 )
{
......
......@@ -156,7 +156,7 @@ static int Open( vlc_object_t * p_this )
return VLC_EGENERIC;
}
p_aout->output.p_sys->p_file = fopen( psz_name, "wb" );
p_aout->output.p_sys->p_file = utf8_fopen( psz_name, "wb" );
free( psz_name );
if ( p_aout->output.p_sys->p_file == NULL )
{
......
......@@ -831,6 +831,8 @@ static void Run( intf_thread_t *p_intf )
/* We write the IOR in a file. */
{
FILE* fp;
/* no need for Unicode transliteration as long as VLC_IOR_FILE
is pure ASCII */
fp = fopen( VLC_IOR_FILE, "w" );
if( fp == NULL )
{
......@@ -843,7 +845,7 @@ static void Run( intf_thread_t *p_intf )
msg_Warn( p_intf, "IOR written to %s", VLC_IOR_FILE );
}
}
root_poa_manager = PortableServer_POA__get_the_POAManager( root_poa, ev );
handle_exception( "Exception during POAManager resolution" );
......
......@@ -91,13 +91,13 @@ static int DirectoryCheck( char *psz_dir )
#ifdef HAVE_SYS_STAT_H
struct stat stat_info;
if( stat( psz_dir, &stat_info ) == -1 || !S_ISDIR( stat_info.st_mode ) )
if( utf8_stat( psz_dir, &stat_info ) == -1 || !S_ISDIR( stat_info.st_mode ) )
{
return VLC_EGENERIC;
}
#endif
if( ( p_dir = opendir( psz_dir ) ) == NULL )
if( ( p_dir = utf8_opendir( psz_dir ) ) == NULL )
{
return VLC_EGENERIC;
}
......@@ -571,6 +571,7 @@ int E_(HttpCallback)( httpd_file_sys_t *p_args,
char **pp_data = (char **)_pp_data;
FILE *f;
/* FIXME: do we need character encoding translation here ? */
if( ( f = fopen( p_args->file, "r" ) ) == NULL )
{
Callback404( p_args, pp_data, pi_data );
......
......@@ -883,6 +883,8 @@ void E_(Execute)( httpd_file_sys_t *p_args,
strcpy( psz_file, m.param1 );
}
/* We hereby assume that psz_file is in the
* local character encoding */
if( ( f = fopen( psz_file, "r" ) ) == NULL )
{
msg_Warn( p_args->p_intf,
......
......@@ -109,7 +109,6 @@ int E_(ParseDirectory)( intf_thread_t *p_intf, char *psz_root,
struct stat stat_info;
#endif
DIR *p_dir;
struct dirent *p_dir_content;
vlc_acl_t *p_acl;
FILE *file;
......@@ -127,13 +126,13 @@ int E_(ParseDirectory)( intf_thread_t *p_intf, char *psz_root,
#endif
#ifdef HAVE_SYS_STAT_H
if( stat( psz_dir, &stat_info ) == -1 || !S_ISDIR( stat_info.st_mode ) )
if( utf8_stat( psz_dir, &stat_info ) == -1 || !S_ISDIR( stat_info.st_mode ) )
{
return VLC_EGENERIC;
}
#endif
if( ( p_dir = opendir( psz_dir ) ) == NULL )
if( ( p_dir = utf8_opendir( psz_dir ) ) == NULL )
{
msg_Err( p_intf, "cannot open dir (%s)", psz_dir );
return VLC_EGENERIC;
......@@ -149,7 +148,7 @@ int E_(ParseDirectory)( intf_thread_t *p_intf, char *psz_root,
msg_Dbg( p_intf, "dir=%s", psz_dir );
sprintf( dir, "%s%c.access", psz_dir, sep );
if( ( file = fopen( dir, "r" ) ) != NULL )
if( ( file = utf8_fopen( dir, "r" ) ) != NULL )
{
char line[1024];
int i_size;
......@@ -192,17 +191,20 @@ int E_(ParseDirectory)( intf_thread_t *p_intf, char *psz_root,
for( ;; )
{
char *psz_filename;
/* parse psz_src dir */
if( ( p_dir_content = readdir( p_dir ) ) == NULL )
if( ( psz_filename = utf8_readdir( p_dir ) ) == NULL )
{
break;
}
if( ( p_dir_content->d_name[0] == '.' )
|| ( i_dirlen + strlen( p_dir_content->d_name ) > MAX_DIR_SIZE ) )
if( ( psz_filename[0] == '.' )
|| ( i_dirlen + strlen( psz_filename ) > MAX_DIR_SIZE ) )
continue;
sprintf( dir, "%s%c%s", psz_dir, sep, p_dir_content->d_name );
sprintf( dir, "%s%c%s", psz_dir, sep, psz_filename );
LocaleFree( psz_filename );
if( E_(ParseDirectory)( p_intf, psz_root, dir ) )
{
httpd_file_sys_t *f = NULL;
......
......@@ -1580,7 +1580,7 @@ static int WriteUserKey( void *_p_drms, uint32_t *p_user_key )
snprintf( psz_path, PATH_MAX - 1, "%s/" DRMS_DIRNAME "/%08X.%03d",
p_drms->psz_homedir, p_drms->i_user, p_drms->i_key );
file = fopen( psz_path, "wb" );
file = utf8_fopen( psz_path, "wb" );
if( file != NULL )
{
i_ret = fwrite( p_user_key, sizeof(uint32_t),
......@@ -1608,7 +1608,7 @@ static int ReadUserKey( void *_p_drms, uint32_t *p_user_key )
"%s/" DRMS_DIRNAME "/%08X.%03d", p_drms->psz_homedir,
p_drms->i_user, p_drms->i_key );
file = fopen( psz_path, "rb" );
file = utf8_fopen( psz_path, "rb" );
if( file != NULL )
{
i_ret = fread( p_user_key, sizeof(uint32_t),
......@@ -1773,7 +1773,7 @@ static int GetSCIData( char *psz_ipod, uint32_t **pp_sci,
{
FILE *file;
char *psz_path = NULL;
char p_tmp[ PATH_MAX ];
char p_tmp[ 4 * PATH_MAX ];
int i_ret = -1;
if( psz_ipod == NULL )
......@@ -1799,7 +1799,12 @@ static int GetSCIData( char *psz_ipod, uint32_t **pp_sci,
strncat( p_tmp, p_filename, min( strlen( p_filename ),
(sizeof(p_tmp)/sizeof(p_tmp[0]) - 1) -
strlen( p_tmp ) ) );
psz_path = p_tmp;
psz_path = FromLocale( p_tmp );
strncpy( psz_tmp, sizeof( psz_tmp ) - 1, psz_path );
psz_tmp[sizeof( psz_tmp ) - 1] = '\0';
LocaleFree( psz_path );
psz_path = psz_tmp;
}
if( shfolder_dll != NULL )
......@@ -1828,7 +1833,7 @@ static int GetSCIData( char *psz_ipod, uint32_t **pp_sci,
return -1;
}
file = fopen( psz_path, "rb" );
file = utf8_fopen( psz_path, "rb" );
if( file != NULL )
{
struct stat st;
......
......@@ -158,7 +158,7 @@ static int Create( vlc_object_t *p_this )
}
/* Parse description file and allocate areas */
p_file = fopen( psz_descfilename, "r" );
p_file = utf8_fopen( psz_descfilename, "r" );
if( !p_file )
{
msg_Err( p_this, "Failed to open descritpion file %s",
......
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