aboutsummaryrefslogtreecommitdiffstats
path: root/src/fs
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2013-10-17 22:42:22 +0200
committerMax Kellermann <max@duempel.org>2013-10-17 22:42:22 +0200
commit608a98c873b94826a98b8dbdf17aa02320de8776 (patch)
tree80b5714da2c5cd8fab07d0148a821c4d2f2efed6 /src/fs
parentf951e5356b7b6fb1126e367e641882f1e5192f76 (diff)
downloadmpd-608a98c873b94826a98b8dbdf17aa02320de8776.tar.gz
mpd-608a98c873b94826a98b8dbdf17aa02320de8776.tar.xz
mpd-608a98c873b94826a98b8dbdf17aa02320de8776.zip
fs/Charset: default filesystem charset is UTF-8
Implement a fast path for UTF-8 which leaves fs_charset empty, and don't assign a value to fs_charset if there's no configuration.
Diffstat (limited to 'src/fs')
-rw-r--r--src/fs/Charset.cxx6
-rw-r--r--src/fs/Config.cxx7
2 files changed, 7 insertions, 6 deletions
diff --git a/src/fs/Charset.cxx b/src/fs/Charset.cxx
index b75001043..3e324f470 100644
--- a/src/fs/Charset.cxx
+++ b/src/fs/Charset.cxx
@@ -81,6 +81,9 @@ PathToUTF8(const char *path_fs)
{
assert(path_fs != nullptr);
+ if (fs_charset.empty())
+ return std::string(path_fs);
+
GIConv conv = g_iconv_open("utf-8", fs_charset.c_str());
if (conv == reinterpret_cast<GIConv>(-1))
return std::string();
@@ -108,6 +111,9 @@ PathFromUTF8(const char *path_utf8)
{
assert(path_utf8 != nullptr);
+ if (fs_charset.empty())
+ return g_strdup(path_utf8);
+
return g_convert(path_utf8, -1,
fs_charset.c_str(), "utf-8",
nullptr, nullptr, nullptr);
diff --git a/src/fs/Config.cxx b/src/fs/Config.cxx
index e08e9f0bf..3d7e99b4a 100644
--- a/src/fs/Config.cxx
+++ b/src/fs/Config.cxx
@@ -60,11 +60,6 @@ ConfigureFS()
#endif
}
- if (charset) {
+ if (charset != nullptr)
SetFSCharset(charset);
- } else {
- LogDebug(path_domain,
- "setting filesystem charset to ISO-8859-1");
- SetFSCharset("ISO-8859-1");
- }
}