From ce925ba56fdcdf6168db7597185f6c34643a7501 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 17 Feb 2014 22:48:26 +0100 Subject: fs/Charset: disable if GLib is disabled --- src/fs/AllocatedPath.cxx | 10 ++++++++++ src/fs/Charset.cxx | 17 +++++++++++++++++ src/fs/Config.cxx | 6 ++++-- 3 files changed, 31 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/fs/AllocatedPath.cxx b/src/fs/AllocatedPath.cxx index 6770fa1b0..30ce7e3a9 100644 --- a/src/fs/AllocatedPath.cxx +++ b/src/fs/AllocatedPath.cxx @@ -24,22 +24,32 @@ #include "util/Error.hxx" #include "Compiler.h" +#ifdef HAVE_GLIB #include +#endif #include +#ifdef HAVE_GLIB + inline AllocatedPath::AllocatedPath(Donate, pointer _value) :value(_value) { g_free(_value); } +#endif + /* no inlining, please */ AllocatedPath::~AllocatedPath() {} AllocatedPath AllocatedPath::FromUTF8(const char *path_utf8) { +#ifdef HAVE_GLIB return AllocatedPath(Donate(), ::PathFromUTF8(path_utf8)); +#else + return FromFS(path_utf8); +#endif } AllocatedPath diff --git a/src/fs/Charset.cxx b/src/fs/Charset.cxx index 05d644b89..232a9a23c 100644 --- a/src/fs/Charset.cxx +++ b/src/fs/Charset.cxx @@ -25,7 +25,9 @@ #include "Log.hxx" #include "Traits.hxx" +#ifdef HAVE_GLIB #include +#endif #include @@ -42,6 +44,7 @@ */ static constexpr size_t MPD_PATH_MAX_UTF8 = (MPD_PATH_MAX - 1) * 4 + 1; +#ifdef HAVE_GLIB static std::string fs_charset; gcc_pure @@ -71,10 +74,16 @@ SetFSCharset(const char *charset) "SetFSCharset: fs charset is: %s", fs_charset.c_str()); } +#endif + const char * GetFSCharset() { +#ifdef HAVE_GLIB return fs_charset.empty() ? "utf-8" : fs_charset.c_str(); +#else + return "utf-8"; +#endif } static inline void FixSeparators(std::string &s) @@ -95,10 +104,13 @@ PathToUTF8(const char *path_fs) { assert(path_fs != nullptr); +#ifdef HAVE_GLIB if (fs_charset.empty()) { +#endif auto result = std::string(path_fs); FixSeparators(result); return result; +#ifdef HAVE_GLIB } GIConv conv = g_iconv_open("utf-8", fs_charset.c_str()); @@ -123,8 +135,11 @@ PathToUTF8(const char *path_fs) auto result_path = std::string(path_utf8, sizeof(path_utf8) - out_left); FixSeparators(result_path); return result_path; +#endif } +#ifdef HAVE_GLIB + char * PathFromUTF8(const char *path_utf8) { @@ -137,3 +152,5 @@ PathFromUTF8(const char *path_utf8) fs_charset.c_str(), "utf-8", nullptr, nullptr, nullptr); } + +#endif diff --git a/src/fs/Config.cxx b/src/fs/Config.cxx index c9555bcc2..6aa23005c 100644 --- a/src/fs/Config.cxx +++ b/src/fs/Config.cxx @@ -22,16 +22,17 @@ #include "Charset.hxx" #include "config/ConfigGlobal.hxx" -#include - #ifdef WIN32 #include // for GetACP() #include // for sprintf() +#elif defined(HAVE_GLIB) +#include #endif void ConfigureFS() { +#if defined(HAVE_GLIB) || defined(WIN32) const char *charset = nullptr; charset = config_get_string(CONF_FS_CHARSET, nullptr); @@ -56,4 +57,5 @@ ConfigureFS() if (charset != nullptr) SetFSCharset(charset); +#endif } -- cgit v1.2.3