1
mirror of https://code.videolan.org/videolan/vlc synced 2024-07-21 07:24:15 +02:00

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

This commit is contained in:
Rémi Denis-Courmont 2018-03-03 18:06:36 +02:00
parent 5acf932211
commit 477d18c723
12 changed files with 38 additions and 60 deletions

View File

@ -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" ); char *psz_name = var_InheritString( p_access, "dvb-satellite" );
if( psz_name ) 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, 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; p_scan->psz_scanlist_file = NULL;
} }

View File

@ -150,12 +150,10 @@ static std::string getHRTFPath(filter_t *p_filter)
} }
else else
{ {
char *dataDir = config_GetDataDir(); char *dataDir = config_GetSysPath(VLC_PKG_DATA_DIR, DEFAULT_HRTF_PATH);
if (dataDir != NULL) if (dataDir != NULL)
{ {
std::stringstream ss; HRTFPath = std::string(dataDir);
ss << std::string(dataDir) << DIR_SEP << DEFAULT_HRTF_PATH;
HRTFPath = ss.str();
free(dataDir); free(dataDir);
} }
} }

View File

@ -381,33 +381,25 @@ static int Open( vlc_object_t *p_this, bool isDialogProvider )
#if (_POSIX_SPAWN >= 0) #if (_POSIX_SPAWN >= 0)
/* Check if QApplication works */ /* Check if QApplication works */
char *libdir = config_GetLibDir(); char *path = config_GetSysPath(VLC_PKG_LIB_DIR, "vlc-qt-check");
if (likely(libdir != NULL)) if (unlikely(path == NULL))
return VLC_ENOMEM;
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 status;
while (waitpid(pid, &status, 0) == -1);
if (!WIFEXITED(status) || WEXITSTATUS(status) != 0)
{ {
char *path; msg_Dbg(p_this, "Qt check failed (%d). Skipping.", status);
return VLC_EGENERIC;
if (unlikely(asprintf(&path, "%s/vlc-qt-check", libdir) < 0))
path = NULL;
free(libdir);
if (unlikely(path == NULL))
return VLC_ENOMEM;
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 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;
}
} }
#endif #endif

View File

@ -220,7 +220,7 @@ bool OS2Factory::init()
char *datadir = config_GetUserDir( VLC_USER_DATA_DIR ); char *datadir = config_GetUserDir( VLC_USER_DATA_DIR );
m_resourcePath.push_back( (std::string)datadir + "\\skins" ); m_resourcePath.push_back( (std::string)datadir + "\\skins" );
free( datadir ); 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 + "\\skins" );
m_resourcePath.push_back( (std::string)datadir + "\\skins2" ); m_resourcePath.push_back( (std::string)datadir + "\\skins2" );
m_resourcePath.push_back( (std::string)datadir + "\\share\\skins" ); m_resourcePath.push_back( (std::string)datadir + "\\share\\skins" );

View File

@ -236,7 +236,7 @@ bool Win32Factory::init()
char *datadir = config_GetUserDir( VLC_USERDATA_DIR ); char *datadir = config_GetUserDir( VLC_USERDATA_DIR );
m_resourcePath.push_back( (std::string)datadir + "\\skins" ); m_resourcePath.push_back( (std::string)datadir + "\\skins" );
free( datadir ); 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 + "\\skins" );
m_resourcePath.push_back( (std::string)datadir + "\\skins2" ); m_resourcePath.push_back( (std::string)datadir + "\\skins2" );
m_resourcePath.push_back( (std::string)datadir + "\\share\\skins" ); m_resourcePath.push_back( (std::string)datadir + "\\share\\skins" );

View File

@ -90,8 +90,8 @@ bool X11Factory::init()
m_resourcePath.push_back( (std::string)datadir + "/skins2" ); m_resourcePath.push_back( (std::string)datadir + "/skins2" );
free( datadir ); free( datadir );
m_resourcePath.push_back( (std::string)"share/skins2" ); m_resourcePath.push_back( (std::string)"share/skins2" );
datadir = config_GetDataDir(); datadir = config_GetSysPath(VLC_PKG_DATA_DIR, "skins2");
m_resourcePath.push_back( (std::string)datadir + "/skins2" ); m_resourcePath.push_back( (std::string)datadir );
free( datadir ); free( datadir );
// Determine the monitor geometry // Determine the monitor geometry

View File

@ -104,7 +104,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(); char *psz_data = config_GetSysPath(VLC_PKG_DATA_DIR, NULL);
lua_pushstring( L, psz_data ); lua_pushstring( L, psz_data );
free( psz_data ); free( psz_data );
return 1; return 1;

View File

@ -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), list = vlclua_dir_list_append(list, config_GetUserDir(VLC_USERDATA_DIR),
luadirname); luadirname);
char *libdir = config_GetLibDir(); char *libdir = config_GetSysPath(VLC_PKG_LIB_DIR, NULL);
char *datadir = config_GetDataDir(); char *datadir = config_GetSysPath(VLC_PKG_DATA_DIR, NULL);
bool both = libdir != NULL && datadir != NULL && strcmp(libdir, datadir); bool both = libdir != NULL && datadir != NULL && strcmp(libdir, datadir);
/* Tokenized Lua scripts in architecture-specific data directory */ /* Tokenized Lua scripts in architecture-specific data directory */

View File

@ -233,14 +233,13 @@ 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 = config_GetSysPath(VLC_PKG_DATA_DIR,
char *psz_data = config_GetDataDir(); "icons/48x48/"PACKAGE".png");
if( asprintf( &psz_pixbuf, "%s/icons/48x48/vlc.png", psz_data ) >= 0 ) if (psz_pixbuf != NULL)
{ {
pix = gdk_pixbuf_new_from_file( psz_pixbuf, &p_error ); pix = gdk_pixbuf_new_from_file( psz_pixbuf, &p_error );
free( psz_pixbuf ); free( psz_pixbuf );
} }
free( psz_data );
} }
} }

View File

@ -306,11 +306,7 @@ static void *Thread( void *p_data )
psz_preset_path = var_InheritString( p_filter, "projectm-preset-path" ); psz_preset_path = var_InheritString( p_filter, "projectm-preset-path" );
#ifdef _WIN32 #ifdef _WIN32
if ( psz_preset_path == NULL ) if ( psz_preset_path == NULL )
{ psz_preset_path = config_GetSysPath(VLC_PKG_DATA_DIR, "visualization");
char *psz_data_path = config_GetDataDir();
asprintf( &psz_preset_path, "%s" DIR_SEP "visualization", psz_data_path );
free( psz_data_path );
}
#endif #endif
psz_title_font = var_InheritString( p_filter, "projectm-title-font" ); psz_title_font = var_InheritString( p_filter, "projectm-title-font" );

View File

@ -45,14 +45,8 @@ int vlc_bindtextdomain (const char *domain)
return -1; return -1;
} }
# else # else
char *datadir = config_GetDataDir(); char *upath = config_GetSysPath(VLC_PKG_DATA_DIR, "locale");
if (unlikely(datadir == NULL)) if (unlikely(upath == NULL))
return -1;
char *upath;
int ret = asprintf (&upath, "%s" DIR_SEP "locale", datadir);
free (datadir);
if (unlikely(ret == -1))
return -1; return -1;
char *lpath = ToLocale(upath); char *lpath = ToLocale(upath);

View File

@ -77,14 +77,13 @@ struct subpicture_updater_sys_t
static char * GetDefaultArtUri( void ) static char * GetDefaultArtUri( void )
{ {
char *psz_uri = NULL; char *psz_uri = NULL;
char *psz_path; char *psz_path = config_GetSysPath(VLC_PKG_DATA_DIR,
char *psz_datadir = config_GetDataDir(); "icons/128x128/"PACKAGE_NAME".png");
if( asprintf( &psz_path, "%s/icons/128x128/vlc.png", psz_datadir ) >= 0 ) if( psz_path != NULL )
{ {
psz_uri = vlc_path2uri( psz_path, NULL ); psz_uri = vlc_path2uri( psz_path, NULL );
free( psz_path ); free( psz_path );
} }
free( psz_datadir );
return psz_uri; return psz_uri;
} }