Commit 28e52ddb authored by Antoine Cellerier's avatar Antoine Cellerier Committed by Antoine Cellerier

Add --data-path option. Access the src share directory now works from build tree.

parent 8241e584
......@@ -133,9 +133,7 @@ int main( int i_argc, const char *ppsz_argv[] )
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;
......
......@@ -214,7 +214,8 @@ VLC_EXPORT( int, __config_SaveConfigFile, ( vlc_object_t *, const char * ) );
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
......
......@@ -232,9 +232,10 @@ static int Open( vlc_object_t *p_this )
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' )
......
......@@ -158,12 +158,13 @@ static void Run( intf_thread_t *p_intf )
// 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 );
......
......@@ -229,14 +229,12 @@ bool Win32Factory::init()
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;
......
......@@ -80,7 +80,9 @@ bool X11Factory::init()
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;
}
......
......@@ -57,11 +57,11 @@ static const char * const ppsz_intf_options[] = { "intf", "config", NULL };
/*****************************************************************************
*
*****************************************************************************/
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;
......@@ -162,7 +162,7 @@ int Open_LuaIntf( vlc_object_t *p_this )
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\".",
......
......@@ -114,7 +114,9 @@ static int vlclua_quit( lua_State *L )
*****************************************************************************/
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;
}
......@@ -157,7 +159,8 @@ static int vlclua_datadir_list( lua_State *L )
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++ )
......
......@@ -132,7 +132,7 @@ static int vlclua_net_accept( lua_State *L )
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];
......
......@@ -105,7 +105,7 @@ static int file_compare( const char **a, const char **b )
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 );
......@@ -121,25 +121,26 @@ int vlclua_dir_list( const char *luadirname, char **ppsz_dir_list )
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;
}
......@@ -169,7 +170,7 @@ int vlclua_scripts_batch_execute( vlc_object_t *p_this,
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;
......
......@@ -105,7 +105,7 @@ int vlclua_push_ret( lua_State *, int i_error );
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 );
/*****************************************************************************
......
......@@ -115,9 +115,10 @@ static int Open( vlc_object_t *p_this )
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 );
......
......@@ -224,11 +224,13 @@ static int ItemChange( vlc_object_t *p_this, const char *psz_var,
{
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 );
......
......@@ -428,6 +428,7 @@ SOURCES_libvlc_common = \
config/intf.c \
config/keys.c \
config/cmdline.c \
config/dirs.c \
misc/events.c \
misc/image.c \
misc/messages.c \
......
......@@ -45,6 +45,8 @@ void config_UnsetCallbacks( module_config_t *, size_t );
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)
......
/*****************************************************************************
* 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() );
}
......@@ -49,7 +49,7 @@ const char *config_GetConfDir( void )
return configdir;
}
const char *config_GetDataDir (void)
const char *config_GetDataDirDefault (void)
{
pthread_once(&once, init_dirs);
return datadir;
......
......@@ -43,7 +43,7 @@
#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!
......
......@@ -40,7 +40,7 @@
*
* @return a string (always succeeds).
*/
const char *config_GetDataDir( void )
const char *config_GetDataDirDefault( void )
{
return DATA_PATH;
}
......
......@@ -1120,6 +1120,10 @@ static const char *const ppsz_clock_descriptions[] =
"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." )
......@@ -2033,6 +2037,9 @@ vlc_module_begin ()
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" )
......
......@@ -52,7 +52,7 @@ __config_ChainParse
__config_ExistIntf
config_FindConfig
config_GetConfDir
config_GetDataDir
__config_GetDataDir
__config_GetFloat
config_GetUserDir
__config_GetInt
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment