open: Use more StringView instead of const char*

This commit is contained in:
Kenneth Myhra 2022-01-30 20:17:42 +01:00 committed by Andreas Kling
parent 71c004b75f
commit 0dc46da99f
Notes: sideshowbarker 2024-07-17 19:56:50 +09:00

View File

@ -16,7 +16,7 @@
ErrorOr<int> serenity_main(Main::Arguments arguments)
{
Core::EventLoop loop;
Vector<const char*> urls_or_paths;
Vector<StringView> urls_or_paths;
Core::ArgsParser parser;
parser.set_general_help("Open a file or URL by executing the appropriate program.");
parser.add_positional_argument(urls_or_paths, "URL or file path to open", "url-or-path");
@ -26,7 +26,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
for (auto& url_or_path : urls_or_paths) {
auto path = Core::File::real_path_for(url_or_path);
auto url = URL::create_with_url_or_path(path.is_null() ? url_or_path : path);
auto url = URL::create_with_url_or_path(path.is_null() ? url_or_path : path.view());
if (!Desktop::Launcher::open(url)) {
warnln("Failed to open '{}'", url);