Commit 082ff1ef authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Locale fixes (refs #528) + clean up

parent 4d4cf035
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#include <vlc/vlc.h> #include <vlc/vlc.h>
#include <vlc/sout.h> #include <vlc/sout.h>
#include "charset.h"
#ifdef HAVE_UNISTD_H #ifdef HAVE_UNISTD_H
# include <unistd.h> # include <unistd.h>
...@@ -101,28 +102,22 @@ static int Open( vlc_object_t *p_this ) ...@@ -101,28 +102,22 @@ static int Open( vlc_object_t *p_this )
sout_CfgParse( p_access, SOUT_CFG_PREFIX, ppsz_sout_options, p_access->p_cfg ); sout_CfgParse( p_access, SOUT_CFG_PREFIX, ppsz_sout_options, p_access->p_cfg );
if( !( p_access->p_sys = malloc( sizeof( sout_access_out_sys_t ) ) ) )
{
msg_Err( p_access, "out of memory" );
return( VLC_EGENERIC );
}
if( !p_access->psz_name ) if( !p_access->psz_name )
{ {
msg_Err( p_access, "no file name specified" ); msg_Err( p_access, "no file name specified" );
return VLC_EGENERIC; return VLC_EGENERIC;
} }
i_flags = O_RDWR|O_CREAT|O_LARGEFILE;
var_Get( p_access, SOUT_CFG_PREFIX "append", &val ); if( !( p_access->p_sys = malloc( sizeof( sout_access_out_sys_t ) ) ) )
if( val.b_bool )
{
i_flags |= O_APPEND;
}
else
{ {
i_flags |= O_TRUNC; return( VLC_ENOMEM );
} }
i_flags = O_RDWR|O_CREAT|O_LARGEFILE;
var_Get( p_access, SOUT_CFG_PREFIX "append", &val );
i_flags |= val.b_bool ? O_APPEND : O_TRUNC;
if( !strcmp( p_access->psz_name, "-" ) ) if( !strcmp( p_access->psz_name, "-" ) )
{ {
#if defined(WIN32) #if defined(WIN32)
...@@ -131,12 +126,20 @@ static int Open( vlc_object_t *p_this ) ...@@ -131,12 +126,20 @@ static int Open( vlc_object_t *p_this )
p_access->p_sys->i_handle = STDOUT_FILENO; p_access->p_sys->i_handle = STDOUT_FILENO;
msg_Dbg( p_access, "using stdout" ); msg_Dbg( p_access, "using stdout" );
} }
else if( ( p_access->p_sys->i_handle = else
open( p_access->psz_name, i_flags, 0666 ) ) == -1 )
{ {
msg_Err( p_access, "cannot open `%s'", p_access->psz_name ); const char *psz_localname = ToLocale( p_access->psz_name );
free( p_access->p_sys ); int fd = open( psz_localname, i_flags, 0666 );
return( VLC_EGENERIC ); LocaleFree( psz_localname );
if( fd == -1 )
{
msg_Err( p_access, "cannot open `%s' (%s)", p_access->psz_name,
strerror( errno ) );
free( p_access->p_sys );
return( VLC_EGENERIC );
}
p_access->p_sys->i_handle = fd;
} }
p_access->pf_write = Write; p_access->pf_write = Write;
......
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