Commit 98e87c5c authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Inline config_GetDataDir()

dirs.c is too simple to grant a file of its own, I think.
parent feb4063c
...@@ -437,7 +437,6 @@ SOURCES_libvlc_common = \ ...@@ -437,7 +437,6 @@ SOURCES_libvlc_common = \
config/intf.c \ config/intf.c \
config/keys.c \ config/keys.c \
config/cmdline.c \ config/cmdline.c \
config/dirs.c \
config/getopt.c \ config/getopt.c \
config/vlc_getopt.h \ config/vlc_getopt.h \
misc/events.c \ misc/events.c \
......
...@@ -41,8 +41,6 @@ bool config_PrintHelp (vlc_object_t *); ...@@ -41,8 +41,6 @@ bool config_PrintHelp (vlc_object_t *);
int config_SortConfig (void); int config_SortConfig (void);
void config_UnsortConfig (void); void config_UnsortConfig (void);
char *config_GetDataDirDefault( void );
#define CONFIG_CLASS(x) ((x) & ~0x1F) #define CONFIG_CLASS(x) ((x) & ~0x1F)
static inline bool IsConfigStringType(unsigned type) static inline bool IsConfigStringType(unsigned type)
......
/*****************************************************************************
* dirs.c: crossplatform directories configuration
*****************************************************************************
* Copyright (C) 2009 VLC authors and VideoLAN
*
* Authors: Antoine Cellerier <dionoea at videolan dot org>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <vlc_common.h>
#include "../libvlc.h"
#include "configuration.h"
/**
* Determines the shared architecture-independent data directory
*
* @return a string or NULL. Use free() to release.
*/
char *config_GetDataDir(void)
{
const char *path = getenv ("VLC_DATA_PATH");
if (path)
return strdup (path);
return config_GetDataDirDefault();
}
...@@ -28,7 +28,6 @@ ...@@ -28,7 +28,6 @@
#ifdef ENABLE_NLS #ifdef ENABLE_NLS
# include <libintl.h> # include <libintl.h>
# if defined (__APPLE__) || defined (WIN32) || defined(__OS2__) # if defined (__APPLE__) || defined (WIN32) || defined(__OS2__)
# include "config/configuration.h"
# include <vlc_charset.h> # include <vlc_charset.h>
# endif # endif
#endif #endif
...@@ -46,7 +45,7 @@ int vlc_bindtextdomain (const char *domain) ...@@ -46,7 +45,7 @@ int vlc_bindtextdomain (const char *domain)
return -1; return -1;
} }
# else # else
char *datadir = config_GetDataDirDefault(); char *datadir = config_GetDataDir();
if (unlikely(datadir == NULL)) if (unlikely(datadir == NULL))
return -1; return -1;
......
...@@ -51,14 +51,16 @@ char *config_GetLibDir (void) ...@@ -51,14 +51,16 @@ char *config_GetLibDir (void)
* *
* @return a nul-terminated string or NULL. Use free() to release it. * @return a nul-terminated string or NULL. Use free() to release it.
*/ */
char *config_GetDataDirDefault (void) char *config_GetDataDir (void)
{ {
char *datadir = config_GetLibDir(); const char *path = getenv ("VLC_DATA_PATH");
if (path)
return strdup (path);
char *datadir = config_GetLibDir();
if (datadir) if (datadir)
/* replace last lib\vlc with share */ /* replace last lib\vlc with share */
strcpy ( datadir + strlen (datadir) - 7, "share"); strcpy ( datadir + strlen (datadir) - 7, "share");
return datadir; return datadir;
} }
......
...@@ -119,8 +119,12 @@ char *config_GetLibDir (void) ...@@ -119,8 +119,12 @@ char *config_GetLibDir (void)
abort (); abort ();
} }
char *config_GetDataDirDefault (void) char *config_GetDataDir (void)
{ {
const char *path = getenv ("VLC_DATA_PATH");
if (path)
return strdup (path);
char *vlcpath = config_GetLibDir (); char *vlcpath = config_GetLibDir ();
char *datadir; char *datadir;
......
...@@ -41,9 +41,10 @@ ...@@ -41,9 +41,10 @@
* *
* @return a nul-terminated string or NULL. Use free() to release it. * @return a nul-terminated string or NULL. Use free() to release it.
*/ */
char *config_GetDataDirDefault (void) char *config_GetDataDir (void)
{ {
return strdup (PKGDATADIR); const char *path = getenv ("VLC_DATA_PATH");
return strdup ((path != NULL) ? path : PKGDATADIR);
} }
/** /**
......
...@@ -75,7 +75,7 @@ error: ...@@ -75,7 +75,7 @@ error:
return (path != NULL) ? path : strdup (PKGLIBDIR); return (path != NULL) ? path : strdup (PKGLIBDIR);
} }
char *config_GetDataDirDefault (void) char *config_GetDataDir (void)
{ {
char *libdir = config_GetLibDir (); char *libdir = config_GetLibDir ();
if (libdir == NULL) if (libdir == NULL)
......
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
* *
* @return a null-terminated string or NULL. Use free() to release it. * @return a null-terminated string or NULL. Use free() to release it.
*/ */
char *config_GetDataDirDefault (void) char *config_GetDataDir (void)
{ {
return GetConstPrivatePath(); return GetConstPrivatePath();
} }
......
...@@ -63,9 +63,10 @@ error: ...@@ -63,9 +63,10 @@ error:
abort (); abort ();
} }
char *config_GetDataDirDefault( void ) char *config_GetDataDir (void)
{ {
return config_GetLibDir (); const char *path = getenv ("VLC_DATA_PATH");
return (path != NULL) ? strdup (path) : config_GetLibDir ();
} }
const char *config_GetConfDir (void) const char *config_GetConfDir (void)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment