diff --git a/src/fs/NarrowPath.cxx b/src/fs/NarrowPath.cxx new file mode 100644 index 000000000..1939998ec --- /dev/null +++ b/src/fs/NarrowPath.cxx @@ -0,0 +1,36 @@ +/* + * Copyright 2003-2018 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 "NarrowPath.hxx" + +#ifdef _UNICODE + +#include "lib/icu/Win32.hxx" + +#include + +NarrowPath::NarrowPath(Path _path) noexcept + :value(WideCharToMultiByte(CP_ACP, _path.c_str())) +{ + if (value.IsNull()) + /* fall back to empty string */ + value = Value::Empty(); +} + +#endif /* _UNICODE */ diff --git a/src/fs/NarrowPath.hxx b/src/fs/NarrowPath.hxx index 20d05b7cb..df92053ba 100644 --- a/src/fs/NarrowPath.hxx +++ b/src/fs/NarrowPath.hxx @@ -21,12 +21,9 @@ #define MPD_FS_NARROW_PATH_HXX #include "Path.hxx" -#include "util/Macros.hxx" #ifdef _UNICODE -#include "lib/icu/Win32.hxx" #include "util/AllocatedString.hxx" -#include #else #include "util/StringPointer.hxx" #endif @@ -48,12 +45,7 @@ class NarrowPath { public: #ifdef _UNICODE - explicit NarrowPath(Path _path) - :value(WideCharToMultiByte(CP_ACP, _path.c_str())) { - if (value.IsNull()) - /* fall back to empty string */ - value = Value::Empty(); - } + explicit NarrowPath(Path _path) noexcept; #else explicit NarrowPath(Path _path):value(_path.c_str()) {} #endif diff --git a/src/fs/meson.build b/src/fs/meson.build index 201d446a2..7ceb3f39d 100644 --- a/src/fs/meson.build +++ b/src/fs/meson.build @@ -6,6 +6,7 @@ fs_sources = [ 'Path.cxx', 'Path2.cxx', 'AllocatedPath.cxx', + 'NarrowPath.cxx', 'FileSystem.cxx', 'List.cxx', 'StandardDirectory.cxx',