diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Mapper.cxx | 8 | ||||
-rw-r--r-- | src/Mapper.hxx | 9 | ||||
-rw-r--r-- | src/PlaylistFile.cxx | 8 |
3 files changed, 11 insertions, 14 deletions
diff --git a/src/Mapper.cxx b/src/Mapper.cxx index e2d082122..7c89ba7c4 100644 --- a/src/Mapper.cxx +++ b/src/Mapper.cxx @@ -248,7 +248,7 @@ map_song_fs(const Song *song) return Path::FromUTF8(song->uri); } -char * +std::string map_fs_to_utf8(const char *path_fs) { if (!music_dir_fs.IsNull() && @@ -263,11 +263,7 @@ map_fs_to_utf8(const char *path_fs) while (path_fs[0] == G_DIR_SEPARATOR) ++path_fs; - const std::string path_utf8 = Path::ToUTF8(path_fs); - if (path_utf8.empty()) - return nullptr; - - return g_strdup(path_utf8.c_str()); + return Path::ToUTF8(path_fs); } const Path & diff --git a/src/Mapper.hxx b/src/Mapper.hxx index a224b8051..76c1a6dac 100644 --- a/src/Mapper.hxx +++ b/src/Mapper.hxx @@ -24,6 +24,8 @@ #ifndef MPD_MAPPER_HXX #define MPD_MAPPER_HXX +#include <string> + #include "gcc.h" #define PLAYLIST_FILE_SUFFIX ".m3u" @@ -118,10 +120,11 @@ map_song_fs(const Song *song); * absolute) to a relative path in UTF-8 encoding. * * @param path_fs a path in file system encoding - * @return the relative path in UTF-8, or nullptr if mapping failed + * @return the relative path in UTF-8, or an empty string if mapping + * failed */ -gcc_malloc -char * +gcc_pure +std::string map_fs_to_utf8(const char *path_fs); /** diff --git a/src/PlaylistFile.cxx b/src/PlaylistFile.cxx index e01bc1d26..b7ed10dfa 100644 --- a/src/PlaylistFile.cxx +++ b/src/PlaylistFile.cxx @@ -248,13 +248,11 @@ LoadPlaylistFile(const char *utf8path, Error &error) s = g_strconcat("file://", path.c_str(), NULL); } else if (!uri_has_scheme(s)) { - char *path_utf8; - - path_utf8 = map_fs_to_utf8(s); - if (path_utf8 == nullptr) + const auto path = map_fs_to_utf8(s); + if (path.empty()) continue; - s = path_utf8; + s = g_strdup(path.c_str()); } else { const auto path = Path::ToUTF8(s); if (path.empty()) |