aboutsummaryrefslogtreecommitdiffstats
path: root/src/fs/Config.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2013-10-17 22:13:54 +0200
committerMax Kellermann <max@duempel.org>2013-10-17 22:29:03 +0200
commit080ee87e07f0037e559abbea6f7db73602af5137 (patch)
tree66464d51200132175724333164a43d65efb2dfe1 /src/fs/Config.cxx
parentfa60b9ae94a61c71da2b7dd7305eb191612bc6e6 (diff)
downloadmpd-080ee87e07f0037e559abbea6f7db73602af5137.tar.gz
mpd-080ee87e07f0037e559abbea6f7db73602af5137.tar.xz
mpd-080ee87e07f0037e559abbea6f7db73602af5137.zip
fs/Path: move configuration code to Config.cxx
Diffstat (limited to 'src/fs/Config.cxx')
-rw-r--r--src/fs/Config.cxx70
1 files changed, 70 insertions, 0 deletions
diff --git a/src/fs/Config.cxx b/src/fs/Config.cxx
new file mode 100644
index 000000000..e08e9f0bf
--- /dev/null
+++ b/src/fs/Config.cxx
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 2003-2013 The Music Player Daemon Project
+ * http://www.musicpd.org
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU 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.
+ */
+
+#include "config.h"
+#include "Config.hxx"
+#include "Charset.hxx"
+#include "Domain.hxx"
+#include "ConfigGlobal.hxx"
+#include "Log.hxx"
+#include "Compiler.h"
+
+#include <glib.h>
+
+#include <assert.h>
+#include <string.h>
+
+#ifdef WIN32
+#include <windows.h> // for GetACP()
+#include <stdio.h> // for sprintf()
+#endif
+
+void
+ConfigureFS()
+{
+ const char *charset = NULL;
+
+ charset = config_get_string(CONF_FS_CHARSET, NULL);
+ if (charset == NULL) {
+#ifndef WIN32
+ const gchar **encodings;
+ g_get_filename_charsets(&encodings);
+
+ if (encodings[0] != NULL && *encodings[0] != '\0')
+ charset = encodings[0];
+#else
+ /* Glib claims that file system encoding is always utf-8
+ * on native Win32 (i.e. not Cygwin).
+ * However this is true only if <gstdio.h> helpers are used.
+ * MPD uses regular <stdio.h> functions.
+ * Those functions use encoding determined by GetACP(). */
+ static char win_charset[13];
+ sprintf(win_charset, "cp%u", GetACP());
+ charset = win_charset;
+#endif
+ }
+
+ if (charset) {
+ SetFSCharset(charset);
+ } else {
+ LogDebug(path_domain,
+ "setting filesystem charset to ISO-8859-1");
+ SetFSCharset("ISO-8859-1");
+ }
+}