diff options
author | Max Kellermann <max@musicpd.org> | 2020-04-02 16:24:08 +0200 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2020-04-02 16:27:44 +0200 |
commit | 61d7b436a29d492610fbc6d60928427f1533dfbe (patch) | |
tree | 0beac1a441267930f3502ca450e108295a1dc3b8 /src/fs | |
parent | cdddaf21b006163fa771ab2a626925d5bbaa0eb9 (diff) |
fs/NarrowPath: un-inline Windows constructor
Diffstat (limited to 'src/fs')
-rw-r--r-- | src/fs/NarrowPath.cxx | 36 | ||||
-rw-r--r-- | src/fs/NarrowPath.hxx | 10 | ||||
-rw-r--r-- | src/fs/meson.build | 1 |
3 files changed, 38 insertions, 9 deletions
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 <windows.h> + +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 <windows.h> #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', |