fs/NarrowPath: un-inline Windows constructor

This commit is contained in:
Max Kellermann 2020-04-02 16:24:08 +02:00
parent cdddaf21b0
commit 61d7b436a2
3 changed files with 38 additions and 9 deletions

36
src/fs/NarrowPath.cxx Normal file
View File

@ -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 */

View File

@ -21,12 +21,9 @@
#define MPD_FS_NARROW_PATH_HXX #define MPD_FS_NARROW_PATH_HXX
#include "Path.hxx" #include "Path.hxx"
#include "util/Macros.hxx"
#ifdef _UNICODE #ifdef _UNICODE
#include "lib/icu/Win32.hxx"
#include "util/AllocatedString.hxx" #include "util/AllocatedString.hxx"
#include <windows.h>
#else #else
#include "util/StringPointer.hxx" #include "util/StringPointer.hxx"
#endif #endif
@ -48,12 +45,7 @@ class NarrowPath {
public: public:
#ifdef _UNICODE #ifdef _UNICODE
explicit NarrowPath(Path _path) explicit NarrowPath(Path _path) noexcept;
:value(WideCharToMultiByte(CP_ACP, _path.c_str())) {
if (value.IsNull())
/* fall back to empty string */
value = Value::Empty();
}
#else #else
explicit NarrowPath(Path _path):value(_path.c_str()) {} explicit NarrowPath(Path _path):value(_path.c_str()) {}
#endif #endif

View File

@ -6,6 +6,7 @@ fs_sources = [
'Path.cxx', 'Path.cxx',
'Path2.cxx', 'Path2.cxx',
'AllocatedPath.cxx', 'AllocatedPath.cxx',
'NarrowPath.cxx',
'FileSystem.cxx', 'FileSystem.cxx',
'List.cxx', 'List.cxx',
'StandardDirectory.cxx', 'StandardDirectory.cxx',