argv[argc++] = FromLocale ("--plugin-path="TOP_BUILDDIR"/modules");
#endif
#ifdef TOP_SRCDIR
-# ifdef ENABLE_HTTPD
- argv[argc++] = FromLocale ("--http-src="TOP_SRCDIR"/share/http");
-# endif
+ argv[argc++] = FromLocale ("--data-path="TOP_SRCDIR"/share");
#endif
int i = 1;
VLC_EXPORT( void, __config_ResetAll, ( vlc_object_t * ) );
VLC_EXPORT( module_config_t *, config_FindConfig,( vlc_object_t *, const char * ) LIBVLC_USED );
-VLC_EXPORT(const char *, config_GetDataDir, ( void ) LIBVLC_USED);
+VLC_EXPORT(char *, __config_GetDataDir, ( vlc_object_t * ) LIBVLC_USED);
+#define config_GetDataDir(a) __config_GetDataDir(VLC_OBJECT(a))
VLC_EXPORT(const char *, config_GetConfDir, ( void ) LIBVLC_USED);
typedef enum vlc_userdir
psz_src = config_GetPsz( p_intf, "http-src" );
if( ( psz_src == NULL ) || ( *psz_src == '\0' ) )
{
- const char *data_path = config_GetDataDir ();
+ char *data_path = config_GetDataDir( p_intf );
if( asprintf( &psz_src, "%s" DIR_SEP "http", data_path ) == -1 )
psz_src = NULL;
+ free( data_path );
}
if( !psz_src || *psz_src == '\0' )
// A little theming
char *psz_rc_file = NULL;
- if( asprintf( &psz_rc_file, "%s/maemo/vlc_intf.rc",
- config_GetDataDir() ) != -1 )
+ char *psz_data = config_GetDataDir( p_intf );
+ if( asprintf( &psz_rc_file, "%s/maemo/vlc_intf.rc", psz_data ) != -1 )
{
gtk_rc_parse( psz_rc_file );
free( psz_rc_file );
}
+ free( psz_data );
// We create the main vertical box
main_vbox = gtk_vbox_new( FALSE, 0 );
char *datadir = config_GetUserDir( VLC_DATA_DIR );
m_resourcePath.push_back( (string)datadir + "\\skins" );
free( datadir );
- m_resourcePath.push_back( (string)config_GetDataDir() +
- "\\skins" );
- m_resourcePath.push_back( (string)config_GetDataDir() +
- "\\skins2" );
- m_resourcePath.push_back( (string)config_GetDataDir() +
- "\\share\\skins" );
- m_resourcePath.push_back( (string)config_GetDataDir() +
- "\\share\\skins2" );
+ datadir = config_GetDataDir( getIntf() );
+ m_resourcePath.push_back( (string)datadir + "\\skins" );
+ m_resourcePath.push_back( (string)datadir + "\\skins2" );
+ m_resourcePath.push_back( (string)datadir + "\\share\\skins" );
+ m_resourcePath.push_back( (string)datadir + "\\share\\skins2" );
+ free( datadir );
// All went well
return true;
m_resourcePath.push_back( (string)datadir + "/skins2" );
free( datadir );
m_resourcePath.push_back( (string)"share/skins2" );
- m_resourcePath.push_back( (string)config_GetDataDir () + "/skins2" );
+ datadir = config_GetDataDir( getIntf() );
+ m_resourcePath.push_back( (string)datadir + "/skins2" );
+ free( datadir );
return true;
}
/*****************************************************************************
*
*****************************************************************************/
-static char *FindFile( const char *psz_name )
+static char *FindFile( vlc_object_t *p_this, const char *psz_name )
{
char *ppsz_dir_list[] = { NULL, NULL, NULL, NULL };
char **ppsz_dir;
- vlclua_dir_list( "intf", ppsz_dir_list );
+ vlclua_dir_list( p_this, "intf", ppsz_dir_list );
for( ppsz_dir = ppsz_dir_list; *ppsz_dir; ppsz_dir++ )
{
char *psz_filename;
return VLC_ENOMEM;
}
p_sys = p_intf->p_sys;
- p_sys->psz_filename = FindFile( psz_name );
+ p_sys->psz_filename = FindFile( p_this, psz_name );
if( !p_sys->psz_filename )
{
msg_Err( p_intf, "Couldn't find lua interface script \"%s\".",
*****************************************************************************/
static int vlclua_datadir( lua_State *L )
{
- lua_pushstring( L, config_GetDataDir() );
+ char *psz_data = config_GetDataDir( vlclua_get_this( L ) );
+ lua_pushstring( L, psz_data );
+ free( psz_data );
return 1;
}
char **ppsz_dir = ppsz_dir_list;
int i = 1;
- if( vlclua_dir_list( psz_dirname, ppsz_dir_list ) != VLC_SUCCESS )
+ if( vlclua_dir_list( vlclua_get_this( L ), psz_dirname, ppsz_dir_list )
+ != VLC_SUCCESS )
return 0;
lua_newtable( L );
for( ; *ppsz_dir; ppsz_dir++ )
int i_fd = -1;
unsigned int i_count = 1;
- while( pi_fd[0][i_count] != -1 )
+ while( pi_fd[i_count] != -1 )
i_count++;
struct pollfd ufd[i_count+1];
return strcmp( *a, *b );
}
-int vlclua_dir_list( const char *luadirname, char **ppsz_dir_list )
+int vlclua_dir_list( vlc_object_t *p_this, const char *luadirname, char **ppsz_dir_list )
{
int i = 0;
char *datadir = config_GetUserDir( VLC_DATA_DIR );
free( datadir );
i++;
+ char *psz_datapath = config_GetDataDir( p_this );
# if defined(__APPLE__) || defined(SYS_BEOS) || defined(WIN32)
{
- const char *psz_vlcpath = config_GetDataDir();
if( asprintf( &ppsz_dir_list[i], "%s" DIR_SEP "lua" DIR_SEP "%s",
- psz_vlcpath, luadirname ) < 0 )
+ psz_datapath, luadirname ) < 0 )
return VLC_ENOMEM;
i++;
if( asprintf( &ppsz_dir_list[i], "%s" DIR_SEP "share" DIR_SEP "lua" DIR_SEP "%s",
- psz_vlcpath, luadirname ) < 0 )
+ psz_datapath, luadirname ) < 0 )
return VLC_ENOMEM;
i++;
}
# else
if( asprintf( &ppsz_dir_list[i], "%s" DIR_SEP "lua" DIR_SEP "%s",
- config_GetDataDir (), luadirname ) < 0 )
+ psz_datapath, luadirname ) < 0 )
return VLC_ENOMEM;
i++;
# endif
+ free( psz_datapath );
return VLC_SUCCESS;
}
char *ppsz_dir_list[] = { NULL, NULL, NULL, NULL };
char **ppsz_dir;
- i_ret = vlclua_dir_list( luadirname, ppsz_dir_list );
+ i_ret = vlclua_dir_list( p_this, luadirname, ppsz_dir_list );
if( i_ret != VLC_SUCCESS )
return i_ret;
i_ret = VLC_EGENERIC;
int vlclua_scripts_batch_execute( vlc_object_t *p_this, const char * luadirname,
int (*func)(vlc_object_t *, const char *, lua_State *, void *),
lua_State * L, void * user_data );
-int vlclua_dir_list( const char *luadirname, char **ppsz_dir_list );
+int vlclua_dir_list( vlc_object_t *p_this, const char *luadirname, char **ppsz_dir_list );
void vlclua_dir_list_free( char **ppsz_dir_list );
/*****************************************************************************
p_sys->app_name = CFSTR( "VLC media player" );
p_sys->notification_type = CFSTR( "New input playing" );
- const char *data_path = config_GetDataDir ();
+ char *data_path = config_GetDataDir ( p_this );
char buf[strlen (data_path) + sizeof ("/vlc48x48.png")];
snprintf (buf, sizeof (buf), "%s/vlc48x48.png", data_path);
+ free( data_path );
p_sys->default_icon = (CFDataRef) readFile( buf );
playlist_t *p_playlist = pl_Hold( p_intf );
{
GError *p_error = NULL;
char *psz_pixbuf;
- if( asprintf( &psz_pixbuf, "%s/vlc48x48.png", config_GetDataDir() ) >= 0 )
+ char *psz_data = config_GetDataDir( p_this );
+ if( asprintf( &psz_pixbuf, "%s/vlc48x48.png", psz_data ) >= 0 )
{
pix = gdk_pixbuf_new_from_file( psz_pixbuf, &p_error );
free( psz_pixbuf );
}
+ free( psz_data );
}
free( psz_arturl );
config/intf.c \
config/keys.c \
config/cmdline.c \
+ config/dirs.c \
misc/events.c \
misc/image.c \
misc/messages.c \
int __config_LoadCmdLine ( vlc_object_t *, int *, const char *[], bool );
int __config_LoadConfigFile( vlc_object_t *, const char * );
+const char *config_GetDataDirDefault( void );
+
int IsConfigStringType( int type );
int IsConfigIntegerType (int type);
static inline int IsConfigFloatType (int type)
--- /dev/null
+/*****************************************************************************
+ * dirs.c: crossplatform directories configuration
+ *****************************************************************************
+ * Copyright (C) 2009 the VideoLAN team
+ *
+ * Authors: Antoine Cellerier <dionoea at videolan dot org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <vlc_common.h>
+
+#include "../libvlc.h"
+
+#include "configuration.h"
+
+/**
+ * Determines the shared data directory
+ *
+ * @return a string (always succeeds). Needs to be freed.
+ */
+char *__config_GetDataDir( vlc_object_t *p_obj )
+{
+ char *psz_path = config_GetPsz( p_obj, "data-path" );
+ if( psz_path && *psz_path )
+ return psz_path;
+ free( psz_path );
+ return strdup( config_GetDataDirDefault() );
+}
+
return configdir;
}
-const char *config_GetDataDir (void)
+const char *config_GetDataDirDefault (void)
{
pthread_once(&once, init_dirs);
return datadir;
#include <assert.h>
#include <limits.h>
-const char *config_GetDataDir( void )
+const char *config_GetDataDirDefault( void )
{
static char path[PATH_MAX] = "";
#warning FIXME: thread-safety!
*
* @return a string (always succeeds).
*/
-const char *config_GetDataDir( void )
+const char *config_GetDataDirDefault( void )
{
return DATA_PATH;
}
"Additional path for VLC to look for its modules. You can add " \
"several paths by concatenating them using \" PATH_SEP \" as separator")
+#define DATA_PATH_TEXT N_("Data search path")
+#define DATA_PATH_LONGTEXT N_( \
+ "Override the default data/share search path.")
+
#define VLM_CONF_TEXT N_("VLM configuration file")
#define VLM_CONF_LONGTEXT N_( \
"Read a VLM configuration file as soon as VLM is started." )
add_directory( "plugin-path", NULL, NULL, PLUGIN_PATH_TEXT,
PLUGIN_PATH_LONGTEXT, true )
change_need_restart ()
+ add_directory( "data-path", NULL, NULL, DATA_PATH_TEXT,
+ DATA_PATH_LONGTEXT, true )
+ change_need_restart ()
set_section( N_("Performance options"), NULL )
add_obsolete_bool( "minimize-threads" )
__config_ExistIntf
config_FindConfig
config_GetConfDir
-config_GetDataDir
+__config_GetDataDir
__config_GetFloat
config_GetUserDir
__config_GetInt