From cfe59a4f713c6a86da75bdcd48919e56dd60711a Mon Sep 17 00:00:00 2001 From: =?utf8?q?R=C3=A9mi=20Denis-Courmont?= Date: Sun, 5 Mar 2006 11:10:34 +0000 Subject: [PATCH] config_GetDataDir(): returns path to VLC installed shared data --- include/configuration.h | 1 + include/vlc_symbols.h | 3 +++ src/misc/configuration.c | 24 ++++++++++++++++++++++++ 3 files changed, 28 insertions(+) diff --git a/include/configuration.h b/include/configuration.h index 7ba41b7978..f6bd713516 100644 --- a/include/configuration.h +++ b/include/configuration.h @@ -181,6 +181,7 @@ VLC_EXPORT( void, __config_PutPsz, (vlc_object_t *, const char *, const char VLC_EXPORT( int, __config_LoadCmdLine, ( vlc_object_t *, int *, char *[], vlc_bool_t ) ); VLC_EXPORT( char *, config_GetHomeDir, ( void ) ); VLC_EXPORT( char *, config_GetUserDir, ( void ) ); +VLC_EXPORT( const char *, config_GetDataDir, ( const vlc_object_t * ) ); VLC_EXPORT( int, __config_LoadConfigFile, ( vlc_object_t *, const char * ) ); VLC_EXPORT( int, __config_SaveConfigFile, ( vlc_object_t *, const char * ) ); VLC_EXPORT( void, __config_ResetAll, ( vlc_object_t * ) ); diff --git a/include/vlc_symbols.h b/include/vlc_symbols.h index ee4fe882ab..02440c5024 100644 --- a/include/vlc_symbols.h +++ b/include/vlc_symbols.h @@ -476,6 +476,7 @@ struct module_symbols_t int (*utf8_mkdir_inner) (const char *filename); vlm_media_t* (*vlm_MediaSearch_inner) (vlm_t *, const char *); int (*playlist_TreeMove_inner) (playlist_t *, playlist_item_t *, playlist_item_t *, int, int); + const char * (*config_GetDataDir_inner) (const vlc_object_t *); }; # if defined (__PLUGIN__) # define aout_FiltersCreatePipeline (p_symbols)->aout_FiltersCreatePipeline_inner @@ -932,6 +933,7 @@ struct module_symbols_t # define utf8_mkdir (p_symbols)->utf8_mkdir_inner # define vlm_MediaSearch (p_symbols)->vlm_MediaSearch_inner # define playlist_TreeMove (p_symbols)->playlist_TreeMove_inner +# define config_GetDataDir (p_symbols)->config_GetDataDir_inner # elif defined (HAVE_DYNAMIC_PLUGINS) && !defined (__BUILTIN__) /****************************************************************** * STORE_SYMBOLS: store VLC APIs into p_symbols for plugin access. @@ -1391,6 +1393,7 @@ struct module_symbols_t ((p_symbols)->utf8_mkdir_inner) = utf8_mkdir; \ ((p_symbols)->vlm_MediaSearch_inner) = vlm_MediaSearch; \ ((p_symbols)->playlist_TreeMove_inner) = playlist_TreeMove; \ + ((p_symbols)->config_GetDataDir_inner) = config_GetDataDir; \ (p_symbols)->net_ConvertIPv4_deprecated = NULL; \ (p_symbols)->__stats_CounterGet_deprecated = NULL; \ (p_symbols)->__stats_TimerDumpAll_deprecated = NULL; \ diff --git a/src/misc/configuration.c b/src/misc/configuration.c index d14486d296..d7e52df211 100644 --- a/src/misc/configuration.c +++ b/src/misc/configuration.c @@ -1676,6 +1676,30 @@ int __config_LoadCmdLine( vlc_object_t *p_this, int *pi_argc, char *ppsz_argv[], return 0; } +/** + * config_GetDataDir: find directory where shared data is installed + * + * @return a string (always succeeds). + */ +const char *config_GetDataDir( const vlc_object_t *p_this ) +{ +#if defined (WIN32) || defined (UNDER_CE) + return p_this->p_libvlc->psz_vlcpath; +#elif defined(__APPLE__) || defined (SYS_BEOS) + static char path[PATH_MAX] = ""; + + if( *path == '\0' ) + { + snprintf( path, sizeof( path ), "%s/share", + p_this->p_libvlc->psz_vlcpath ); + path[sizeof( path ) - 1] = '\0'; + } + return path; +#else + return DATA_PATH; +#endif +} + /***************************************************************************** * config_GetHomeDir, config_GetUserDir: find the user's home directory. ***************************************************************************** -- 2.39.2