[demux/avi] Enable dirac support (Set PTS on first output block)
[vlc/davidf-public.git] / modules / meta_engine / folder.c
blobe6493e0e2e8d5545a72a26397196d8cba7843f78
1 /*****************************************************************************
2 * folder.c
3 *****************************************************************************
4 * Copyright (C) 2006 the VideoLAN team
5 * $Id$
7 * Authors: Antoine Cellerier <dionoea -at- videolan -dot- org>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
24 /*****************************************************************************
25 * Preamble
26 *****************************************************************************/
28 #ifdef HAVE_CONFIG_H
29 # include "config.h"
30 #endif
32 #include <vlc_common.h>
33 #include <vlc_plugin.h>
34 #include <vlc_interface.h>
35 #include <vlc_meta.h>
36 #include <vlc_playlist.h>
37 #include <vlc_input.h>
38 #include <vlc_charset.h>
40 #ifdef HAVE_SYS_STAT_H
41 # include <sys/stat.h>
42 #endif
44 #ifndef MAX_PATH
45 # define MAX_PATH 250
46 #endif
48 /*****************************************************************************
49 * Local prototypes
50 *****************************************************************************/
51 static int FindMeta( vlc_object_t * );
53 /*****************************************************************************
54 * Module descriptor
55 *****************************************************************************/
57 vlc_module_begin();
58 set_shortname( N_( "Folder" ) );
59 set_description( N_("Folder meta data") );
61 set_capability( "art finder", 90 );
62 set_callbacks( FindMeta, NULL );
63 vlc_module_end();
65 /*****************************************************************************
66 *****************************************************************************/
67 static int FindMeta( vlc_object_t *p_this )
69 playlist_t *p_playlist = (playlist_t *)p_this;
70 input_item_t *p_item = (input_item_t *)(p_playlist->p_private);
71 bool b_have_art = false;
73 int i = 0;
74 struct stat a;
75 char psz_filename[MAX_PATH];
76 if( !p_item )
77 return VLC_EGENERIC;
79 char *psz_dir = input_item_GetURI( p_item );
80 if( !psz_dir )
81 return VLC_EGENERIC;
83 char *psz_buf = strrchr( psz_dir, '/' );
84 if( psz_buf )
86 psz_buf++;
87 *psz_buf = '\0';
89 else
91 *psz_dir = '\0';
94 char *psz_path = psz_dir;
95 if( !strncmp( psz_path, "file://", 7 ) )
96 psz_path += 7;
98 for( i = 0; b_have_art == false && i < 3; i++ )
100 switch( i )
102 case 0:
103 /* Windows Folder.jpg */
104 snprintf( psz_filename, MAX_PATH,
105 "file://%sFolder.jpg", psz_path );
106 break;
108 case 1:
109 /* Windows AlbumArtSmall.jpg == small version of Folder.jpg */
110 snprintf( psz_filename, MAX_PATH,
111 "file://%sAlbumArtSmall.jpg", psz_path );
112 break;
114 case 2:
115 /* KDE (?) .folder.png */
116 snprintf( psz_filename, MAX_PATH,
117 "file://%s.folder.png", psz_path );
118 break;
121 if( utf8_stat( psz_filename+7, &a ) != -1 )
123 input_item_SetArtURL( p_item, psz_filename );
124 b_have_art = true;
128 free( psz_dir );
130 return b_have_art ? VLC_SUCCESS : VLC_EGENERIC;