#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
+#ifdef HAVE_SYS_STAT_H
+# include <sys/stat.h>
+#endif
#include <vlc_common.h>
#include <vlc_update.h>
char *psz_tmpdestfile = NULL;
FILE *p_file = NULL;
+ struct stat p_stat;
stream_t *p_stream = NULL;
void* p_buffer = NULL;
int i_read;
goto end;
}
psz_tmpdestfile++;
- if( asprintf( &psz_destfile, "%s%s", psz_destdir, psz_tmpdestfile ) == -1 )
- goto end;
+
+ if( utf8_stat( psz_destdir, &p_stat) == 0 && (p_stat.st_mode & S_IFDIR) )
+ {
+ if( asprintf( &psz_destfile, "%s%c%s", psz_destdir, DIR_SEP_CHAR, psz_tmpdestfile ) == -1 )
+ goto end;
+ }
+ else if( psz_destdir )
+ psz_destfile = strdup( psz_destdir );
+ else
+ psz_destfile = strdup( psz_tmpdestfile );
p_file = utf8_fopen( psz_destfile, "w" );
if( !p_file )
{
msg_Err( p_udt, "Failed to open %s for writing", psz_destfile );
+ intf_UserFatal( p_udt, true, _("Saving file failed"),
+ _("Failed to open \"%s\" for writing"),
+ psz_destfile );
goto end;
}