#endif
#include <vlc_common.h>
-#include <vlc_charset.h>
+#include <vlc_fs.h>
#include <vlc_url.h>
#ifdef HAVE_DIRENT_H
vlc_subfn_t *result = NULL; /* unsorted results */
char **result2; /* sorted results */
- const char *psz_fname = psz_name_org;
+ if( !psz_name_org )
+ return NULL;
+ char *psz_fname = make_path( psz_name_org );
if( !psz_fname )
return NULL;
- if( !strncmp( psz_fname, "file://", 7 ) )
- {
- psz_fname += 7;
- if( !strncmp( psz_fname, "localhost", 9 ) )
- psz_fname += 9;
- }
- psz_fname = decode_URI( psz_fname );
-
/* extract filename & dirname from psz_fname */
tmp = strrchr( psz_fname, DIR_SEP_CHAR );
if( tmp )
char *psz_cwd = NULL;
#endif
if( !psz_cwd )
+ {
+ free( psz_fname );
return NULL;
+ }
f_fname = strdup( psz_fname );
if( asprintf( &f_dir, "%s%c", psz_cwd, DIR_SEP_CHAR ) == -1 )
{
free( f_fname );
free( f_dir );
+ free( psz_fname );
return NULL;
}
free( f_dir );
free( f_fname_noext );
free( f_fname_trim );
+ free( psz_fname );
return NULL;
}
continue;
/* parse psz_src dir */
- i_dir_content = utf8_scandir( psz_dir, &ppsz_dir_content,
+ i_dir_content = vlc_scandir( psz_dir, &ppsz_dir_content,
subtitles_Filter, NULL );
if( i_dir_content < 0 )
continue;
if( !strcmp( psz_path, psz_fname ) )
continue;
- if( !utf8_stat( psz_path, &st ) && S_ISREG( st.st_mode ) && result )
+ if( !vlc_stat( psz_path, &st ) && S_ISREG( st.st_mode ) && result )
{
msg_Dbg( p_this,
"autodetected subtitle: %s with priority %d",
free( f_dir );
free( f_fname_trim );
free( f_fname_noext );
+ free( psz_fname );
if( !result )
return NULL;