2009-03-13 18:43:16 +01:00
|
|
|
/*
|
2022-07-14 17:58:12 +02:00
|
|
|
* Copyright 2003-2022 The Music Player Daemon Project
|
2009-03-13 18:43:16 +01:00
|
|
|
* http://www.musicpd.org
|
2004-02-24 00:41:20 +01:00
|
|
|
*
|
|
|
|
* 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.
|
2009-03-13 18:43:16 +01:00
|
|
|
*
|
|
|
|
* 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.
|
2004-02-24 00:41:20 +01:00
|
|
|
*/
|
|
|
|
|
2013-10-17 22:00:01 +02:00
|
|
|
#include "Path.hxx"
|
2013-10-17 22:13:54 +02:00
|
|
|
#include "Charset.hxx"
|
2013-10-01 18:35:37 +02:00
|
|
|
|
2013-10-17 22:13:54 +02:00
|
|
|
std::string
|
2017-05-08 14:44:49 +02:00
|
|
|
Path::ToUTF8() const noexcept
|
2006-07-20 18:02:40 +02:00
|
|
|
{
|
2016-04-12 21:24:16 +02:00
|
|
|
try {
|
2018-07-18 16:30:46 +02:00
|
|
|
return ToUTF8Throw();
|
2017-12-19 10:56:23 +01:00
|
|
|
} catch (...) {
|
2021-11-11 11:18:46 +01:00
|
|
|
return {};
|
2016-04-12 21:24:16 +02:00
|
|
|
}
|
2004-02-24 00:41:20 +01:00
|
|
|
}
|
2015-03-01 01:09:53 +01:00
|
|
|
|
2018-07-18 16:30:46 +02:00
|
|
|
std::string
|
|
|
|
Path::ToUTF8Throw() const
|
|
|
|
{
|
|
|
|
return ::PathToUTF8(c_str());
|
|
|
|
}
|
|
|
|
|
2020-01-03 15:49:29 +01:00
|
|
|
Path::const_pointer
|
2017-05-08 14:44:49 +02:00
|
|
|
Path::GetSuffix() const noexcept
|
2015-03-01 01:09:53 +01:00
|
|
|
{
|
2015-03-05 08:45:04 +01:00
|
|
|
const auto base = GetBase().c_str();
|
|
|
|
const auto *dot = StringFindLast(base, '.');
|
|
|
|
if (dot == nullptr || dot == base)
|
|
|
|
return nullptr;
|
|
|
|
|
|
|
|
return dot + 1;
|
2015-03-01 01:09:53 +01:00
|
|
|
}
|