Commit feb4063c authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

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.
parent 85f5c15f
...@@ -100,6 +100,7 @@ int main( int i_argc, const char *ppsz_argv[] ) ...@@ -100,6 +100,7 @@ int main( int i_argc, const char *ppsz_argv[] )
#ifdef TOP_BUILDDIR #ifdef TOP_BUILDDIR
setenv ("VLC_PLUGIN_PATH", TOP_BUILDDIR"/modules", 1); setenv ("VLC_PLUGIN_PATH", TOP_BUILDDIR"/modules", 1);
setenv ("VLC_DATA_PATH", TOP_SRCDIR"/share", 1);
#endif #endif
/* Clear the X.Org startup notification ID. Otherwise the UI might try to /* 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[] ) ...@@ -167,14 +168,11 @@ int main( int i_argc, const char *ppsz_argv[] )
/* Block all these signals */ /* Block all these signals */
pthread_sigmask (SIG_SETMASK, &set, NULL); pthread_sigmask (SIG_SETMASK, &set, NULL);
const char *argv[i_argc + 3]; const char *argv[i_argc + 2];
int argc = 0; int argc = 0;
argv[argc++] = "--no-ignore-config"; argv[argc++] = "--no-ignore-config";
argv[argc++] = "--media-library"; argv[argc++] = "--media-library";
#ifdef TOP_SRCDIR
argv[argc++] = "--data-path="TOP_SRCDIR"/share";
#endif
ppsz_argv++; i_argc--; /* skip executable path */ ppsz_argv++; i_argc--; /* skip executable path */
#ifdef __APPLE__ #ifdef __APPLE__
/* When VLC.app is run by double clicking in Mac OS X, the 2nd arg /* When VLC.app is run by double clicking in Mac OS X, the 2nd arg
......
...@@ -123,6 +123,7 @@ int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, ...@@ -123,6 +123,7 @@ int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
#ifndef UNDER_CE #ifndef UNDER_CE
#ifdef TOP_BUILDDIR #ifdef TOP_BUILDDIR
putenv("VLC_PLUGIN_PATH=Z:"TOP_BUILDDIR"/modules"); putenv("VLC_PLUGIN_PATH=Z:"TOP_BUILDDIR"/modules");
putenv("VLC_DATA_PATH=Z:"TOP_SRCDIR"/share");
#endif #endif
HeapSetInformation(NULL, HeapEnableTerminationOnCorruption, NULL, 0); HeapSetInformation(NULL, HeapEnableTerminationOnCorruption, NULL, 0);
......
...@@ -194,8 +194,7 @@ VLC_API void config_ResetAll( vlc_object_t * ); ...@@ -194,8 +194,7 @@ VLC_API void config_ResetAll( vlc_object_t * );
#define config_ResetAll(a) config_ResetAll(VLC_OBJECT(a)) #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 module_config_t * config_FindConfig( vlc_object_t *, const char * ) VLC_USED;
VLC_API char * config_GetDataDir( vlc_object_t * ) VLC_USED VLC_MALLOC; VLC_API char * config_GetDataDir(void) VLC_USED VLC_MALLOC;
#define config_GetDataDir(a) config_GetDataDir(VLC_OBJECT(a))
VLC_API char *config_GetLibDir(void) VLC_USED; VLC_API char *config_GetLibDir(void) VLC_USED;
VLC_API const char * config_GetConfDir( void ) VLC_USED; VLC_API const char * config_GetConfDir( void ) VLC_USED;
......
...@@ -248,7 +248,7 @@ static int ScanDvbSNextFast( scan_t *p_scan, scan_configuration_t *p_cfg, double ...@@ -248,7 +248,7 @@ static int ScanDvbSNextFast( scan_t *p_scan, scan_configuration_t *p_cfg, double
DIR *p_dir; DIR *p_dir;
char *psz_dir = NULL; 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 ) if( asprintf( &psz_dir, "%s" DIR_SEP "dvb" DIR_SEP "dvb-s", data_dir ) == -1 )
psz_dir = NULL; psz_dir = NULL;
......
...@@ -173,7 +173,7 @@ static void *Thread( void *obj ) ...@@ -173,7 +173,7 @@ static void *Thread( void *obj )
// A little theming // A little theming
char *psz_rc_file = NULL; 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 ) if( asprintf( &psz_rc_file, "%s/maemo/vlc_intf.rc", psz_data ) != -1 )
{ {
gtk_rc_parse( psz_rc_file ); gtk_rc_parse( psz_rc_file );
......
...@@ -234,7 +234,7 @@ bool Win32Factory::init() ...@@ -234,7 +234,7 @@ bool Win32Factory::init()
char *datadir = config_GetUserDir( VLC_DATA_DIR ); char *datadir = config_GetUserDir( VLC_DATA_DIR );
m_resourcePath.push_back( (string)datadir + "\\skins" ); m_resourcePath.push_back( (string)datadir + "\\skins" );
free( datadir ); free( datadir );
datadir = config_GetDataDir( getIntf() ); datadir = config_GetDataDir();
m_resourcePath.push_back( (string)datadir + "\\skins" ); m_resourcePath.push_back( (string)datadir + "\\skins" );
m_resourcePath.push_back( (string)datadir + "\\skins2" ); m_resourcePath.push_back( (string)datadir + "\\skins2" );
m_resourcePath.push_back( (string)datadir + "\\share\\skins" ); m_resourcePath.push_back( (string)datadir + "\\share\\skins" );
......
...@@ -87,7 +87,7 @@ bool X11Factory::init() ...@@ -87,7 +87,7 @@ bool X11Factory::init()
m_resourcePath.push_back( (string)datadir + "/skins2" ); m_resourcePath.push_back( (string)datadir + "/skins2" );
free( datadir ); free( datadir );
m_resourcePath.push_back( (string)"share/skins2" ); m_resourcePath.push_back( (string)"share/skins2" );
datadir = config_GetDataDir( getIntf() ); datadir = config_GetDataDir();
m_resourcePath.push_back( (string)datadir + "/skins2" ); m_resourcePath.push_back( (string)datadir + "/skins2" );
free( datadir ); free( datadir );
......
...@@ -107,7 +107,7 @@ static int vlclua_config_set( lua_State *L ) ...@@ -107,7 +107,7 @@ static int vlclua_config_set( lua_State *L )
*****************************************************************************/ *****************************************************************************/
static int vlclua_datadir( 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 ); lua_pushstring( L, psz_data );
free( psz_data ); free( psz_data );
return 1; return 1;
......
...@@ -226,7 +226,7 @@ int vlclua_dir_list( vlc_object_t *p_this, const char *luadirname, ...@@ -226,7 +226,7 @@ int vlclua_dir_list( vlc_object_t *p_this, const char *luadirname,
} }
#endif #endif
char *psz_datapath = config_GetDataDir( p_this ); char *psz_datapath = config_GetDataDir();
if( likely(psz_datapath != NULL) ) if( likely(psz_datapath != NULL) )
{ {
if( likely(asprintf( &ppsz_dir_list[i], "%s"DIR_SEP"lua"DIR_SEP"%s", if( likely(asprintf( &ppsz_dir_list[i], "%s"DIR_SEP"lua"DIR_SEP"%s",
......
...@@ -117,7 +117,7 @@ static int Open( vlc_object_t *p_this ) ...@@ -117,7 +117,7 @@ static int Open( vlc_object_t *p_this )
p_sys->app_name = CFSTR( "VLC media player" ); p_sys->app_name = CFSTR( "VLC media player" );
p_sys->notification_type = CFSTR( "New input playing" ); 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")]; char buf[strlen (data_path) + sizeof ("/vlc512x512.png")];
snprintf (buf, sizeof (buf), "%s/vlc512x512.png", data_path); snprintf (buf, sizeof (buf), "%s/vlc512x512.png", data_path);
msg_Dbg( p_this, "looking for icon at %s", buf ); msg_Dbg( p_this, "looking for icon at %s", buf );
......
...@@ -240,7 +240,7 @@ static int ItemChange( vlc_object_t *p_this, const char *psz_var, ...@@ -240,7 +240,7 @@ static int ItemChange( vlc_object_t *p_this, const char *psz_var,
/* Load icon from share/ */ /* Load icon from share/ */
GError *p_error = NULL; GError *p_error = NULL;
char *psz_pixbuf; 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 ) if( asprintf( &psz_pixbuf, "%s/icons/48x48/vlc.png", psz_data ) >= 0 )
{ {
pix = gdk_pixbuf_new_from_file( psz_pixbuf, &p_error ); pix = gdk_pixbuf_new_from_file( psz_pixbuf, &p_error );
......
...@@ -369,7 +369,7 @@ static void *Thread( void *p_data ) ...@@ -369,7 +369,7 @@ static void *Thread( void *p_data )
#ifdef WIN32 #ifdef WIN32
if ( psz_preset_path == NULL ) 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 ); asprintf( &psz_preset_path, "%s" DIR_SEP "visualization", psz_data_path );
free( psz_data_path ); free( psz_data_path );
} }
......
...@@ -30,15 +30,16 @@ ...@@ -30,15 +30,16 @@
#include "configuration.h" #include "configuration.h"
#undef config_GetDataDir
/** /**
* Determines the shared architecture-independent data directory * Determines the shared architecture-independent data directory
* *
* @return a string or NULL. Use free() to release. * @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" ); const char *path = getenv ("VLC_DATA_PATH");
return psz_path ? psz_path : config_GetDataDirDefault(); if (path)
return strdup (path);
return config_GetDataDirDefault();
} }
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