Use environment variable for data directory

...as for plugins directory. Most of the content is anyway per-process,
either because gettext and interfaces are per-process. The only caller
of the function that is not an interface or gettext is the DVB scanner.
This is even probably a bug.
This commit is contained in:
Rémi Denis-Courmont 2012-03-20 20:41:56 +02:00
parent 85f5c15fe5
commit feb4063c35
13 changed files with 18 additions and 19 deletions

View File

@ -100,6 +100,7 @@ int main( int i_argc, const char *ppsz_argv[] )
#ifdef TOP_BUILDDIR
setenv ("VLC_PLUGIN_PATH", TOP_BUILDDIR"/modules", 1);
setenv ("VLC_DATA_PATH", TOP_SRCDIR"/share", 1);
#endif
/* Clear the X.Org startup notification ID. Otherwise the UI might try to
@ -167,14 +168,11 @@ int main( int i_argc, const char *ppsz_argv[] )
/* Block all these signals */
pthread_sigmask (SIG_SETMASK, &set, NULL);
const char *argv[i_argc + 3];
const char *argv[i_argc + 2];
int argc = 0;
argv[argc++] = "--no-ignore-config";
argv[argc++] = "--media-library";
#ifdef TOP_SRCDIR
argv[argc++] = "--data-path="TOP_SRCDIR"/share";
#endif
ppsz_argv++; i_argc--; /* skip executable path */
#ifdef __APPLE__
/* When VLC.app is run by double clicking in Mac OS X, the 2nd arg

View File

@ -123,6 +123,7 @@ int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
#ifndef UNDER_CE
#ifdef TOP_BUILDDIR
putenv("VLC_PLUGIN_PATH=Z:"TOP_BUILDDIR"/modules");
putenv("VLC_DATA_PATH=Z:"TOP_SRCDIR"/share");
#endif
HeapSetInformation(NULL, HeapEnableTerminationOnCorruption, NULL, 0);

View File

@ -194,8 +194,7 @@ VLC_API void config_ResetAll( vlc_object_t * );
#define config_ResetAll(a) config_ResetAll(VLC_OBJECT(a))
VLC_API module_config_t * config_FindConfig( vlc_object_t *, const char * ) VLC_USED;
VLC_API char * config_GetDataDir( vlc_object_t * ) VLC_USED VLC_MALLOC;
#define config_GetDataDir(a) config_GetDataDir(VLC_OBJECT(a))
VLC_API char * config_GetDataDir(void) VLC_USED VLC_MALLOC;
VLC_API char *config_GetLibDir(void) VLC_USED;
VLC_API const char * config_GetConfDir( void ) VLC_USED;

View File

@ -248,7 +248,7 @@ static int ScanDvbSNextFast( scan_t *p_scan, scan_configuration_t *p_cfg, double
DIR *p_dir;
char *psz_dir = NULL;
char *data_dir = config_GetDataDir( p_scan->p_obj );
char *data_dir = config_GetDataDir();
if( asprintf( &psz_dir, "%s" DIR_SEP "dvb" DIR_SEP "dvb-s", data_dir ) == -1 )
psz_dir = NULL;

View File

@ -173,7 +173,7 @@ static void *Thread( void *obj )
// A little theming
char *psz_rc_file = NULL;
char *psz_data = config_GetDataDir( p_intf );
char *psz_data = config_GetDataDir();
if( asprintf( &psz_rc_file, "%s/maemo/vlc_intf.rc", psz_data ) != -1 )
{
gtk_rc_parse( psz_rc_file );

View File

@ -234,7 +234,7 @@ bool Win32Factory::init()
char *datadir = config_GetUserDir( VLC_DATA_DIR );
m_resourcePath.push_back( (string)datadir + "\\skins" );
free( datadir );
datadir = config_GetDataDir( getIntf() );
datadir = config_GetDataDir();
m_resourcePath.push_back( (string)datadir + "\\skins" );
m_resourcePath.push_back( (string)datadir + "\\skins2" );
m_resourcePath.push_back( (string)datadir + "\\share\\skins" );

View File

@ -87,7 +87,7 @@ bool X11Factory::init()
m_resourcePath.push_back( (string)datadir + "/skins2" );
free( datadir );
m_resourcePath.push_back( (string)"share/skins2" );
datadir = config_GetDataDir( getIntf() );
datadir = config_GetDataDir();
m_resourcePath.push_back( (string)datadir + "/skins2" );
free( datadir );

View File

@ -107,7 +107,7 @@ static int vlclua_config_set( lua_State *L )
*****************************************************************************/
static int vlclua_datadir( lua_State *L )
{
char *psz_data = config_GetDataDir( vlclua_get_this( L ) );
char *psz_data = config_GetDataDir();
lua_pushstring( L, psz_data );
free( psz_data );
return 1;

View File

@ -226,7 +226,7 @@ int vlclua_dir_list( vlc_object_t *p_this, const char *luadirname,
}
#endif
char *psz_datapath = config_GetDataDir( p_this );
char *psz_datapath = config_GetDataDir();
if( likely(psz_datapath != NULL) )
{
if( likely(asprintf( &ppsz_dir_list[i], "%s"DIR_SEP"lua"DIR_SEP"%s",

View File

@ -117,7 +117,7 @@ static int Open( vlc_object_t *p_this )
p_sys->app_name = CFSTR( "VLC media player" );
p_sys->notification_type = CFSTR( "New input playing" );
char *data_path = config_GetDataDir ( p_this );
char *data_path = config_GetDataDir ();
char buf[strlen (data_path) + sizeof ("/vlc512x512.png")];
snprintf (buf, sizeof (buf), "%s/vlc512x512.png", data_path);
msg_Dbg( p_this, "looking for icon at %s", buf );

View File

@ -240,7 +240,7 @@ static int ItemChange( vlc_object_t *p_this, const char *psz_var,
/* Load icon from share/ */
GError *p_error = NULL;
char *psz_pixbuf;
char *psz_data = config_GetDataDir( p_this );
char *psz_data = config_GetDataDir();
if( asprintf( &psz_pixbuf, "%s/icons/48x48/vlc.png", psz_data ) >= 0 )
{
pix = gdk_pixbuf_new_from_file( psz_pixbuf, &p_error );

View File

@ -369,7 +369,7 @@ static void *Thread( void *p_data )
#ifdef WIN32
if ( psz_preset_path == NULL )
{
char *psz_data_path = config_GetDataDir( p_filter );
char *psz_data_path = config_GetDataDir();
asprintf( &psz_preset_path, "%s" DIR_SEP "visualization", psz_data_path );
free( psz_data_path );
}

View File

@ -30,15 +30,16 @@
#include "configuration.h"
#undef config_GetDataDir
/**
* Determines the shared architecture-independent data directory
*
* @return a string or NULL. Use free() to release.
*/
char *config_GetDataDir( vlc_object_t *p_obj )
char *config_GetDataDir(void)
{
char *psz_path = var_InheritString( p_obj, "data-path" );
return psz_path ? psz_path : config_GetDataDirDefault();
const char *path = getenv ("VLC_DATA_PATH");
if (path)
return strdup (path);
return config_GetDataDirDefault();
}