[vlc-commits] Replace config_Get(Data|Lib)Dir() with config_GetSysDir()

Rémi Denis-Courmont git at videolan.org
Tue Mar 6 20:17:25 CET 2018


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat Mar  3 18:06:36 2018 +0200| [477d18c7236ef6cad8f3a8593844454cf81b7c25] | committer: Rémi Denis-Courmont

Replace config_Get(Data|Lib)Dir() with config_GetSysDir()

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

 modules/access/dvb/linux_dvb.c                     |  4 +--
 .../audio_filter/channel_mixer/spatialaudio.cpp    |  6 ++--
 modules/gui/qt/qt.cpp                              | 38 +++++++++-------------
 modules/gui/skins2/os2/os2_factory.cpp             |  2 +-
 modules/gui/skins2/win32/win32_factory.cpp         |  2 +-
 modules/gui/skins2/x11/x11_factory.cpp             |  4 +--
 modules/lua/libs/configuration.c                   |  2 +-
 modules/lua/vlc.c                                  |  4 +--
 modules/notify/notify.c                            |  7 ++--
 modules/visualization/projectm.cpp                 |  6 +---
 src/modules/textdomain.c                           | 10 ++----
 src/video_output/video_epg.c                       |  7 ++--
 12 files changed, 35 insertions(+), 57 deletions(-)

diff --git a/modules/access/dvb/linux_dvb.c b/modules/access/dvb/linux_dvb.c
index 44ef0edc32..30d3566d13 100644
--- a/modules/access/dvb/linux_dvb.c
+++ b/modules/access/dvb/linux_dvb.c
@@ -381,9 +381,9 @@ static int ScanParametersDvbS( vlc_object_t *p_access, dvb_sys_t *p_sys, scan_pa
     char *psz_name = var_InheritString( p_access, "dvb-satellite" );
     if( psz_name )
     {
-        char *data_dir = config_GetDataDir();
+        char *data_dir = config_GetSysPath(VLC_PKG_DATA_DIR, "dvb/dvb-s");
         if( !data_dir || -1 ==  asprintf( &p_scan->psz_scanlist_file,
-            "%s" DIR_SEP "dvb" DIR_SEP "dvb-s" DIR_SEP "%s", data_dir, psz_name ) )
+            "%s/%s", data_dir, psz_name ) )
         {
             p_scan->psz_scanlist_file = NULL;
         }
diff --git a/modules/audio_filter/channel_mixer/spatialaudio.cpp b/modules/audio_filter/channel_mixer/spatialaudio.cpp
index c34e402527..02d791b911 100644
--- a/modules/audio_filter/channel_mixer/spatialaudio.cpp
+++ b/modules/audio_filter/channel_mixer/spatialaudio.cpp
@@ -150,12 +150,10 @@ static std::string getHRTFPath(filter_t *p_filter)
     }
     else
     {
-        char *dataDir = config_GetDataDir();
+        char *dataDir = config_GetSysPath(VLC_PKG_DATA_DIR, DEFAULT_HRTF_PATH);
         if (dataDir != NULL)
         {
-            std::stringstream ss;
-            ss << std::string(dataDir) << DIR_SEP << DEFAULT_HRTF_PATH;
-            HRTFPath = ss.str();
+            HRTFPath = std::string(dataDir);
             free(dataDir);
         }
     }
diff --git a/modules/gui/qt/qt.cpp b/modules/gui/qt/qt.cpp
index 61c0049925..aba55b61ea 100644
--- a/modules/gui/qt/qt.cpp
+++ b/modules/gui/qt/qt.cpp
@@ -381,33 +381,25 @@ static int Open( vlc_object_t *p_this, bool isDialogProvider )
 
 #if (_POSIX_SPAWN >= 0)
     /* Check if QApplication works */
-    char *libdir = config_GetLibDir();
-    if (likely(libdir != NULL))
-    {
-        char *path;
-
-        if (unlikely(asprintf(&path, "%s/vlc-qt-check", libdir) < 0))
-            path = NULL;
-        free(libdir);
-        if (unlikely(path == NULL))
-            return VLC_ENOMEM;
+    char *path = config_GetSysPath(VLC_PKG_LIB_DIR, "vlc-qt-check");
+    if (unlikely(path == NULL))
+        return VLC_ENOMEM;
 
-        char *argv[] = { path, NULL };
-        pid_t pid;
+    char *argv[] = { path, NULL };
+    pid_t pid;
 
-        int val = posix_spawn(&pid, path, NULL, NULL, argv, environ);
-        free(path);
-        if (val)
-            return VLC_ENOMEM;
+    int val = posix_spawn(&pid, path, NULL, NULL, argv, environ);
+    free(path);
+    if (val)
+        return VLC_ENOMEM;
 
-        int status;
-        while (waitpid(pid, &status, 0) == -1);
+    int status;
+    while (waitpid(pid, &status, 0) == -1);
 
-        if (!WIFEXITED(status) || WEXITSTATUS(status) != 0)
-        {
-            msg_Dbg(p_this, "Qt check failed (%d). Skipping.", status);
-            return VLC_EGENERIC;
-        }
+    if (!WIFEXITED(status) || WEXITSTATUS(status) != 0)
+    {
+        msg_Dbg(p_this, "Qt check failed (%d). Skipping.", status);
+        return VLC_EGENERIC;
     }
 #endif
 
diff --git a/modules/gui/skins2/os2/os2_factory.cpp b/modules/gui/skins2/os2/os2_factory.cpp
index dc6357c371..a013175229 100644
--- a/modules/gui/skins2/os2/os2_factory.cpp
+++ b/modules/gui/skins2/os2/os2_factory.cpp
@@ -220,7 +220,7 @@ bool OS2Factory::init()
     char *datadir = config_GetUserDir( VLC_USER_DATA_DIR );
     m_resourcePath.push_back( (std::string)datadir + "\\skins" );
     free( datadir );
-    datadir = config_GetDataDir();
+    datadir = config_GetSysPath(VLC_PKG_DATA_DIR, NULL);
     m_resourcePath.push_back( (std::string)datadir + "\\skins" );
     m_resourcePath.push_back( (std::string)datadir + "\\skins2" );
     m_resourcePath.push_back( (std::string)datadir + "\\share\\skins" );
diff --git a/modules/gui/skins2/win32/win32_factory.cpp b/modules/gui/skins2/win32/win32_factory.cpp
index 3df64fb785..49885ab729 100644
--- a/modules/gui/skins2/win32/win32_factory.cpp
+++ b/modules/gui/skins2/win32/win32_factory.cpp
@@ -236,7 +236,7 @@ bool Win32Factory::init()
     char *datadir = config_GetUserDir( VLC_USERDATA_DIR );
     m_resourcePath.push_back( (std::string)datadir + "\\skins" );
     free( datadir );
-    datadir = config_GetDataDir();
+    datadir = config_GetSysPath(VLC_PKG_DATA_DIR, NULL);
     m_resourcePath.push_back( (std::string)datadir + "\\skins" );
     m_resourcePath.push_back( (std::string)datadir + "\\skins2" );
     m_resourcePath.push_back( (std::string)datadir + "\\share\\skins" );
diff --git a/modules/gui/skins2/x11/x11_factory.cpp b/modules/gui/skins2/x11/x11_factory.cpp
index d66dbcf5bc..d658ac3b83 100644
--- a/modules/gui/skins2/x11/x11_factory.cpp
+++ b/modules/gui/skins2/x11/x11_factory.cpp
@@ -90,8 +90,8 @@ bool X11Factory::init()
     m_resourcePath.push_back( (std::string)datadir + "/skins2" );
     free( datadir );
     m_resourcePath.push_back( (std::string)"share/skins2" );
-    datadir = config_GetDataDir();
-    m_resourcePath.push_back( (std::string)datadir + "/skins2" );
+    datadir = config_GetSysPath(VLC_PKG_DATA_DIR, "skins2");
+    m_resourcePath.push_back( (std::string)datadir );
     free( datadir );
 
     // Determine the monitor geometry
diff --git a/modules/lua/libs/configuration.c b/modules/lua/libs/configuration.c
index 0d94cb1c07..30c00077d2 100644
--- a/modules/lua/libs/configuration.c
+++ b/modules/lua/libs/configuration.c
@@ -104,7 +104,7 @@ static int vlclua_config_set( lua_State *L )
  *****************************************************************************/
 static int vlclua_datadir( lua_State *L )
 {
-    char *psz_data = config_GetDataDir();
+    char *psz_data = config_GetSysPath(VLC_PKG_DATA_DIR, NULL);
     lua_pushstring( L, psz_data );
     free( psz_data );
     return 1;
diff --git a/modules/lua/vlc.c b/modules/lua/vlc.c
index e2a63ebb54..846c979223 100644
--- a/modules/lua/vlc.c
+++ b/modules/lua/vlc.c
@@ -223,8 +223,8 @@ int vlclua_dir_list(const char *luadirname, char ***restrict listp)
     list = vlclua_dir_list_append(list, config_GetUserDir(VLC_USERDATA_DIR),
                                   luadirname);
 
-    char *libdir = config_GetLibDir();
-    char *datadir = config_GetDataDir();
+    char *libdir = config_GetSysPath(VLC_PKG_LIB_DIR, NULL);
+    char *datadir = config_GetSysPath(VLC_PKG_DATA_DIR, NULL);
     bool both = libdir != NULL && datadir != NULL && strcmp(libdir, datadir);
 
     /* Tokenized Lua scripts in architecture-specific data directory */
diff --git a/modules/notify/notify.c b/modules/notify/notify.c
index bd6bba6c32..5c5092dbd9 100644
--- a/modules/notify/notify.c
+++ b/modules/notify/notify.c
@@ -233,14 +233,13 @@ 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();
-            if( asprintf( &psz_pixbuf, "%s/icons/48x48/vlc.png", psz_data ) >= 0 )
+            char *psz_pixbuf = config_GetSysPath(VLC_PKG_DATA_DIR,
+                                                 "icons/48x48/"PACKAGE".png");
+            if (psz_pixbuf != NULL)
             {
                 pix = gdk_pixbuf_new_from_file( psz_pixbuf, &p_error );
                 free( psz_pixbuf );
             }
-            free( psz_data );
         }
     }
 
diff --git a/modules/visualization/projectm.cpp b/modules/visualization/projectm.cpp
index 9f99e8bb02..5a8770d9f6 100644
--- a/modules/visualization/projectm.cpp
+++ b/modules/visualization/projectm.cpp
@@ -306,11 +306,7 @@ static void *Thread( void *p_data )
     psz_preset_path = var_InheritString( p_filter, "projectm-preset-path" );
 #ifdef _WIN32
     if ( psz_preset_path == NULL )
-    {
-        char *psz_data_path = config_GetDataDir();
-        asprintf( &psz_preset_path, "%s" DIR_SEP "visualization", psz_data_path );
-        free( psz_data_path );
-    }
+        psz_preset_path = config_GetSysPath(VLC_PKG_DATA_DIR, "visualization");
 #endif
 
     psz_title_font                = var_InheritString( p_filter, "projectm-title-font" );
diff --git a/src/modules/textdomain.c b/src/modules/textdomain.c
index ed9206edd0..5d0e3ec9f2 100644
--- a/src/modules/textdomain.c
+++ b/src/modules/textdomain.c
@@ -45,14 +45,8 @@ int vlc_bindtextdomain (const char *domain)
         return -1;
     }
 # else
-    char *datadir = config_GetDataDir();
-    if (unlikely(datadir == NULL))
-        return -1;
-
-    char *upath;
-    int ret = asprintf (&upath, "%s" DIR_SEP "locale", datadir);
-    free (datadir);
-    if (unlikely(ret == -1))
+    char *upath = config_GetSysPath(VLC_PKG_DATA_DIR, "locale");
+    if (unlikely(upath == NULL))
         return -1;
 
     char *lpath = ToLocale(upath);
diff --git a/src/video_output/video_epg.c b/src/video_output/video_epg.c
index ddd02609b4..4547ed030d 100644
--- a/src/video_output/video_epg.c
+++ b/src/video_output/video_epg.c
@@ -77,14 +77,13 @@ struct subpicture_updater_sys_t
 static char * GetDefaultArtUri( void )
 {
     char *psz_uri = NULL;
-    char *psz_path;
-    char *psz_datadir = config_GetDataDir();
-    if( asprintf( &psz_path, "%s/icons/128x128/vlc.png", psz_datadir ) >= 0 )
+    char *psz_path = config_GetSysPath(VLC_PKG_DATA_DIR,
+                                       "icons/128x128/"PACKAGE_NAME".png");
+    if( psz_path != NULL )
     {
         psz_uri = vlc_path2uri( psz_path, NULL );
         free( psz_path );
     }
-    free( psz_datadir );
     return psz_uri;
 }
 



More information about the vlc-commits mailing list