[vlc-commits] metaengine: folder: test uri against folder first. (fix #10380)
Francois Cartegnie
git at videolan.org
Sun Mar 9 21:55:43 CET 2014
vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Sun Mar 9 21:50:34 2014 +0100| [e8c856b9a2c1e410b4e64f65b85184883e292ffa] | committer: Francois Cartegnie
metaengine: folder: test uri against folder first. (fix #10380)
because make_path strips last segment
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=e8c856b9a2c1e410b4e64f65b85184883e292ffa
---
modules/meta_engine/folder.c | 55 ++++++++++++++++++++++++++++++++----------
1 file changed, 42 insertions(+), 13 deletions(-)
diff --git a/modules/meta_engine/folder.c b/modules/meta_engine/folder.c
index 5cdb6ea..2e463eb 100644
--- a/modules/meta_engine/folder.c
+++ b/modules/meta_engine/folder.c
@@ -75,24 +75,54 @@ static int FindMeta( vlc_object_t *p_this )
art_finder_t *p_finder = (art_finder_t *)p_this;
input_item_t *p_item = p_finder->p_item;
bool b_have_art = false;
+ struct stat statinfo;
+ char *psz_path = NULL;
if( !p_item )
return VLC_EGENERIC;
- char *psz_dir = input_item_GetURI( p_item );
- if( !psz_dir )
+ char *psz_uri = input_item_GetURI( p_item );
+ if( !psz_uri )
return VLC_EGENERIC;
- char *psz_path = make_path( psz_dir );
- free( psz_dir );
- if( psz_path == NULL )
- return VLC_EGENERIC;
+ if ( *psz_uri && psz_uri[strlen( psz_uri ) - 1] != DIR_SEP_CHAR )
+ {
+ if ( asprintf( &psz_path, "%s"DIR_SEP, psz_uri ) == -1 )
+ {
+ free( psz_uri );
+ return VLC_EGENERIC;
+ }
+ char *psz_basedir = make_path( psz_path );
+ FREENULL( psz_path );
+ if( psz_basedir == NULL )
+ {
+ free( psz_uri );
+ return VLC_EGENERIC;
+ }
+ if( vlc_stat( psz_basedir, &statinfo ) == 0 && S_ISDIR(statinfo.st_mode) )
+ psz_path = psz_basedir;
+ else
+ free( psz_basedir );
+ }
+
+ if ( psz_path == NULL )
+ {
+ char *psz_basedir = make_path( psz_uri );
+ if( psz_basedir == NULL )
+ {
+ free( psz_uri );
+ return VLC_EGENERIC;
+ }
+
+ char *psz_buf = strrchr( psz_basedir, DIR_SEP_CHAR );
+ if( psz_buf )
+ *++psz_buf = '\0';
+ else
+ *psz_basedir = '\0'; /* relative path */
+ psz_path = psz_basedir;
+ }
- char *psz_buf = strrchr( psz_path, DIR_SEP_CHAR );
- if( psz_buf )
- *++psz_buf = '\0';
- else
- *psz_path = '\0'; /* relative path */
+ free( psz_uri );
for( int i = -1; !b_have_art && i < i_covers; i++ )
{
@@ -118,8 +148,7 @@ static int FindMeta( vlc_object_t *p_this )
if( unlikely(filepath == NULL) )
continue;
- struct stat dummy;
- if( vlc_stat( filepath, &dummy ) == 0 )
+ if( vlc_stat( filepath, &statinfo ) == 0 && S_ISREG(statinfo.st_mode) )
{
char *psz_uri = vlc_path2uri( filepath, "file" );
if( psz_uri )
More information about the vlc-commits
mailing list