#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
+#include <sys/stat.h>
#include <ctype.h>
+#include "input_internal.h"
/**
* We are not going to autodetect more subtitle files than this.
/**
* Convert a list of paths separated by ',' to a char**
*/
-static char **paths_to_list( char *psz_dir, char *psz_path )
+static char **paths_to_list( const char *psz_dir, char *psz_path )
{
unsigned int i, k, i_nb_subdirs;
char **subdirs; /* list of subdirectories to look in */
* The array contains max MAX_SUBTITLE_FILES items and you need to free it after use.
*/
char **subtitles_Detect( input_thread_t *p_this, char *psz_path,
- char *psz_name )
+ const char *psz_name )
{
vlc_value_t fuzzy;
int j, i_result2, i_sub_count = 0, i_fname_len = 0;
msg_Dbg( p_this, "looking for a subtitle file in %s", psz_dir );
for( a = 0; a < i_dir_content; a++ )
{
- char *psz_name = vlc_fix_readdir_charset( p_this,
- ppsz_dir_content[a] );
+ char *psz_name = ppsz_dir_content[a];
char tmp_fname_noext[strlen( psz_name ) + 1];
char tmp_fname_trim[strlen( psz_name ) + 1];
char tmp_fname_ext[strlen( psz_name ) + 1];
}
if( i_prio >= fuzzy.i_int )
{
- FILE *f;
char psz_path[strlen( psz_dir ) + strlen( psz_name ) + 1];
+ struct stat st;
sprintf( psz_path, "%s%s", psz_dir, psz_name );
msg_Dbg( p_this,
"autodetected subtitle: %s with priority %d",
psz_path, i_prio );
- /* FIXME: a portable wrapper for stat() or access() would be more suited */
- if( ( f = utf8_fopen( psz_path, "rt" ) ) )
+
+ if( utf8_stat( psz_path, &st ) && S_ISREG( st.st_mode ) )
{
- fclose( f );
msg_Dbg( p_this,
"autodetected subtitle: %s with priority %d",
psz_path, i_prio );
}
}
if( i_sub_count >= MAX_SUBTITLE_FILES ) break;
- free( psz_name );
}
for( a = 0; a < i_dir_content; a++ )
free( ppsz_dir_content[a] );