[vlc-commits] Use environment variable for data directory

Rémi Denis-Courmont git at videolan.org
Tue Mar 20 19:50:24 CET 2012


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Tue Mar 20 20:41:56 2012 +0200| [feb4063c35aeb4779f51a75dcefe44966e58c14d] | committer: 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.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=feb4063c35aeb4779f51a75dcefe44966e58c14d
---

 bin/vlc.c                                  |    6 ++----
 bin/winvlc.c                               |    1 +
 include/vlc_configuration.h                |    3 +--
 modules/access/dvb/scan.c                  |    2 +-
 modules/gui/hildon/maemo.c                 |    2 +-
 modules/gui/skins2/win32/win32_factory.cpp |    2 +-
 modules/gui/skins2/x11/x11_factory.cpp     |    2 +-
 modules/lua/libs/configuration.c           |    2 +-
 modules/lua/vlc.c                          |    2 +-
 modules/notify/growl.m                     |    2 +-
 modules/notify/notify.c                    |    2 +-
 modules/visualization/projectm.cpp         |    2 +-
 src/config/dirs.c                          |    9 +++++----
 13 files changed, 18 insertions(+), 19 deletions(-)

diff --git a/bin/vlc.c b/bin/vlc.c
index 80418f1..46c7d7d 100644
--- a/bin/vlc.c
+++ b/bin/vlc.c
@@ -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
diff --git a/bin/winvlc.c b/bin/winvlc.c
index 42a3d56..ce17c95 100644
--- a/bin/winvlc.c
+++ b/bin/winvlc.c
@@ -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);
diff --git a/include/vlc_configuration.h b/include/vlc_configuration.h
index e9ca96b..e3b17a5 100644
--- a/include/vlc_configuration.h
+++ b/include/vlc_configuration.h
@@ -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;
 
diff --git a/modules/access/dvb/scan.c b/modules/access/dvb/scan.c
index 5f75e58..5ad6187 100644
--- a/modules/access/dvb/scan.c
+++ b/modules/access/dvb/scan.c
@@ -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;
diff --git a/modules/gui/hildon/maemo.c b/modules/gui/hildon/maemo.c
index 9fa9809..7f2619d 100644
--- a/modules/gui/hildon/maemo.c
+++ b/modules/gui/hildon/maemo.c
@@ -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 );
diff --git a/modules/gui/skins2/win32/win32_factory.cpp b/modules/gui/skins2/win32/win32_factory.cpp
index 6d8e2d9..237b4d5 100644
--- a/modules/gui/skins2/win32/win32_factory.cpp
+++ b/modules/gui/skins2/win32/win32_factory.cpp
@@ -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" );
diff --git a/modules/gui/skins2/x11/x11_factory.cpp b/modules/gui/skins2/x11/x11_factory.cpp
index 1e23300..26b881d 100644
--- a/modules/gui/skins2/x11/x11_factory.cpp
+++ b/modules/gui/skins2/x11/x11_factory.cpp
@@ -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 );
 
diff --git a/modules/lua/libs/configuration.c b/modules/lua/libs/configuration.c
index b0c76ce..a640c3e 100644
--- a/modules/lua/libs/configuration.c
+++ b/modules/lua/libs/configuration.c
@@ -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;
diff --git a/modules/lua/vlc.c b/modules/lua/vlc.c
index 963a67d..1fb969f 100644
--- a/modules/lua/vlc.c
+++ b/modules/lua/vlc.c
@@ -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",
diff --git a/modules/notify/growl.m b/modules/notify/growl.m
index 329144f..8ce8835 100644
--- a/modules/notify/growl.m
+++ b/modules/notify/growl.m
@@ -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 );
diff --git a/modules/notify/notify.c b/modules/notify/notify.c
index 0dc494d..c07015b 100644
--- a/modules/notify/notify.c
+++ b/modules/notify/notify.c
@@ -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 );
diff --git a/modules/visualization/projectm.cpp b/modules/visualization/projectm.cpp
index c21ecb6..9d76223 100644
--- a/modules/visualization/projectm.cpp
+++ b/modules/visualization/projectm.cpp
@@ -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 );
     }
diff --git a/src/config/dirs.c b/src/config/dirs.c
index 94002d9..4c1d00f 100644
--- a/src/config/dirs.c
+++ b/src/config/dirs.c
@@ -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();
 }
 



More information about the vlc-commits mailing list