Commit 44d2d9b1 authored by Max Kellermann's avatar Max Kellermann

PlaylistStream: pass Path instance to playlist_open_path()

Convert filesystem charset to UTF-8 for playlist_list_open_uri(). This fixes one of many remaining charset bugs.
parent 8302ed44
...@@ -41,7 +41,7 @@ playlist_open_in_playlist_dir(const char *uri, Mutex &mutex, Cond &cond) ...@@ -41,7 +41,7 @@ playlist_open_in_playlist_dir(const char *uri, Mutex &mutex, Cond &cond)
if (path_fs.IsNull()) if (path_fs.IsNull())
return nullptr; return nullptr;
return playlist_open_path(path_fs.c_str(), mutex, cond); return playlist_open_path(path_fs, mutex, cond);
} }
#ifdef ENABLE_DATABASE #ifdef ENABLE_DATABASE
...@@ -61,7 +61,7 @@ playlist_open_in_storage(const char *uri, const Storage *storage, ...@@ -61,7 +61,7 @@ playlist_open_in_storage(const char *uri, const Storage *storage,
{ {
const auto path = storage->MapFS(uri); const auto path = storage->MapFS(uri);
if (!path.IsNull()) if (!path.IsNull())
return playlist_open_path(path.c_str(), mutex, cond); return playlist_open_path(path, mutex, cond);
} }
const auto uri2 = storage->MapUTF8(uri); const auto uri2 = storage->MapUTF8(uri);
......
...@@ -24,21 +24,23 @@ ...@@ -24,21 +24,23 @@
#include "util/UriUtil.hxx" #include "util/UriUtil.hxx"
#include "util/Error.hxx" #include "util/Error.hxx"
#include "input/InputStream.hxx" #include "input/InputStream.hxx"
#include "fs/Path.hxx"
#include "Log.hxx" #include "Log.hxx"
#include <assert.h> #include <assert.h>
static SongEnumerator * static SongEnumerator *
playlist_open_path_suffix(const char *path_fs, Mutex &mutex, Cond &cond) playlist_open_path_suffix(Path path, Mutex &mutex, Cond &cond)
{ {
assert(path_fs != nullptr); assert(!path.IsNull());
const char *suffix = uri_get_suffix(path_fs); const char *suffix = uri_get_suffix(path.c_str());
if (suffix == nullptr || !playlist_suffix_supported(suffix)) if (suffix == nullptr || !playlist_suffix_supported(suffix))
return nullptr; return nullptr;
Error error; Error error;
InputStream *is = InputStream::OpenReady(path_fs, mutex, cond, error); InputStream *is = InputStream::OpenReady(path.c_str(),
mutex, cond, error);
if (is == nullptr) { if (is == nullptr) {
if (error.IsDefined()) if (error.IsDefined())
LogError(error); LogError(error);
...@@ -56,11 +58,16 @@ playlist_open_path_suffix(const char *path_fs, Mutex &mutex, Cond &cond) ...@@ -56,11 +58,16 @@ playlist_open_path_suffix(const char *path_fs, Mutex &mutex, Cond &cond)
} }
SongEnumerator * SongEnumerator *
playlist_open_path(const char *path_fs, Mutex &mutex, Cond &cond) playlist_open_path(Path path, Mutex &mutex, Cond &cond)
{ {
auto playlist = playlist_list_open_uri(path_fs, mutex, cond); assert(!path.IsNull());
const std::string uri_utf8 = path.ToUTF8();
auto playlist = !uri_utf8.empty()
? playlist_list_open_uri(uri_utf8.c_str(), mutex, cond)
: nullptr;
if (playlist == nullptr) if (playlist == nullptr)
playlist = playlist_open_path_suffix(path_fs, mutex, cond); playlist = playlist_open_path_suffix(path, mutex, cond);
return playlist; return playlist;
} }
......
...@@ -25,18 +25,19 @@ ...@@ -25,18 +25,19 @@
class Mutex; class Mutex;
class Cond; class Cond;
class SongEnumerator; class SongEnumerator;
class Path;
/** /**
* Opens a playlist from a local file. * Opens a playlist from a local file.
* *
* @param path_fs the path of the playlist file * @param path the path of the playlist file
* @param is_r on success, an input_stream object is returned here, * @param is_r on success, an input_stream object is returned here,
* which must be closed after the playlist_provider object is freed * which must be closed after the playlist_provider object is freed
* @return a playlist, or nullptr on error * @return a playlist, or nullptr on error
*/ */
gcc_nonnull_all gcc_nonnull_all
SongEnumerator * SongEnumerator *
playlist_open_path(const char *path_fs, Mutex &mutex, Cond &cond); playlist_open_path(Path path, Mutex &mutex, Cond &cond);
gcc_nonnull_all gcc_nonnull_all
SongEnumerator * SongEnumerator *
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment