[vlc-devel] commit: Use config_Get*Dir ( Rémi Denis-Courmont )
git version control
git at videolan.org
Mon May 5 22:40:12 CEST 2008
vlc | branch: master | Rémi Denis-Courmont <rem at videolan.org> | Mon May 5 23:16:50 2008 +0300| [9b6ca602809f373e1770e32720f7961c3a0febed]
Use config_Get*Dir
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=9b6ca602809f373e1770e32720f7961c3a0febed
---
modules/gui/skins2/win32/win32_factory.cpp | 5 ++-
modules/gui/skins2/x11/x11_factory.cpp | 5 ++-
modules/misc/gnutls.c | 42 ++++++++++++++-------------
modules/misc/lua/vlc.c | 18 ++++++++++--
4 files changed, 43 insertions(+), 27 deletions(-)
diff --git a/modules/gui/skins2/win32/win32_factory.cpp b/modules/gui/skins2/win32/win32_factory.cpp
index 16b70b3..47d4556 100644
--- a/modules/gui/skins2/win32/win32_factory.cpp
+++ b/modules/gui/skins2/win32/win32_factory.cpp
@@ -225,8 +225,9 @@ bool Win32Factory::init()
}
// Initialize the resource path
- m_resourcePath.push_back( (string)getIntf()->p_libvlc->psz_datadir +
- "\\skins" );
+ char *datadir = config_GetUserDataDir();
+ m_resourcePath.push_back( (string)datadir + "\\skins" );
+ free( datadir );
m_resourcePath.push_back( (string)config_GetDataDir() +
"\\skins" );
m_resourcePath.push_back( (string)config_GetDataDir() +
diff --git a/modules/gui/skins2/x11/x11_factory.cpp b/modules/gui/skins2/x11/x11_factory.cpp
index 02fcc17..815a169 100644
--- a/modules/gui/skins2/x11/x11_factory.cpp
+++ b/modules/gui/skins2/x11/x11_factory.cpp
@@ -71,8 +71,9 @@ bool X11Factory::init()
ConnectionNumber( pDisplay ) );
// Initialize the resource path
- m_resourcePath.push_back( (string)getIntf()->p_libvlc->psz_datadir +
- + "/skins2" );
+ char *datadir = config_GetUserDataDir();
+ m_resourcePath.push_back( (string)datadir + "/skins2" );
+ free( datadir );
m_resourcePath.push_back( (string)"share/skins2" );
m_resourcePath.push_back( (string)config_GetDataDir () + "/skins2" );
diff --git a/modules/misc/gnutls.c b/modules/misc/gnutls.c
index 88fcc32..1f6be91 100644
--- a/modules/misc/gnutls.c
+++ b/modules/misc/gnutls.c
@@ -643,13 +643,6 @@ static int OpenClient (vlc_object_t *obj)
p_sys->session.b_handshaked = false;
- const char *homedir = obj->p_libvlc->psz_datadir,
- *datadir = config_GetDataDir ();
- size_t l1 = strlen (homedir), l2 = strlen (datadir);
- char path[((l1 > l2) ? l1 : l2) + sizeof ("/ca-certificates.crt")];
- // > sizeof ("/ssl/private")
- // > sizeof ("/ssl/certs")
-
i_val = gnutls_certificate_allocate_credentials (&p_sys->x509_cred);
if (i_val != 0)
{
@@ -658,23 +651,32 @@ static int OpenClient (vlc_object_t *obj)
goto error;
}
- sprintf (path, "%s/ssl", homedir);
- utf8_mkdir (path, 0755);
-
- sprintf (path, "%s/ssl/certs", homedir);
- gnutls_Addx509Directory (VLC_OBJECT (p_session),
- p_sys->x509_cred, path, false);
+ char *userdir = config_GetUserDataDir ();
+ if (userdir != NULL)
+ {
+ char path[strlen (userdir) + sizeof ("/ssl/private")];
+ sprintf (path, "%s/ssl", userdir);
+ utf8_mkdir (path, 0755);
+
+ sprintf (path, "%s/ssl/certs", userdir);
+ gnutls_Addx509Directory (VLC_OBJECT (p_session),
+ p_sys->x509_cred, path, false);
+ sprintf (path, "%s/ssl/private", userdir);
+ gnutls_Addx509Directory (VLC_OBJECT (p_session), p_sys->x509_cred,
+ path, true);
+ free (userdir);
+ }
- sprintf (path, "%s/ca-certificates.crt", datadir);
- gnutls_Addx509File (VLC_OBJECT (p_session),
- p_sys->x509_cred, path, false);
+ const char *datadir = config_GetDataDir ();
+ {
+ char path[strlen (datadir) + sizeof ("/ca-certificates.crt")];
+ sprintf (path, "%s/ca-certificates.crt", datadir);
+ gnutls_Addx509File (VLC_OBJECT (p_session),
+ p_sys->x509_cred, path, false);
+ }
p_session->pf_handshake = gnutls_HandshakeAndValidate;
/*p_session->pf_handshake = gnutls_ContinueHandshake;*/
- sprintf (path, "%s/ssl/private", homedir);
- gnutls_Addx509Directory (VLC_OBJECT (p_session), p_sys->x509_cred,
- path, true);
-
i_val = gnutls_init (&p_sys->session.session, GNUTLS_CLIENT);
if (i_val != 0)
{
diff --git a/modules/misc/lua/vlc.c b/modules/misc/lua/vlc.c
index 2c356ee..1e81acd 100644
--- a/modules/misc/lua/vlc.c
+++ b/modules/misc/lua/vlc.c
@@ -164,12 +164,16 @@ int vlclua_homedir( lua_State *L )
}
int vlclua_configdir( lua_State *L )
{
- lua_pushstring( L, vlclua_get_this( L )->p_libvlc->psz_configdir );
+ char *dir = config_GetConfigDir();
+ lua_pushstring( L, dir );
+ free( dir );
return 1;
}
int vlclua_cachedir( lua_State *L )
{
- lua_pushstring( L, vlclua_get_this( L )->p_libvlc->psz_cachedir );
+ char *dir = config_GetCacheDir();
+ lua_pushstring( L, dir );
+ free( dir );
return 1;
}
int vlclua_datadir_list( lua_State *L )
@@ -400,9 +404,17 @@ int vlclua_dir_list( vlc_object_t *p_this, const char *luadirname,
char **ppsz_dir_list )
{
int i = 0;
+ char *datadir = config_GetUserDataDir();
+ if( datadir == NULL )
+ return VLC_ENOMEM;
+
if( asprintf( &ppsz_dir_list[i], "%s" DIR_SEP "lua" DIR_SEP "%s",
- p_this->p_libvlc->psz_datadir, luadirname ) < 0 )
+ datadir, luadirname ) < 0 )
+ {
+ free( datadir );
return VLC_ENOMEM;
+ }
+ free( datadir );
i++;
# if defined(__APPLE__) || defined(SYS_BEOS) || defined(WIN32)
More information about the vlc-devel
mailing list