mirror of
https://github.com/videolan/vlc.git
synced 2024-11-30 13:25:56 +08:00
Linux: determine data path at run-time from library path
This commit is contained in:
parent
e83bc5b906
commit
85f5c15fe5
@ -169,7 +169,7 @@ AM_CPPFLAGS = $(INCICONV) \
|
||||
-DMODULE_STRING=\"main\" \
|
||||
-DLOCALEDIR=\"$(localedir)\" \
|
||||
-DSYSCONFDIR=\"$(sysconfdir)\" \
|
||||
-DDATA_PATH=\"$(vlcdatadir)\" \
|
||||
-DPKGDATADIR=\"$(vlcdatadir)\" \
|
||||
-DPKGLIBDIR=\"$(vlclibdir)\"
|
||||
AM_CFLAGS = $(CFLAGS_libvlccore)
|
||||
|
||||
|
@ -35,6 +35,7 @@
|
||||
#include <assert.h>
|
||||
#include <limits.h>
|
||||
|
||||
#if !defined (__linux__)
|
||||
/**
|
||||
* Determines the shared data directory
|
||||
*
|
||||
@ -42,10 +43,9 @@
|
||||
*/
|
||||
char *config_GetDataDirDefault (void)
|
||||
{
|
||||
return strdup (DATA_PATH);
|
||||
return strdup (PKGDATADIR);
|
||||
}
|
||||
|
||||
#if !defined (__linux__)
|
||||
/**
|
||||
* Determines the architecture-dependent data directory
|
||||
*
|
||||
|
@ -26,7 +26,8 @@
|
||||
#include <string.h>
|
||||
|
||||
#include <vlc_common.h>
|
||||
#include "../libvlc.h"
|
||||
#include "libvlc.h"
|
||||
#include "config/configuration.h"
|
||||
|
||||
char *config_GetLibDir (void)
|
||||
{
|
||||
@ -73,3 +74,29 @@ char *config_GetLibDir (void)
|
||||
error:
|
||||
return (path != NULL) ? path : strdup (PKGLIBDIR);
|
||||
}
|
||||
|
||||
char *config_GetDataDirDefault (void)
|
||||
{
|
||||
char *libdir = config_GetLibDir ();
|
||||
if (libdir == NULL)
|
||||
return NULL; /* OOM */
|
||||
|
||||
char *datadir = NULL;
|
||||
|
||||
/* There are no clean ways to do this, are there?
|
||||
* Due to multilibs, we cannot simply append ../share/. */
|
||||
char *p = strstr (libdir, "/lib/");
|
||||
if (p != NULL)
|
||||
{
|
||||
char *p2;
|
||||
/* Deal with nested "lib" directories. Grmbl. */
|
||||
while ((p2 = strstr (p + 4, "/lib/")) != NULL)
|
||||
p = p2;
|
||||
*p = '\0';
|
||||
|
||||
if (unlikely(asprintf (&datadir, "%s/share/"PACKAGE, libdir) == -1))
|
||||
datadir = NULL;
|
||||
}
|
||||
free (libdir);
|
||||
return (datadir != NULL) ? datadir : strdup (PKGDATADIR);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user