mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-04 05:20:30 +00:00
SoundPlayer: Port M3UParser to Core::Stream
Also make the path parameter a StringView, since that's what gets passed in.
This commit is contained in:
parent
684c3efc04
commit
183b054695
Notes:
sideshowbarker
2024-07-17 06:49:24 +09:00
Author: https://github.com/AtkinsSJ Commit: https://github.com/SerenityOS/serenity/commit/183b054695 Pull-request: https://github.com/SerenityOS/serenity/pull/15215
2 changed files with 5 additions and 6 deletions
|
@ -9,17 +9,16 @@
|
|||
#include <AK/RefPtr.h>
|
||||
#include <AK/ScopeGuard.h>
|
||||
#include <AK/Utf8View.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibCore/Stream.h>
|
||||
|
||||
M3UParser::M3UParser()
|
||||
{
|
||||
}
|
||||
|
||||
NonnullOwnPtr<M3UParser> M3UParser::from_file(const String path)
|
||||
NonnullOwnPtr<M3UParser> M3UParser::from_file(StringView path)
|
||||
{
|
||||
auto file_result = Core::File::open(path, Core::OpenMode::ReadOnly);
|
||||
VERIFY(!file_result.is_error());
|
||||
auto contents = file_result.value()->read_all();
|
||||
auto file_result = Core::Stream::File::open(path, Core::Stream::OpenMode::Read).release_value_but_fixme_should_propagate_errors();
|
||||
auto contents = file_result->read_all().release_value_but_fixme_should_propagate_errors();
|
||||
auto use_utf8 = path.ends_with(".m3u8"sv, CaseSensitivity::CaseInsensitive);
|
||||
return from_memory(String { contents, NoChomp }, use_utf8);
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ struct M3UEntry {
|
|||
|
||||
class M3UParser {
|
||||
public:
|
||||
static NonnullOwnPtr<M3UParser> from_file(String path);
|
||||
static NonnullOwnPtr<M3UParser> from_file(StringView path);
|
||||
static NonnullOwnPtr<M3UParser> from_memory(String const& m3u_contents, bool utf8);
|
||||
|
||||
NonnullOwnPtr<Vector<M3UEntry>> parse(bool include_extended_info);
|
||||
|
|
Loading…
Reference in a new issue